Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

TIC-80

Fantasy computer for making, playing and sharing tiny games. · By Nesbox

How to animate composite sprites?

A topic by watercolor created Nov 29, 2018 Views: 1,596 Replies: 1
Viewing posts 1 to 2

I want to flip between sprite 1 and 2 in an endless loop, which are multiple sprites with a height of 2 but I'm not sure how to make it draw the 2nd frame.

well... I'm a bit confused on what you need. if you could post a screenshot of your spritesheet so I could see what you're doing I'd be able to help you better but here goes.

The easiest way to animate sprites is to use a game time variable (usually named "t" in tic 80) like this:

Local t=0 --initialize it at 0

function Tic()

 --game code here

t=t+1 --add to time every frame

end

Now you can call  spr () like this:

spr(  sprite_index+t%60//30, x,y)

This will switch between a Sprite cell and the cell directly next to it. If you want to cycle over four sprites for example it'll look like this:

spr( sprite_index+t%120//30, x,y)

This is the method that I use, and like I said if you could elaborate on your question and maybe post some screenshots I could help you better.