When the sprite collides with another sprite the second sprite is destroyed and another sprite is created in another position. How do I do it?
this.physics.add.collider(firstObject, secondObject, () => {
let newX = secondObject.x;
let newY = secondObject.y;
secondObject.destroy();
newObject = this.physics.add.sprite(newX, newY, ‘SpriteName’);
}
I haven’t tested that code but it should be very similar to what you want to accomplish
1 Like