Does the on frame update reference on line 33 in this example exist? (https://labs.phaser.io/edit.html?src=src\animation\on%20update%20callback.js
I can’t seem to find it, is this left over from a Phaser 2 example or is it implemented in Phaser 3 ?
Does the on frame update reference on line 33 in this example exist? (https://labs.phaser.io/edit.html?src=src\animation\on%20update%20callback.js
I can’t seem to find it, is this left over from a Phaser 2 example or is it implemented in Phaser 3 ?
I could not find it either.
But this works
class MainScene extends Phaser.Scene {
constructor() {
super({ key: 'MainScene' })
}
preload() {
this.load.crossOrigin = 'anonymous'
this.load.setBaseURL('https://labs.phaser.io')
this.load.atlas('gems', 'assets/tests/columns/gems.png', 'assets/tests/columns/gems.json')
}
create() {
let frames = this.anims.generateFrameNames('gems', { prefix: 'diamond_', end: 15, zeroPad: 4 })
// uncomment to take a look at all frames
// console.log(frames)
const animConfig = {
key: 'diamond',
frames,
repeat: 3
}
this.anims.create(animConfig)
let gem = this.add.sprite(400, 300, 'gems')
gem.play('diamond')
// https://github.com/photonstorm/phaser/blob/master/src/animations/events/SPRITE_ANIMATION_KEY_UPDATE_EVENT.js
gem.on('animationupdate-diamond', (animation, animationFrame) => {
if (animationFrame.textureFrame === 'diamond_0003')
console.log('The frame "diamond_0003" is playing')
})
}
}