BlueGit

blue-star speeltuin

allow finishing animations after gameOver & before destroy

timfa wsadhelios · pushed by timfa

Authored 2022-10-21 · 4 years ago

Hash
2405113ede705ae70194d6be3bf19f8d571cfbe6
Parent
7fd16cfc
1 file changed +16 −6
src/minigame/frog/frogScene.js +16 −6
@@ -25,6 +25,8 @@ class FrogScene extends Scene
25 25 spaceBarTween = null;
26 26 screenTween = null;
27 27
28 destructing = false;
29
28 30 constructor (x, y, width, height, displayMode = 0)
29 31 {
30 32 super(x, y, width, height, displayMode);
@@ -44,14 +46,23 @@ class FrogScene extends Scene
44 46 {
45 47 super.update(deltaTime);
46 48
47 if (this.start)
49 if (this.start && !this.destructing)
48 50 {
49 51 this.spawnFruits(deltaTime);
50 52 }
51 else
53 else if (!this.start && !this.destructing)
52 54 {
53 55 this.checkSpacebar();
54 56 }
57
58 if (this.destructing)
59 {
60 if (this.activeObjects.length > 0)
61 {
62 return;
63 }
64 this.destroy();
65 }
55 66 }
56 67
57 68 gameOver ()
@@ -59,8 +70,9 @@ class FrogScene extends Scene
59 70 this.start = false;
60 71 this.activeObjects.forEach(ao => ao.destroy());
61 72
62 // pass over fruits array
63 // destroy self
73 // pass over fruits array to parent scene
74
75 this.destructing = true; // finish animations first
64 76 }
65 77
66 78 increaseDifficulty ()
@@ -217,8 +229,6 @@ class FrogScene extends Scene
217 229 offX * this.eatenFruit[i].scaleX, offY * this.eatenFruit[i].scaleY,
218 230 0, 0, 0, 1, this.eatenFruit[i].image);
219 231
220 console.log(this.eatenFruit[i].scaleX);
221
222 232 if (xAxisCount < maxPerXAxis)
223 233 {
224 234 xAxisCount++;
@@ -25,6 +25,8 @@ class FrogScene extends Scene
25 spaceBarTween = null;
25 spaceBarTween = null;
26 screenTween = null;
26 screenTween = null;
27
27
28 destructing = false;
29
28 constructor (x, y, width, height, displayMode = 0)
30 constructor (x, y, width, height, displayMode = 0)
29 {
31 {
30 super(x, y, width, height, displayMode);
32 super(x, y, width, height, displayMode);
@@ -44,14 +46,23 @@ class FrogScene extends Scene
44 {
46 {
45 super.update(deltaTime);
47 super.update(deltaTime);
46
48
47 if (this.start)
49 if (this.start && !this.destructing)
48 {
50 {
49 this.spawnFruits(deltaTime);
51 this.spawnFruits(deltaTime);
50 }
52 }
51 else
53 else if (!this.start && !this.destructing)
52 {
54 {
53 this.checkSpacebar();
55 this.checkSpacebar();
54 }
56 }
57
58 if (this.destructing)
59 {
60 if (this.activeObjects.length > 0)
61 {
62 return;
63 }
64 this.destroy();
65 }
55 }
66 }
56
67
57 gameOver ()
68 gameOver ()
@@ -59,8 +70,9 @@ class FrogScene extends Scene
59 this.start = false;
70 this.start = false;
60 this.activeObjects.forEach(ao => ao.destroy());
71 this.activeObjects.forEach(ao => ao.destroy());
61
72
62 // pass over fruits array
73 // pass over fruits array to parent scene
63 // destroy self
74
75 this.destructing = true; // finish animations first
64 }
76 }
65
77
66 increaseDifficulty ()
78 increaseDifficulty ()
@@ -217,8 +229,6 @@ class FrogScene extends Scene
217 offX * this.eatenFruit[i].scaleX, offY * this.eatenFruit[i].scaleY,
229 offX * this.eatenFruit[i].scaleX, offY * this.eatenFruit[i].scaleY,
218 0, 0, 0, 1, this.eatenFruit[i].image);
230 0, 0, 0, 1, this.eatenFruit[i].image);
219
231
220 console.log(this.eatenFruit[i].scaleX);
221
222 if (xAxisCount < maxPerXAxis)
232 if (xAxisCount < maxPerXAxis)
223 {
233 {
224 xAxisCount++;
234 xAxisCount++;