casey Posted March 31, 2018 Share Posted March 31, 2018 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 More sharing options...
onlycape Posted March 31, 2018 Share Posted March 31, 2018 Hi @casey, Replace this line: this.animat.play('swing', 20, true); with this: this.animat.play(20, true); Regards. casey 1 Link to comment Share on other sites More sharing options...
casey Posted March 31, 2018 Author Share Posted March 31, 2018 cheers! It worked. Link to comment Share on other sites More sharing options...
Recommended Posts