Is it possible animate tiles in tilemap?

Hello.

I have got items.png file which contains 7 frames of animation. I have built items.tilesource (Image: items.png) which contains “anim” (start tile: 1, end tile: 7, playback: Loop Ping Pong, Fps: 10). Then I have prepared a scene using items.tilemap (Tilesource: items.tilesource). After that, I attached tilemap to an object and put it to my game, so it is visible after Build and Launch. But unfortunatelly,tiles do not animate. How to make tiles animate?

Thanks in advance for your answer.

Best regards,
Sebastian.

1 Like

You currently have to programmatically animate tiles. Check out http://www.defold.com/ref/tilemap

1 Like

I created an animated tilesheet shader for Hammerwatch Coliseum that I have open sourced here: https://github.com/johnnyjr/defold-stuff/tree/master/animated%20tilemap

It should at least get you started.

7 Likes

Very nice Johan! Thanks for sharing!

1 Like

@Johan If you calculate the texcoord offset in the vertex shader you won’t get dependent texture reads, which are slower on mobile devices. Just a tiny optimization for you. :smile:

(Scroll down to listing 10-7 for details on this: https://developer.apple.com/library/ios/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/BestPracticesforShaders/BestPracticesforShaders.html)

3 Likes

Will fix that! Thanks a bunch!

1 Like

is there a tutorial how to use it

1 Like