Flixel - Animated Tilemaps

Posted by nospoone on Game Development See other posts from Game Development or by nospoone
Published on 2012-10-29T08:42:18Z Indexed on 2012/10/29 11:19 UTC
Read the original article Hit count: 749

Filed under:
|
|

I am using Flixel 2.55 and I am trying to animate a tilemap. I found this piece of code that apparently enables the use of sprites as tiles.

From what I understand, 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 the relevant parts from LevelLoader.as, which only instantiates the AnimatedTilemaps (piece of code from forum) and pushes sprites to the 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);

Now, 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 AnimatedTiles 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 on this for a week now and can't seem to put my finger on what's wrong. I am also open to other solutions to have animates tiles in a tilemap.

If other details are needed, just ask.

PS: Sorry for my english, I am not a native speaker...

© Game Development or respective owner

Related posts about animation

Related posts about tilemap