Hi @rexrainbow
Back to working on my game at https://emberquest.danmonroe.dev/
How do you animate chess objects that are sprites?
I have a Container object that has a Sprite and I want to animate the sprite after I have added the chess.
scene.board.addChess(agent.container, agentConfig.x, agentConfig.y, this.constants.TILEZ_AGENTS);
agent.container is a Phaser.GameObjects.Container
the container adds the Sprite:
this.phaserAgent = new PhaserAgent(this.scene, config);
this.add(this.phaserAgent);
PhaserAgent is a Phaser.Physics.Arcade.Sprite
Thanks!
1 Like
Get chess (agent.container) back by tileXYZ position, or other condition, then get sprite back, play animation.
Hmm, thank you but I still can’t get it to play.
If I just hard code and add a test to my scene, it works
this = scene
this.anims.create({
key: 'young-ogre-rest-test',
frames: this.anims.generateFrameNumbers('young-ogre', { start: 1, end: 4}),
frameRate: 3,
repeat: -1,
});
const ogre = this.add.sprite(400, 300, 'young-ogre');
ogre.anims.play('young-ogre-rest-test');
This one plays, but using agent.container.phaserAgent.anims.play(‘young-ogre-rest-test’) does not.
I noticed with debug on, that my containers and sprites in the container have the purple border around it where the sprite with the working animation does NOT have the purple border around it. Is that something that might give you a clue as to what is happening?
Check if the container, and its child sprite is got back correctly. For example, agent.container.phaserAgent
seems to be the sprite game object, but I doubt it is undefined
because that container
dose not have phaserAgent
property unless you assign a custom value.
Your a mind reader and a brilliant saviour to my newest game. I was totaly stumped until I saw what you were doing! THANK YOU THANK YOU THANK YOU. (oops, sorry for my exuberance)