Game Development Reference
In-Depth Information
User Input
A video game is not going to be a whole lot of fun to play if the user has no way
of controlling the events that happen, so in this chapter we will be looking at
the various ways in which we can add interactivity to our programs by using
Marmalade. By the end of this chapter you will know how to detect the following
types of input:
• Key presses
• Touch screen and pointer inputs
• Detection of gestures such as swipes and pinches
• Changes in device orientation using accelerometers
Detecting key input
We'll start our journey into the world of player input methods with the simplest
method possible—pressing keys, which we detect by using the s3eKeyboard API.
To use these functions in our code, we just need to include the s3eKeyboard.h ile.
While the touch screen may now rule supreme as the primary method of interacting
with many modern devices, it is still worthwhile to know how to detect key presses.
Android devices, in particular, have keys that are intended to be used for quick
access to menus and for navigation around a program. Quite often these are not
even physical buttons, just an area at the bottom of the touch screen, but they are
still reported as key presses.
Key press detection is also extremely useful when debugging your code in the
Windows simulator, as Marmalade allows full access to your computer's keyboard too.
This makes it really easy to add a debugging functionality triggered by a key press.
The s3eKeyboard API allows us to detect key input either by key state or by
character input. It also provides functionality that allows us to determine what
kind of keyboard support the device we are running on has available.
Search WWH ::




Custom Search