Game Development Reference
In-Depth Information
Figure 8-8. Architecture of an event process in Corona SDK
We can register the program to listen to specific events using the addEventListener function on the
object on which we want to listen to the events, and we can pass it a function that will handle the
event when passed to it.
OBJECT:addEventListener( EVENT , HANDLER )
In this code, EVENT is one of the many events that we can register to listen for, and HANDLER is the
function that is invoked when the event is received.
Input: Touches
We can place images and text on the screen using the methods mentioned. However, we also need to
handle the various forms of input, such as touches on the touch screen. These are equivalent to mouse
clicks on the desktop. Generally, touch events are associated with a display element; you can touch
the display element and trigger a touch phase. However, Corona SDK also allows you to have a generic
touch handler that is associated with the Runtime object, which triggers the touch event for all objects.
When the user places a finger on the device, a touch event is triggered. As shown in Figure 8-9 , this
touch event has a couple of attributes, or members. A touch event starts with the finger touching the
 
Search WWH ::




Custom Search