diff --git a/src/components/Panel.ts b/src/components/Panel.ts index 08d1fa4..c578b9b 100644 --- a/src/components/Panel.ts +++ b/src/components/Panel.ts @@ -10,10 +10,14 @@ export interface PanelOptions extends ContainerOptions { export class Panel extends Container { private bg: Graphics; + private _backgroundColor: number; + private _alpha: number; constructor(opts: PanelOptions) { super(opts); this.bg = new Graphics(); + this._backgroundColor = opts.backgroundColor ?? 0x000000; + this._alpha = opts.alpha ?? 0.8; this.drawBackground(opts); this.addChild(this.bg); } @@ -21,18 +25,20 @@ export class Panel extends Container { private drawBackground(opts: PanelOptions): void { this.bg.clear(); this.bg.roundRect(0, 0, opts.width, opts.height, 8); - this.bg.fill(opts.backgroundColor ?? 0x000000); - this.bg.alpha = opts.alpha ?? 0.8; + this.bg.fill(this._backgroundColor); + this.bg.alpha = this._alpha; } resize(width: number, height: number): void { this.bg.clear(); this.bg.roundRect(0, 0, width, height, 8); - this.bg.fill(0x000000); + this.bg.fill(this._backgroundColor); + this.bg.alpha = this._alpha; } setBackgroundColor(color: number): void { - this.bg.tint = color; + this._backgroundColor = color; + this.resize(this.width, this.height); } }