Jump to content

animation doesn't loop


casey
 Share

Recommended Posts

Hi. I'm having trouble with an animation. The animation is 3 frames, and is a static image until the user ciicks in, and animates it, which should happen in a loop. Instead, the frames play once then the entire thing disappears from the screen.  How do I get it to loop? 

Also, ideally I'd have it loop a number of times then stop. I see there's an example for loop counts in the Phaser documentation, but that doesn't seem to work either... 

 

 preload: function () {
		
	
		this.load.spritesheet('spritesheet', 'pngs/sprites.png', 99, 79, 3);
		
		
	},

 create: function () {
	this.sprites = this.game.add.sprite(760, 60, 'sprites');
		
		this.sprites.inputEnabled = true;
		this.sprites.events.onInputDown.add(this.spritesanim, this);
}


spritesanim: function(){
		this.animat = this.sprites.animations.add('swing');
		this.animat.play('swing', 20, true);
	},

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...