mirror of
https://github.com/OpenLiberty/liberty-bikes.git
synced 2025-01-30 10:40:13 +08:00
Only request animation frames when needed
This commit is contained in:
parent
11366c662c
commit
55078e8b24
@ -236,8 +236,6 @@ export class ControlsComponent implements OnInit, OnDestroy {
|
||||
ctx.lineTo(rightArrow.point3.x, rightArrow.point3.y);
|
||||
ctx.closePath();
|
||||
ctx.stroke();
|
||||
|
||||
window.requestAnimationFrame(() => this.draw());
|
||||
}
|
||||
|
||||
touchStarted(evt: TouchEvent) {
|
||||
@ -302,6 +300,8 @@ export class ControlsComponent implements OnInit, OnDestroy {
|
||||
} else {
|
||||
this.rightPressed = false;
|
||||
}
|
||||
|
||||
window.requestAnimationFrame(() => this.draw());
|
||||
}
|
||||
|
||||
canvasReleased(x: number, y: number) {
|
||||
@ -325,6 +325,8 @@ export class ControlsComponent implements OnInit, OnDestroy {
|
||||
if (this.rightTriangle.containsPoint(location)) {
|
||||
this.rightPressed = false;
|
||||
}
|
||||
|
||||
window.requestAnimationFrame(() => this.draw());
|
||||
}
|
||||
|
||||
// Game actions
|
||||
|
Loading…
Reference in New Issue
Block a user