Reader small image

You're reading from  Corona SDK Mobile Game Development: Beginner's Guide

Product typeBook
Published inMar 2015
Publisher
ISBN-139781783559343
Edition1st Edition
Tools
Right arrow
Author (1)
Michelle M Fernandez
Michelle M Fernandez
Right arrow

Understanding events and listeners


Events are sent to listeners that are executed by a touch on the mobile screen, tap, accelerometer, and so on. Functions or objects can be event listeners. When an event occurs, the listener is called by a table that represents the event. All events will have a property name that identifies the kind of event.

Register events

Display objects and global runtime objects can be event listeners. You can add and remove listeners for events using the following object methods:

  • object:addEventListener(): This adds a listener to the object's list of listeners. When the named event occurs, the listener will be invoked and supplied with a table that represents the event.

  • object:removeEventListener(): This removes the specified listener from the object's list of listeners so that it is no longer notified of events that correspond to the specified event.

In the following example, an image display object registers to receive a touch event. Touch events are not broadcast...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Corona SDK Mobile Game Development: Beginner's Guide
Published in: Mar 2015Publisher: ISBN-13: 9781783559343

Author (1)