-
Notifications
You must be signed in to change notification settings - Fork 2
KeyboardMovement
Manno edited this page Dec 6, 2016
·
1 revision
This example on movement based on keyboard controls explains the very basics on what the elements are involved in steering a character based on keyboard controls:
- Registering key presses and -releases;
- Updating an element (a Sprite in this example) every frame based on the keys that are currently pressed.
This example suffers from the 'bug' that if you move horizontal and vertical simultaneously, you move faster than if you only move in one dimension. One (somewhat less elegant) way to solve would be to allow only movement in one dimension at the same time by changing the if-else structure. Again: this example mainly explains the elements involved.