Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created October 3, 2020 22:10
Show Gist options
  • Save flushpot1125/c61fa4c4f2519f24841d86f918ee74ff to your computer and use it in GitHub Desktop.
Save flushpot1125/c61fa4c4f2519f24841d86f918ee74ff to your computer and use it in GitHub Desktop.
/**
* Registers the keyboard event to start game.
*/
private _registerStartGameEvent(): void {
// Register the space keyboard event to start the game.
const spaceObservable = this.onKeyboardObservable.add((ev) => {
if (ev.event.keyCode === 32) { // space bar
this._ball.reset();
this._ball.applyStartImpulse();
this.onKeyboardObservable.remove(spaceObservable);
this._gameMessageControl.isVisible = false;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment