Skip to content

Commit

Permalink
journal open/close, button click,
Browse files Browse the repository at this point in the history
  • Loading branch information
amcolash committed Jan 13, 2025
1 parent 59cfffc commit b47e5e6
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Some sound effects https://mixkit.co/

- footsteps
- door open
- metallic clunk
- book open/close
- button click

### Music

Expand Down
Binary file added public/assets/sounds/sfx/book_close.mp3
Binary file not shown.
Binary file added public/assets/sounds/sfx/book_open.mp3
Binary file not shown.
Binary file added public/assets/sounds/sfx/button.mp3
Binary file not shown.
1 change: 1 addition & 0 deletions src/classes/UI/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class Button extends GameObjects.Text {
if (!this.disabled) {
this.setSelected(false);
onClick(this);
this.scene.sound.play('button');
}
});
this.on('pointerover', () => {
Expand Down
5 changes: 4 additions & 1 deletion src/classes/UI/IconButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ export class IconButton extends GameObjects.Container {
this.add(this.rect);
this.add(this.img);

this.rect.setInteractive({ useHandCursor: true }).on('pointerdown', () => callback(this));
this.onClick = callback;
this.rect.setInteractive({ useHandCursor: true }).on('pointerdown', () => {
this.scene.sound.play('button');
callback(this);
});

this.selected = false;

Expand Down
3 changes: 3 additions & 0 deletions src/scenes/Preloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ export class Preloader extends Scene {
this.load.audio('ladder', 'sounds/sfx/ladder.mp3');
this.load.audio('door', 'sounds/sfx/door.mp3');
this.load.audio('clunk', 'sounds/sfx/clunk.mp3');
this.load.audio('book_open', 'sounds/sfx/book_open.mp3');
this.load.audio('book_close', 'sounds/sfx/book_close.mp3');
this.load.audio('button', 'sounds/sfx/button.mp3');

// music
this.load.audio(MusicType.Town, 'sounds/music/Unknown.m4a');
Expand Down
4 changes: 4 additions & 0 deletions src/scenes/dialogs/Dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export abstract class Dialog extends Scene {
}

close(success?: boolean) {
this.preHandleSuccess(success);

this.fadeOut(() => {
this.scene.stop();
if (this.dialogData.childScene) this.scene.stop(this.dialogData.childScene);
Expand All @@ -134,5 +136,7 @@ export abstract class Dialog extends Scene {
});
}

preHandleSuccess(success?: boolean): void {}

abstract handleSuccess(success?: boolean): void;
}
6 changes: 6 additions & 0 deletions src/scenes/dialogs/JournalDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export class JournalDialog extends Dialog {
this.input.keyboard?.on('keydown-J', () => {
this.close();
});

this.sound.play('book_open');
}

preHandleSuccess(): void {
this.sound.play('book_close');
}

handleSuccess(): void {}
Expand Down

0 comments on commit b47e5e6

Please sign in to comment.