fix(sts-like-viewer): defer interactive setup until shape is available
Delay calling `setupInteractive` in `InventoryItemContainer` until the item shape is actually rendered to ensure the hit area matches the visual representation.
This commit is contained in:
parent
f03e6c5a7b
commit
fd41db2a89
|
|
@ -28,7 +28,6 @@ export class InventoryItemContainer extends Phaser.GameObjects.Container {
|
|||
) {
|
||||
super(scene, gridOffsetX, gridOffsetY);
|
||||
scene.add.existing(this);
|
||||
this.setupInteractive();
|
||||
|
||||
const graphics = this.scene.add.graphics();
|
||||
const label = this.scene.add.text(
|
||||
|
|
@ -57,10 +56,15 @@ export class InventoryItemContainer extends Phaser.GameObjects.Container {
|
|||
const color = computed(() => {
|
||||
return this.getItemColor(this.item.value?.id ?? "");
|
||||
});
|
||||
let hasSize = false;
|
||||
disposables.addEffect(() => {
|
||||
graphics.clear();
|
||||
if (!shape.value) return;
|
||||
this.renderGraphics(graphics, shape.value, color.value);
|
||||
|
||||
if (hasSize) return;
|
||||
hasSize = true;
|
||||
this.setupInteractive();
|
||||
});
|
||||
|
||||
const transform = computed(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue