Advance an animation one frame at a time by interacting?

If you set a tile with multiple frames to 0 fps, is there a way to advance that tile's current frame each time you interact with the tile, or another nearby tile?

Using swap to change the tile repeatedly seems wrong if you can use a single tile with multiple frames instead.

You can use frame frameIndex, docs here.

Thanks Grim,

Here's the answer I found by testing.

Tile 1:

on interact do
  // tell Tile 2 to
  tell x,y to
    call "eventName"
  end
end

Tile 2:

on eventName do
  frameIndex = frame event.x,event.y
  // # = number of frames in animation 
  if frameIndex < # then 
    frameIndex++
    frame frameIndex
  end
end

If multiple tiles are used in the animation you'll need to tell each tile to call the event using the tiles x,y coordinates, or you could use emit.

Note that frameIndex is a variable, so you can rename it if you want to.

1 Like