Skip to content

Commit 869e6ad

Browse files
committed
Delay keyboard button press in scenes to prevent accidental skip
1 parent 39ea9c0 commit 869e6ad

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

src/Credits.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ PrinceJS.Credits.prototype = {
4343
.to({ alpha: 0 }, 2000, Phaser.Easing.Linear.None, false, 0, 0, false);
4444
this.tween4.onComplete.add(this.play, this);
4545

46-
this.input.keyboard.onDownCallback = this.play.bind(this);
46+
this.input.keyboard.onDownCallback = null;
47+
PrinceJS.Utils.delayed(() => {
48+
this.input.keyboard.onDownCallback = this.play.bind(this);
49+
}, 1000);
4750
},
4851

4952
update: function () {

src/Cutscene.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ PrinceJS.Cutscene.prototype = {
5555

5656
this.executeProgram();
5757

58-
this.input.keyboard.onDownCallback = this.continue.bind(this);
58+
this.input.keyboard.onDownCallback = null;
59+
PrinceJS.Utils.delayed(() => {
60+
this.input.keyboard.onDownCallback = this.continue.bind(this);
61+
}, 1000);
62+
5963
this.game.time.events.loop(120, this.updateScene, this);
6064
},
6165

@@ -181,14 +185,12 @@ PrinceJS.Cutscene.prototype = {
181185

182186
play: function () {
183187
this.stopMusic();
184-
185188
this.input.keyboard.onDownCallback = null;
186189
this.state.start("Game");
187190
},
188191

189192
next: function () {
190193
this.input.keyboard.onDownCallback = null;
191-
192194
if (PrinceJS.currentLevel === 1) {
193195
this.state.start("Credits");
194196
} else if (PrinceJS.currentLevel === 15) {

src/EndTitle.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ PrinceJS.EndTitle.prototype = {
3838
.to({ alpha: 0 }, 2000, Phaser.Easing.Linear.None, false, 0, 0, false);
3939
this.tween3.onComplete.add(this.next, this);
4040

41-
this.input.keyboard.onDownCallback = this.next.bind(this);
41+
this.input.keyboard.onDownCallback = null;
42+
PrinceJS.Utils.delayed(() => {
43+
this.input.keyboard.onDownCallback = this.next.bind(this);
44+
}, 1000);
4245
},
4346

4447
update: function () {

src/Title.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,12 @@ PrinceJS.Title.prototype = {
9696

9797
play: function () {
9898
this.stopMusic();
99-
10099
this.input.keyboard.onDownCallback = null;
101100
this.state.start("Game");
102101
},
103102

104103
cutscene: function () {
105104
this.stopMusic();
106-
107105
this.input.keyboard.onDownCallback = null;
108106
this.state.start("Cutscene");
109107
},

0 commit comments

Comments
 (0)