Jump to content

animation doesn't loop


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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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