Game Development Reference
In-Depth Information
Table 9-1. ( continued )
Event Type
Events Handled
System and application
APPLICATION_START
APPLICATION_RESUME
APPLICATION_SUSPEND
APPLICATION_EXIT
COMPLETE
TIMER
TIMER_COMPLETE
Sound and timer
MOUSE_DOWN
MOUSE_UP
MOUSE_MOVE
Mouse
COMPLETE
ERROR
PROGRESS
URL loader
BEGIN_CONTACT
END_CONTACT
PRE_SOLVE
POST_SOLVE
Physics
Touch
An application needs to set an event listener to be able to listen to a particular event. The event
listener can be attached to any display object.
local image = newImage("myImage.png")
function handler(object, event)
print("Got an event")
end
image:addEventListener(Event.TOUCHES_BEGIN, handler, image)
The event listener takes the event, the handler, and an additional parameter that allows for passing
data to the event handler. The event handler gets two parameters: the extra data that we pass to the
handler and the event object that contains the event-related data.
 
Search WWH ::




Custom Search