Animated Tiles?

I know this was handled in the long threat before but I can’t get animated tiles to work in the current version of dusk. Are there some changed to access tiles anims?

What is the best approach to tile animations?

I want to do something like this:

A character is walking over a tile and the tile below it’s feet should start animating. How can I define the animation and start and stop it correctly?

Any help welcome!

I wish you all a Merry Christmas! :slight_smile:

Animated tiles in Dusk have always been an alpha feature. For now, you can set the !isSprite! property to build sprites as tiles instead of image rectangles and manually set up the animation. Sometime soon I’m going to build Dusk 1.0; animated tiles might get better support then.

  • Caleb

Thx for the info Caleb. Can you please give a short example on how to use the !isSprite! property and how to access sprite frames?

A bit late perhaps, but I animate tiles on the go like this:

Tile properties:

anim:enabled true anim:options !!! {name: closed start: 1 count: 1 time: 1000 loopCount: 1}, {name: opened start: 1 count: 4 time: 500 loopCount: 1 } ++physcis options

Then i get the tile sometime in code and start the sequence just like a sprite.

local tile = map.layer["someLayer"].tile(x, y) if (tile) then tile:setSequence("opened") tile:play() end

You can add anim options and do it just like a normal sprite: http://https://docs.coronalabs.com/guide/media/spriteAnimation/index.html

Sorry for the delay, and thanks @bendikr5 for reminding me of this topic :(.

@d.mach:

@bendikr5’s approach is a good one. Try that and see how it goes. I believe it’ll get you further than !isSprite!, as it will support animation options better.

I’m definitely putting improved animations near the top of my Dusk 1.0 feature list, so buckle up! Dusk 1.0 is currently working well in my personal project (a large-scale metroidvania), so the public date is coming slowly closer.

  • Caleb

Thank you guys for the help!

Can’t wait for Dusk 1.0 btw :wink:

how do i access frame animations and the frame numbers using this?

And what happens to the animations when the sprites are culled and re-entering the visible screen? Will they just restart from the beginning?

I wonder because I need an animation of multiply tiles side by side which should be always in sync. Something which is like this example:

Think about 5 animated tiles, side by side. Each sequence has a frame count of 5 frames. The first tile should start with frame 1, the second with frame 2 and so on. The animation should loop through the frames.

Chris

Ah… got it:

!!! {name: closed start: 1 count: 1 time: 1000 loopCount: 1}, {name: opened frames:{2,3,4,5,6}  time: 500 loopCount: 0 }

Thx! :slight_smile:

@c.noeth:

Tile animations will definitely stay in sync. However, without code, you can’t override a tile’s starting frame. (Actually, I don’t even think Dusk lets you with code…)

  • Caleb

What about the culling? How can I start tile animations off screen? Should I turn off culling for the sprite tiles? If so, how is this done for each tile?

UPDATE: I found this here:

map.layer[1].\_lockTileDrawn(x, y) -- A core method that locks a single tile at an x,y tile position

but it doesn’t seem to work!?

Is there a way to stop tiles culling of some tiles off screen, so the sprite animation of this tiles can be started while they (the tiles) are out of the screen borders?

I want to achieve this: I have some water animation tiles and I want them to start playing in the map at start of the scene. But the sprite:play() is only starting the tiles on screen. How can I do this?

Sounds like I have the exact same setup as you with several equal tiles next to each other playing in sync. All I do is add properties in tiled(My spritesheet has 13 frames):

anim:enabled true anim:options !!! start: 1 count: 13 time: 1000

Then the animation starts when the tiles are drawn and no need to do anything in code.

You don’t need tile:play() at all. Dusk handles tile animations on its own. If you set up an animation in properties, Dusk will animate it when it comes on-screen and keep it synced with all other tiles of the same type. Is there some specific reason you need more control over it?

  • Caleb

Thank you all for the detailed info!

Regarding “in sync” I need tiles that allow the following for example: I have a sequence of a water surface for a water animation. This is build in TILED with water tiles side by side. BUT the animation should be like this:

Tile1, Tile2, Tile3

This are three water tiles set side by side in TILED. Each of the tiles is showing the same water animation BUT starts with a different frame as first frame of the animation, so there is an illusion of waves on the surface which seem to be bigger than the standard tile size.

I wonder if the water surface is still “playing” correctly if for example Tile3 was culled and redrawn when the screen is entered again, while Tile1 and Tile2 are staying on the screen during the culling of Tile3.

Hope this makes sense somehow… but please note I haven’t tested the info here you gave me, so maybe everything is already working! :slight_smile:

Thx again!

Dusk does not currently sync all animations to the same time. Instead, it syncs them to the first built tile. This means that each animated tile will stay in sync with each other tile of the same type, but they will not stay in sync with other non-related animated tiles. Dusk 1.0 syncs all animations to the map build time, though, so this will be fixed in 1.0. (And sorry for continually saying that, but the Dusk repo on my end is in extensive reconstruction mode, so I can’t really release small fixes that easily. I’m doing my very best to get Dusk 1.0 all together.)

  • Caleb

Animated tiles in Dusk have always been an alpha feature. For now, you can set the !isSprite! property to build sprites as tiles instead of image rectangles and manually set up the animation. Sometime soon I’m going to build Dusk 1.0; animated tiles might get better support then.

  • Caleb

Thx for the info Caleb. Can you please give a short example on how to use the !isSprite! property and how to access sprite frames?

A bit late perhaps, but I animate tiles on the go like this:

Tile properties:

anim:enabled true anim:options !!! {name: closed start: 1 count: 1 time: 1000 loopCount: 1}, {name: opened start: 1 count: 4 time: 500 loopCount: 1 } ++physcis options

Then i get the tile sometime in code and start the sequence just like a sprite.

local tile = map.layer["someLayer"].tile(x, y) if (tile) then tile:setSequence("opened") tile:play() end

You can add anim options and do it just like a normal sprite: http://https://docs.coronalabs.com/guide/media/spriteAnimation/index.html

Sorry for the delay, and thanks @bendikr5 for reminding me of this topic :(.

@d.mach:

@bendikr5’s approach is a good one. Try that and see how it goes. I believe it’ll get you further than !isSprite!, as it will support animation options better.

I’m definitely putting improved animations near the top of my Dusk 1.0 feature list, so buckle up! Dusk 1.0 is currently working well in my personal project (a large-scale metroidvania), so the public date is coming slowly closer.

  • Caleb

Thank you guys for the help!

Can’t wait for Dusk 1.0 btw :wink:

how do i access frame animations and the frame numbers using this?

And what happens to the animations when the sprites are culled and re-entering the visible screen? Will they just restart from the beginning?

I wonder because I need an animation of multiply tiles side by side which should be always in sync. Something which is like this example:

Think about 5 animated tiles, side by side. Each sequence has a frame count of 5 frames. The first tile should start with frame 1, the second with frame 2 and so on. The animation should loop through the frames.

Chris