[SOLVED] Spritemap doesn't play! help!


#1

So I’m trying to get my enemies to loop an animation, using the Spritemap class.

I can use setFrame() and setAnimFrame() with no problems, but when I use play() the animation stays on the first frame and never progresses.

Here is the relevant code:

private const move:String = "move";

public function Enemy() 
	{
                type = "Enemy";
		graphic = new Spritemap(ENEMY, 64, 64);
		Spritemap(graphic).add(move, [0, 1, 2, 3, 4, 5], 1, true);
		
		Spritemap(graphic).play(move); //not working, why????
		
	}

(Martí Angelats i Ribera) #2

2 things:

  1. Try saving the spritemap in a variable before assing it into the graphic.
  2. Let us see your ENEMY embed file.

#3

I’ve tried assigning the spritemap to a variable, same problems as before.

I cannot upload an image because I am a new user, the image is a 64 tall by 384 wide image of 6 sprites (making the sprites 64x64). I can access each and every sprite by setFrame() and setAnimFrame().


#4

here is a link to the file: https://drive.google.com/file/d/0B-6jOuA4QervYlV0b3k5NS12WFE/view?usp=sharing

and the line of code embedding it:

[Embed(source = '../assets/Enemy.png')]private const ENEMY:Class;

(meganmorgangames) #5

Just a stab in the dark, because I’ve had similar problems before. Are you overriding update on the class that calls on Enemy? If so, did you super the update?

Again, just a stab in the dark.


#6

I am an idiot, wasn’t calling super.update() in my world. Thank you so much!


(Jacob Albano) #7

We’ve all been there! Here’s a tip: If you’re using Flashdevelop, you can type override and then start typing the name of the function you want and it’ll automatically add an overridden version. For example, I can type “over(enter)up(enter)” and it’ll add an override of update(), complete with the super.update() call.