fix: infinite loop when end game

main
tiendat3699 2024-03-04 09:29:39 +07:00
parent 9bef92b7e7
commit f03d95d12a
3 changed files with 23 additions and 12 deletions

View File

@ -58,7 +58,7 @@
}, },
{ {
"__type__": "cc.animation.HierarchyPath", "__type__": "cc.animation.HierarchyPath",
"path": "Sprite" "path": "goal"
}, },
{ {
"__type__": "cc.animation.Channel", "__type__": "cc.animation.Channel",
@ -87,7 +87,9 @@
"leftTangent": 0, "leftTangent": 0,
"leftTangentWeight": 1, "leftTangentWeight": 1,
"easingMethod": 0, "easingMethod": 0,
"__editorExtras__": null "__editorExtras__": {
"tangentMode": 0
}
}, },
{ {
"__type__": "cc.RealKeyframeValue", "__type__": "cc.RealKeyframeValue",
@ -99,7 +101,9 @@
"leftTangent": 0, "leftTangent": 0,
"leftTangentWeight": 1, "leftTangentWeight": 1,
"easingMethod": 0, "easingMethod": 0,
"__editorExtras__": null "__editorExtras__": {
"tangentMode": 0
}
}, },
{ {
"__type__": "cc.RealKeyframeValue", "__type__": "cc.RealKeyframeValue",
@ -111,7 +115,9 @@
"leftTangent": 0, "leftTangent": 0,
"leftTangentWeight": 1, "leftTangentWeight": 1,
"easingMethod": 0, "easingMethod": 0,
"__editorExtras__": null "__editorExtras__": {
"tangentMode": 0
}
}, },
{ {
"__type__": "cc.RealKeyframeValue", "__type__": "cc.RealKeyframeValue",
@ -123,7 +129,9 @@
"leftTangent": 0, "leftTangent": 0,
"leftTangentWeight": 1, "leftTangentWeight": 1,
"easingMethod": 0, "easingMethod": 0,
"__editorExtras__": null "__editorExtras__": {
"tangentMode": 0
}
}, },
{ {
"__type__": "cc.RealKeyframeValue", "__type__": "cc.RealKeyframeValue",
@ -135,7 +143,9 @@
"leftTangent": 0, "leftTangent": 0,
"leftTangentWeight": 1, "leftTangentWeight": 1,
"easingMethod": 0, "easingMethod": 0,
"__editorExtras__": null "__editorExtras__": {
"tangentMode": 0
}
}, },
{ {
"__type__": "cc.RealKeyframeValue", "__type__": "cc.RealKeyframeValue",
@ -147,7 +157,9 @@
"leftTangent": 0, "leftTangent": 0,
"leftTangentWeight": 1, "leftTangentWeight": 1,
"easingMethod": 0, "easingMethod": 0,
"__editorExtras__": null "__editorExtras__": {
"tangentMode": 0
}
} }
], ],
"preExtrapolation": 1, "preExtrapolation": 1,
@ -175,7 +187,9 @@
"leftTangent": 0, "leftTangent": 0,
"leftTangentWeight": 1, "leftTangentWeight": 1,
"easingMethod": 0, "easingMethod": 0,
"__editorExtras__": null "__editorExtras__": {
"tangentMode": 0
}
} }
], ],
"preExtrapolation": 1, "preExtrapolation": 1,

View File

@ -9,10 +9,7 @@ import {
director, director,
EventTarget, EventTarget,
IPhysics2DContact, IPhysics2DContact,
ParticleSystem,
randomRangeInt,
RigidBody2D, RigidBody2D,
Vec2,
} from 'cc'; } from 'cc';
import { GameplayController } from './GameplayController'; import { GameplayController } from './GameplayController';
import { SoundManager } from './SoundManager'; import { SoundManager } from './SoundManager';

View File

@ -245,7 +245,7 @@ export class GameplayController extends Component {
public updateCurrentBallsInGame(value: number) { public updateCurrentBallsInGame(value: number) {
this._currentBallsInGame += value; this._currentBallsInGame += value;
if (this._currentBallsInGame <= 0) { if (this._currentBallsInGame == 0) {
this.ball--; this.ball--;
this.eventUpdateBall.emit(EventType.UpdateBall, this.ball); this.eventUpdateBall.emit(EventType.UpdateBall, this.ball);
if (this.ball <= 0) this.ChangeGameState(GameState.EndGame); if (this.ball <= 0) this.ChangeGameState(GameState.EndGame);