diff --git a/src/assets/assets.ts b/src/assets/assets.ts index 775b436..99f1c8c 100644 --- a/src/assets/assets.ts +++ b/src/assets/assets.ts @@ -34,6 +34,7 @@ const images: Image[] = [ // UI image("ui/hud", "hud"), + image("ui/shop_buy_button", "buy_button"), // Titlescreen image("titlescreen/sky", "title_sky"), diff --git a/src/assets/images/ui/shop_buy_button.png b/src/assets/images/ui/shop_buy_button.png new file mode 100644 index 0000000..06f9e7d Binary files /dev/null and b/src/assets/images/ui/shop_buy_button.png differ diff --git a/src/scenes/ShopState.ts b/src/scenes/ShopState.ts index 7d209df..be20fc6 100644 --- a/src/scenes/ShopState.ts +++ b/src/scenes/ShopState.ts @@ -64,6 +64,8 @@ export class ShopState extends Phaser.GameObjects.Container { private selectedItem: ShopItem | undefined; + private buyButton: Button; + constructor(scene: GameScene) { super(scene, 0, 0); this.scene = scene; @@ -96,6 +98,20 @@ export class ShopState extends Phaser.GameObjects.Container { this.shopper = new Shopper(scene, 0.5, 0.5); this.add(this.shopper); + + this.buyButton = new Button(this.scene, this.scene.W * 0.6, this.scene.H * 0.6); + const buySign = this.scene.add.sprite(0, 0, 'buy_button').setOrigin(0.3, 0.35); + this.buyButton.add(buySign); + this.buyButton.add(this.scene.add.text(0, 0, 'BUY', {fontSize: 80, fontStyle: 'bold', align: 'center'})); + this.buyButton.bindInteractive(buySign, true); + this.buyButton.on('click', () => { + if(this.selectedItem) + console.log('Buying', this.selectedItem); + else + console.log('Select item first') + }); + this.add(this.buyButton); + } populateShop() {