I have a sprite with 6 frames, and when I click on a button I want to show the frame 3, for example. I'm try this code, but it's still stopping in frame 1.
function preload (){
this.load.spritesheet('info', 'images/info.png', { frameWidth: 550, frameHeight: 400 });
}
function create (){
var infos = this.add.sprite(275,200,"info")
this.anims.create({
key: "informations",
frames: this.anims.generateFrameNumbers("info", { start: 0, end: 6 }),
frameRate: 10,
repeat: -1
});
// I'm try to show the frame 3 here.
informations.pause(3);
// When I play, the animation work!
//infos.anims.play("informations", true);
}
I found the documentation for pause( [atFrame] ), but it isn't working.
atFrame
is actually of type Phaser.Animations.AnimationFrame
. So you need to pass one of those.
You can get one of these types by calling infos.anims.currentAnim.frames[0]
for example, where 0
is the index of the frame you want.
// Assuming you want the third actual frame:
infos.anims.pause(infos.anims.currentAnim.frames[2]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With