Defold Tilemap Animator

#1

Hi all, this is my first contribution to the Defold workspace and my first post to the forums.

One of the issues I ran into with Defold was the fact that it does not support runtime tile animations. Most of the games that I love to play now and loved to play growing up boasted beautiful tilemap scenes with moving parts all over the place.

Defold Tilemap Animator (DTA) provides runtime tile animations in a Defold game engine project. This includes both looping and trigger animations, which can be activated from a script.

Updates will continue to roll out. Happy Defolding!

12 Likes

#2

Sounds like a good module, thanks! Yet the link in github to the html5 example is not working.
http://planksoftware.com/html/defold_tilemap_automator.html

2 Likes

#3

Approved! It should show up in the Asset Portal in a couple of minutes.

1 Like

#4

Yes, I will fix this issue once I draft a more interesting example project and implement a couple new features.

0 Likes

#5

Thank you! I will submit cover art for the asset soon.

1 Like

#6

Full version 1.0 has been released. It now supports four loop playbacks:

  1. “loop_forward”
  2. “loop_backward”
  3. “loop_pingpong”
  4. “loop_corolla”

And four on-demand playbacks:

  1. “once_forward”
  2. “once_backward”
  3. “once_pingpong”
  4. “once_corolla”

On-demand playbacks are the bread and butter of DTA: they allow you to programmatically run animations on any tile assigned with a “once_” playback. This can be used to display interactive visual effects on a tilemap, such as the player stepping through grass or chopping down a tree. I’m pleased to see these playbacks working properly!

4 Likes

#7

This asset is amazing! :wink:

Just a small note, that for me natural was that “once_forward” should end at “end_tile”

function dta.once_forward(data, instance_data)
    instance_data["frame"] = instance_data["frame"] + 1
    if instance_data["frame"] > data["end_tile"] then
    	instance_data["frame"] = data["end_tile"] -- not "start_tile"
    	instance_data["extra"] = 9999
    end
end
2 Likes

#8

Thanks! Glad you like it. I see what you mean about the start_tile preference, I will look into it. I actually plan to rewrite this module soon, since there are quite a few components I can make more flexible and efficient. Now that I’ve learned about semantic versioning and how to handle open source projects properly, hopefully there won’t be too many setup changes after I get the new version out. :slight_smile:

If you have any feature ideas, let me know! I’ve started using this in my own project and I realize there may be some additional functions I could add to make things super convenient.

2 Likes

#9

Yoau can see DTA here in action on the grass: :smiley: :leaves:

One feature I was thinking on was using DTA to set tiles properly according to some event (e.g. when that grass is burnt), but I came out with a workaround of just modifying “animation_group” table to suite my needs :wink:

4 Likes

#10

Looks great! Bringing tile map worlds to life is exactly what I was hoping to see more of.

As for the suggestion, that’s in part why I added once_animations and the dta.animate(x, y) function. If you keep track of where the fire is burning, you can pass the coordinates to that function to roll the new animation.

Oh wait. Actually, something just came to kind. You mean you’re trying to assign both a continuous grass animation and a burning animation when an event occurs? I didn’t think of that. :persevere:

Yes, you could edit the tables, but I’d like to make a safer way of dealing with that. Thanks for the suggestion, I’ll make sure to work it in soon.

1 Like

#11

No, no. One solution will be to draw burnt version of tileset and use it with your DTA - I will just set_tile to another tile (let’s say 100) and in “animation_group” there will be an entry starting at 100 and with end_tile = e.g. 110, so one normal animation, but I’m changing a tile :wink:

But that’s a lot of drawing and I’m thinking about some shader instead, but for now I have something pretty easy and pretty ugly:

(it’s working just like 2D lights, but color is black and not drawn on background (but drawn on hero sprite - that you can see it in the end of this gif)

I don’t like it now, but perhaps I’m going into a proper direction with something like a “decay” on the ground. For grass I will probably need to make something different.

2 Likes

#12

Hi all,

I decided to rewrite this entire module from scratch. The resulting Lua module was cut ~in half, design complexity was drastically reduced, the code is much more readable, and performance has been slightly improved.

Additionally, due to my recent learning about semantic versioning and how to properly manage a GitHub release, all erroneous previous releases have been deleted and replaced with version 0.1.0. Sorry for any inconvenience, although I am relieved to know that this will no longer be an issue in the future. Please take a look through the new README.md for setup changes.

Finally, a few notes about improvements to the module:

  1. All loop_ and once_ callback presets have been removed. Instead, you are able to define your own custom animation sequences without being forced to conform to a preset. Very handy!
  2. Tilemap layers have better support, namely when activating a trigger animation from a script.
  3. Message passing has been incorporated into the project. DTA will send animation progress updates to your on_message() function. This can be disabled by calling dta.toggle_message_passing().

I noticed that using tilemap.set_tile() does not play nice with DTA, since the only version of tilemap that the module knows about is the one that exists when dta.init() is called. It will continue animating the exact same tiles regardless of how the tilemap changes throughout its lifetime. If you are setting new tiles to your map, then you will likely run into this problem. I am looking into how to handle this.

Let me know if you run into any glitches or unexpected behaviors. I will be sure to fix them as soon as possible.

5 Likes

#13

Good work!

2 Likes

#14

Thanks for making this extension! I’m planning to add it to my current project.

3 Likes

#15

It has been a while, but I figured I’d mention: DTA v0.2.0 was just released. Your suggestion was added! We can now specify a new reset field in the animation_groups table passed into dta.init(). This argument indicates that this trigger animation should regain its start tile graphic on completion. Otherwise, this animation will quit rolling once the final sequence frame has been reached.

7 Likes