Skip to content

Commit

Permalink
Add items to state
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcticFqx committed Nov 19, 2023
1 parent de237a5 commit c69138f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/scenes/ShopState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export class ShopState extends Phaser.GameObjects.Container {
private itemsForSale: Item[];
private shopper: Shopper;

private selectedItem: ShopItem | undefined;

constructor(scene: GameScene) {
super(scene, 0, 0);
this.scene = scene;
Expand Down Expand Up @@ -109,9 +111,10 @@ export class ShopState extends Phaser.GameObjects.Container {
new ShopItem(this.scene, Wstart + itemPositions[i].x * Wdist, Hstart + itemPositions[i].y * Hdist, item.image[0])
);

items.forEach((elem) => {
elem.on('click', () => {
console.log("click")
items.forEach((item) => {
this.add(item);
item.on('click', () => {
this.selectedItem = item;
});
});
}
Expand Down

0 comments on commit c69138f

Please sign in to comment.