I have a loading scene which preloads my textures..
preload() {
this.load.image("ship", "./assets/ship.png")...
and a level-scene with a custom player object..
export class Player extends Phaser.Physics.Matter.Sprite {
constructor(scene: Scene) {
super(scene.matter.world, 64, 64, "ship", undefined, {
friction: 0.025,
frictionAir: 0.25,
}); ...
but inside that player object i can´t set textures, it has no effect.
in level-scene:
create(){
this.player = new Player(this);...
how can i load textures inside the player subclass of the level-scene? thanks.
You just have to add the sprite to the scene, with the command
scene.add.existing(this);currently only the physics object is added.Here a small Demo: