
by double tapping the home button and kill the application), this event may not be dispatched. If an application is forced to be terminated (e.g.



new () b : addEventListener ( "myevent", a. class ( EventDispatcher ) function ClassA : funcA ( event ) print ( "funcA", self, event : getType (), event : getTarget ()) end local a = ClassA. class ( EventDispatcher ) ClassB = gideros. For example, assume that we have an sprite hierarchy like this:ĬlassA = gideros. The next sprite at the bottom of the top-most sprite receives the event second and so on. The Sprite instance that is drawn last (top-most sprite) receives the event first. The order of dispatch is determined by the hierarchy of the scene tree. Note: even if touch or mouse doesn’t hit the Sprite instance, the instance receives mouse/touch events. If a Sprite instance is not on the scene tree, this instance doesn’t receive mouse and touch events. The mouse and touch events are dispatched to Sprite instances which are on the scene tree. Mouse events are mainly used in single-touch whereas touch events are used in multi-touch applications. Gideros runtime dispatches mouse and touch events when the the user’s finger touches the screen. ENTER_FRAME, onEnterFrame ) Mouse and touch events deltaTime ) end stage : addEventListener ( Event. Local function onEnterFrame ( event ) print ( event. In this example, onEnterFrame function increases the x-coordinate of a sprite object at each frame: This first basic example shows a moving sprite one pixel to the right at each frame.

Visual changes made by any Event.ENTER_FRAME listener function will be visible at next frame. The Gideros runtime dispatches the built-in Event.ENTER_FRAME event to Sprite instances before rendering the screen. ENTER_FRAME event, touch events, etc.) or can be dispatched to a single target (e.g. custom events which can be generated by the user.Īccording to their event type, built-in events can be broadcasted to multiple targets (e.g.ENTER_FRAME event, touch events, timer events, etc.) built-in events which are generated by the system (e.g.In Gideros, events can be divided into two categories: If the optional data value is given, it is used as a first parameter while calling the listener function. When an event is dispatched, the registered function is called. The target of an event is a listener function and an optional data value. 7 ADDED_TO_STAGE and REMOVED_FROM_STAGE EventsĮvents are the central mechanism to handle responses and they allow to create interactive applications.Īll classes that dispatch events inherit from EventDispatcher.
