Tried fiddling with your stuff @yannick but nothing is rendering to my screen
Code I am working with (with your class used, and my scene I made as a ui channel to the main game scene is getting the draw() calls including the fillrects, but nothing is rendering to my screen unfortunately):
class DraggableContainer extends Phaser.GameObjects.Container {
constructor(scene, x, y, width, height, children){
super(scene, x, y, children)
scene.add.existing(this)
this.setSize(width, height)
.setInteractive()
.on('drag', p => {
this.setX(p.x - this._dragX + width / 2)
this.setY(p.y - this._dragY + height / 2)
})
.on('pointerdown', (p, x, y) => {
this._dragX = x
this._dragY = y
})
scene.input.setDraggable(this, true)
}
}
class Player_Resources_Scene extends Phaser.Scene {
constructor(args){
super({key: "Player_Resources_Scene", active: true});
this.width = 200;
this.height = 20;
this.elements = 3;
}
creategraphic(){
const {width, height} = this.sys.game.canvas;
this.hpbar = this.add.graphics()
this.hpbar.fillStyle(0xff0000,1);
this.endbar = this.add.graphics()
this.endbar.fillStyle(0x00ff00,1);
this.manabar = this.add.graphics()
this.manabar.fillStyle(0x0000ff,1);
this.container = new DraggableContainer(
this,
width/2-this.width/2,
height-this.height*this.elements,
this.width,
this.height*this.elements,
[this.hpbar,this.endbar,this.manabar]
)
}
draw(data){
const {currenthp, maxhp, currentmana, maxmana, currentend, maxend} = data;
const hpmod = currenthp / maxhp;
const manamod = currentmana / maxmana;
const endmod = currentend / maxend;
const {width, height} = this.sys.game.canvas;
this.hpbar.fillRect(width/2-this.width/2, height-this.height*this.elements, this.width*hpmod, height)
this.endbar.fillRect(width/2-this.width/2, height-this.height*(this.elements-1), this.width*hpmod, height)
this.manabar.fillRect(width/2-this.width/2, height-this.height*(this.elements-2), this.width*hpmod, height)
}
create(){
this.creategraphic();
this.scene.get('game').events.on('updateresources', data=>{
this.draw(data);
})
}
}