Skip to content

Commit

Permalink
fix(settings): ignore hit on pad when not on canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
domi7777 committed Nov 2, 2024
1 parent 70080f4 commit ee2ba65
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/scenes/DrumsScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ export class DrumsScene extends Phaser.Scene {
.setStrokeStyle(2, hexToColor('#FFF'), 0.8)
.setInteractive()
.setOrigin(0, 0);
button.on('pointerdown', () => {
button.on('pointerdown', (e: Phaser.Input.Pointer) => {
if (e.downElement?.tagName?.toLowerCase() !== 'canvas') {
return;
}
button.setFillStyle(hitColor);
playSample(instrument);
this.scene.get(LoopTracksScene.key).events.emit('instrument-played', {instrument, scene: this});
Expand Down
13 changes: 5 additions & 8 deletions src/settings/TweakPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ import {LoopTracksScene} from '../scenes/LoopTracksScene.ts';
export class TweakPane {

constructor(private game: Phaser.Game) {
const container = document.getElementById('settings');
if (!container) {
throw new Error('No settings container found');
}
const pane = new Pane({
title: 'Settings',
expanded: false,
container: document.getElementById('settings')!
});
pane.on('fold', (e) => {
if(e.expanded){
this.game.pause();
}else{
this.game.resume();
}
container,
});
pane.addButton({title: 'Delete current loop'}).on('click', (e) => {
LoopTracksScene.deleteCurrentTrack();
Expand Down

0 comments on commit ee2ba65

Please sign in to comment.