Game Development Reference
In-Depth Information
Illustration 16: A simple scene to demonstrate reading keyboard input
After creating the scene, create a new script in scripts sub folder that we dedicated for
script files, and name it KeyboardMovement. Let's say that we want to move the cube in
the four directions: up, down, left, and right depending on which keyboard arrow key the
player is pressing. Listing 4 shows the required code to implement such functionality. All
you have to do is to add the script to the cube and start the game to move it using the
keyboard arrow keys.
Search WWH ::




Custom Search