Hello
Is it possible to set multiple Texture to Sprite Class ??
I using this example code
class Brain extends Phaser.GameObjects.Sprite {
constructor (scene, x, y)
{
super(scene, x, y);
this.setTexture('brain');
this.setTexture('another_sprite'); //<- add another sprite
this.setPosition(x, y);
}
preUpdate (time, delta)
{
super.preUpdate(time, delta);
this.rotation += 0.01;
}
}
var game = new Phaser.Game(config);
function preload ()
{
this.load.image('brain', 'assets/sprites/brain.png');
this.load.image('another_sprite', 'assets/sprites/another_sprite.png'); //<- add another sprite
}
But finally it only successful to show the last sprite.
One of my way to solve my problem
add
this.setTexture('brain');
this.another_sprite = scene.add.image('another_sprite');
....
preUpdate (time, delta)
{
super.preUpdate(time, delta);
this.rotation += 0.01;
this.another_sprite += 0.01;
}
to Sprite Class
Is there any best way to set multiple Texture to Sprite Class ??
Thank you very much