This adds support for tile animations created in editors like Tiled and saved into the TMX files.
Currently, I have not found a good way to use the animation rate set in the editor, so that must be set when using the tile later and creating an AnimationComponent.
Here is an example of how to then implement the animation:
tiles := []*Tile{}
for idx, layer := range level.TileLayers {
for _, tile := range layer.Tiles {
if tile.Image == nil {
log.Printf("Tile has no image at point: %v", tile.Point)
}
t := &Tile{BasicEntity: ecs.NewBasic()}
if len(tile.Drawables) > 0 {
t.AnimationComponent = common.NewAnimationComponent(tile.Drawables, 0.1)
t.AnimationComponent.AddDefaultAnimation(tile.Animation)
}
t.RenderComponent = common.RenderComponent{
Drawable: tile.Image,
Scale: engo.Point{X: 1, Y: 1},
StartZIndex: float32(idx),
}
t.SpaceComponent = common.SpaceComponent{
Position: tile.Point,
}
tiles = append(tiles, t)
}
}
Coverage increased (+0.05%) to 40.905% when pulling 4080e22c70c72869b00144d6647b879050119433 on raziel2244:master into fbe20e0b813eb5947dceb34938f972f4b61403b0 on EngoEngine:master.
This adds support for tile animations created in editors like Tiled and saved into the TMX files.
Currently, I have not found a good way to use the animation rate set in the editor, so that must be set when using the tile later and creating an AnimationComponent.
Here is an example of how to then implement the animation: