I am coding a 2d rpg that loads/destroys maps in chunks. The first time the chunk is loaded the code below works. When the chunk is reloaded(same code as first load), the chest animation does not play, but everything else works. I’ve narrowed it down to the qq.push(chestID) line. If I comment it out the animation plays.
export function openChest(player, chest){
let chestID = chest.getData('chest_id');
let chestsCollected = this.registry.get('chestsCollected');
if(!chestsCollected.includes(chestID) && this.jButtonA.pressed){
chest.play('chestopen',50,false);
let qq = this.registry.get('chestsCollected');
qq.push(chestID);
}
}
Here is how I am triggering openChest function.
scene.physics.add.overlap(scene.halo, chests, scene.openChest, null, this);
Update:
I also tried with the same results, everything works but the animation does not play. The chests show the initial sprite.
Phaser.Utils.Array.Add(qq, chestID);