Hello
I've got stuck with an "Entity & Spritemap" object.
Can not make it animate with "sprite.play (" xxx ");
Have tried sprite.play ("xxx") in
Entity new () function, as well as in the update () function.
I can however animate the object with "sprite.setAnimFrame (" xxx ", index)",
or with "sprite.frame = index".
index += 1;
if (index >= 8)
index = 5;
But with "sprite.play (....)" nothing happens at all.
What have I missed?
Have checked http://haxepunk.com/documentation/tutorials/movement-and-animation/.
As far as I can see, I have not done anything differently.
Sincerely, OB
here is the full source for my Entity!
class MushRoom extends Entity
{
var sprite:Spritemap;
var i:Int = 5;
public function new(x:Float=0, y:Float=0)
{
super(x, y);
sprite = new Spritemap("graphics/centipede_8.png", 10, 10);
sprite.add("green", [5, 6, 7, 8], 12);
sprite.play("green");
//graphic = sprite;
addGraphic(sprite);
}
public override function update() {
/* this works!
i += 1;
if (i >= 8)
i = 5;
sprite.frame = i;
*/
// or
/* this works!
i += 1;
if (i >= 8)
i = 5;
sprite.setAnimFrame("green", i);
*/
/* this dosen´t work!
sprite.play("green");
*/
}
}