Fric Posted November 15, 2018 Share Posted November 15, 2018 I have animation this.anims.create({ key: 'left', frames: this.anims.generateFrameNumbers('man', { start: 1, end: 3 }), frameRate: 10, repeat: -1 }); and when i press left key, i play it if (cursors.left.isDown) { player.setVelocityX(-160); player.anims.play('left', true); } I understand that repeat param is responsible for looping animation, but i tried 0, 1, false, -1 and the animation still loops. I didn't find any DOC with all objects and there parameters, so i'm asking here Link to comment Share on other sites More sharing options...
Ananth Posted November 19, 2018 Share Posted November 19, 2018 On 11/16/2018 at 12:41 AM, Fric said: player.anims.play('left', true); you can replace false instead of adding true. player.anims.play('left', false); Like this, And also in repeat param you assign value 0. Link to comment Share on other sites More sharing options...
Fric Posted November 20, 2018 Author Share Posted November 20, 2018 Thank you! Link to comment Share on other sites More sharing options...
thosakwe Posted November 20, 2018 Share Posted November 20, 2018 On 11/19/2018 at 1:14 AM, Ananth said: you can replace false instead of adding true. player.anims.play('left', false); Like this, And also in repeat param you assign value 0. Just wanted to expound upon this answer, for anyone who stumbles across this in the future. That second parameter on `anims.play` is named "ignoreIfPlaying." If false, whichever animation is currently playing will stop, even if it's the animation you intend to play. If true, then if you're already playing that animation it will continue. It's false by default, so you can omit the second argument entirely. Secondly, `repeat` determines the number of times the animation will play. When you have it as -1, Phaser interprets that as "loop indefinitely." The default value is 0, in which case the animation will play once, and repeat zero times. For more info, see the API docs: https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Components.Animation.html And: https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Components.Animation.html#play__anchor Link to comment Share on other sites More sharing options...
Recommended Posts