allow finishing animations after gameOver & before destroy
@@ -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 Scene25
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 Scene44
{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
else53
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 Scene59
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 array73
// pass over fruits array to parent scene63
// destroy self74
75
this.destructing = true; // finish animations first64
}76
}65
77
66
increaseDifficulty ()78
increaseDifficulty ()@@ -217,8 +229,6 @@ class FrogScene extends Scene217
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++;