Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created October 3, 2020 22:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
/**
* 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