I’m building an rpg that’s loading in chunks. Everything is working well except I am trying to display a chest sprite with no anim. The path is correct, the keyword is correct. I have verified this by using a multi frame anim and it works.
This DOES NOT work:
frames: [{ key: ‘destructs’, frame: 77 }]
But this DOES work:
frames: anims.generateFrameNumbers(‘destructs’, { frames: [78, 77] }),
frameRate: 8,
repeat: 0
Seems like both should work. The single frame anim works for other sprites, like my player. Any ideas as to where I might have gone wrong?
Edit: Here is my Chest class:
import { createTreasureAnims } from '../Anims/treasureAnims.js';
export default class Chest extends Phaser.Physics.Arcade.Sprite {
constructor(scene, x, y) {
super(scene, x, y, 'destructs', 77);
this.scene = scene;
scene.physics.add.existing(this);
this.play('chestclosed', true);
this.moves = false;
this.sound = this.scene.sound.add('coinSFX');
this.sound.setVolume(0.4);
this.setSize(20, 20, true);
}
openChest(player, chest) {}
}
export function placeChests(scene, map) {
let chests = scene.physics.add.group();
chests.addMultiple(
map.createFromObjects('Chests', {
name: 'chestSprite',
classType: Chest
})
);
let chestID = 0;
chests.children.each(function (chest) {
const worth = Phaser.Math.Between(1, 10);
chest.chest_id = chestID;
chestID++;
}, this);
scene.physics.add.overlap(scene.halo, chests, scene.openChest, null, this);
return chests;
}
Phaser.GameObjects.GameObjectFactory.register('chest', function (x, y) {
const chest = new Chest(this.scene, x, y);
this.displayList.add(chest);
this.updateList.add(chest);
return chest;
});