-
How can I animate a tile? I am new to ldtk and bevy. Looks like ldtk doesn't support animation but how can I do it myself? There is the AnimatedTile struct in bevy_ecs_tilemap. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Sorry it took me a while to get back to you on this. I think you can just insert that component on the tile you're interested in, I don't see why not. Though, note that bevy_ecs_tilemap requires that the tiles in the animation be contiguous. Selecting the appropriate tile entity in a system could be done in a couple different ways depending on your use case. If there's an intgrid value associated with the tiles you want to animate - you could add the fn animation_component_for_water_tile(_: IntGridCell) -> AnimatedTile {
todo!()
}
#[derive(Debug, Default, Bundle, LdtkIntCell)]
struct WaterBundle {
#[with(animation_component_for_water_tile)]
animation: AnimatedTile,
} Otherwise, if the tile you want to animate is only associated with a certain tile visually, not logically associated with an intgrid value, you may want to use one of the tile metadata components. In LDtk, edit the tile in the tileset to give it custom data, or a custom "enum for tile marking". Then the plugin will insert one of the components linked in that document on those tiles automatically. From there, it's a matter of using those components to find the appropriate tile entity in a system and insert the I've decided this could use a guide or example so I've created an issue: #311 |
Beta Was this translation helpful? Give feedback.
Sorry it took me a while to get back to you on this. I think you can just insert that component on the tile you're interested in, I don't see why not. Though, note that bevy_ecs_tilemap requires that the tiles in the animation be contiguous.
Selecting the appropriate tile entity in a system could be done in a couple different ways depending on your use case.
If there's an intgrid value associated with the tiles you want to animate - you could add the
AnimatedTile
using the ldtk int cell registration API. Something like...