Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

3. Building our First Game: Breakout > Understanding events and listeners

Understanding events and listeners

Events are sent to listeners. Functions or objects can be event listeners. When an event occurs, the listener is called by a table representing 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( ): It adds a listener to the object's list of listeners. When the named event occurs, the listener will be invoked and be supplied with a table representing the event.
  • object:removeEventListener( ): It removes the specified listener from the object's list of listeners so that it no longer is notified of events corresponding to the specified event.

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial