Skip to content

Commit

Permalink
separated the shroom pickup callback to a separate function for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
insulationman committed Jul 25, 2023
1 parent c29fd60 commit d01909d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Scenes/Game/OrustScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,17 @@ export default class OrustScene extends Phaser.Scene {
//add overlay trigger for all mushrooms
shrooms.children.iterate((shroom) => {
this.physics.add.overlap(this.player, shroom, () => {
shroom.destroy();
this.mushroomPickupCallback(shroom);
});
});
}

private mushroomPickupCallback(shroom: Phaser.GameObjects.GameObject): void {
//remove the mushroom from the display list
shroom.destroy();
//we can add more logic here, like adding the mushroom to the player's inventory
}

private initCollidingActions(): void {
const objects = this.map.createFromObjects("Interactive", {
name: "house",
Expand Down

0 comments on commit d01909d

Please sign in to comment.