Game Development Reference
In-Depth Information
This event handler does a number of interesting things:
It figures out which object has been clicked by accessing the event's arajp*_qnnajpP]ncap prop-
erty and assigning it to a variable called _qnnajp@n]cK^fa_p (more on the _qnnajpP]ncap property
It then invokes the op]np@n]c method of the object. This starts the object dragging, with the
effect you can clearly see on the stage:
You want the object that you're dragging to be above all the other objects on the stage. This
creates the illusion that it's being picked up. To do this, you need to move it to the highest
position in the display list. oap?deh`Ej`at$_qnnajp@n]cK^fa_p(jqi?deh`naj)-% takes care of
that quite nicely:
It sets the [eo@n]ccejc variable to pnqa:
It adds the kjIkqoaQl listener to the object. You could have easily added this event to the
object in the constructor method, but, for performance reasons it's generally a good idea to
create listeners only when you need them. You don't need to listen for a IKQOA[QL event
before the IKQOA[@KSJ event is triggered, so it makes sense to add it here:
Now that you can happily drag the object around the stage, what happens when the mouse is released?
The kjIkqoaQl event handler is called:
_qnnajp@n]cK^fa_p*naikraArajpHeopajan$IkqoaArajp*IKQOA[QL( ±
This event listener uses the target object's opkl@n]c method to stop the drag effect. It sets [eo@n]ccejc
to b]hoa and then removes itself after completing the job.
Search Nedrilad ::

Custom Search