Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { onKeyboardEvent } from "../tools";
export default class PlayerComponent extends Mesh {
// ...
/*
* An example of keycode reference : https://keycode.info/
*/
/**
* Moves the player on the left
*/
@onKeyboardEvent(65, KeyboardEventTypes.KEYDOWN)
protected moveLeft(): void {
this.position.z += 5;
}
/**
* Moves the player on the right.
*/
@onKeyboardEvent(68, KeyboardEventTypes.KEYDOWN)
protected moveRight(): void {
this.position.z -= 5;
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.