I am trying to animate a tilemap using Flixel 2.55. I found this code that apparently enables the use of sprites as tiles.
To my understanding, this loops over the tilemap's graphic and replaces the tile's pixels with the sprite's pixels each time they change. I have implemented the class and it's working, but not completely; the tiles get replaced, but do not animate unless the camera moves. Here's is the relevant part from LevelLoader.as
, which only instantiates the AnimatedTilemap
s (piece of code from forum) and pushes sprites into an array:
// AnimatedTile is just an extended FlxSprite
private var _waterTop1:AnimatedTile;
// Create ground tilemap
_groundTilemap = new AnimatedTilemap();
_groundTilemap.loadMap(_rawXML.Ground, Assets.OverworldGround, 8, 8);
FlxG.state.add(_groundTilemap);
_waterTop1 = new AnimatedTile(8, 8, Assets.WaterTop, 100);
// .Animate only adds and plays an animation, with a startAtFrame param.
_waterTop1.Animate('run', [0...47], 10, true, 0);
It seems as though the sprites are updating. I tried tracing the update()
s, and they are running for both the sprites and the tilemap. The sprites are even changing frames. Using only AnimatedTile
s and hard-placing them (giving a x
and y
) works and animates. What troubles me is that they only update when the camera moves.
I've been stuck on this for a week now. I am also open to other solutions for animating tilemap tiles.