Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit fcdd2b3

Browse files
committed
fixed GameLoop stop function: in native, cancelAnimationFrame takes request id and after stoping, loopId should be assigned to null in case of need to restart
1 parent 25cf0b7 commit fcdd2b3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/native/utils/game-loop.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export default class GameLoop {
1616
}
1717
}
1818
stop() {
19-
window.cancelAnimationFrame(this.loop);
19+
if (!this.loopID) {
20+
window.cancelAnimationFrame(this.loopID);
21+
this.loopID = null;
22+
}
2023
}
2124
subscribe(callback) {
2225
return this.subscribers.push(callback);

src/utils/game-loop.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export default class GameLoop {
1616
}
1717
}
1818
stop() {
19-
window.cancelAnimationFrame(this.loopID);
19+
if (!this.loopID) {
20+
window.cancelAnimationFrame(this.loopID);
21+
this.loopID = null;
22+
}
2023
}
2124
subscribe(callback) {
2225
return this.subscribers.push(callback);

0 commit comments

Comments
 (0)