Difference between revisions of "Event:getTarget"
From GiderosMobile
(added example) |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
(One intermediate revision by the same user not shown) | |||
Line 4: | Line 4: | ||
=== Description === | === Description === | ||
Returns the element on which the event listener was registered. | Returns the element on which the event listener was registered. | ||
− | < | + | <syntaxhighlight lang="lua"> |
(object) = Event:getTarget() | (object) = Event:getTarget() | ||
− | </ | + | </syntaxhighlight> |
=== Return values === | === Return values === | ||
Line 12: | Line 12: | ||
=== Example === | === Example === | ||
− | < | + | <syntaxhighlight lang="lua"> |
function ExplosionLayer:addExplosion(x, y) | function ExplosionLayer:addExplosion(x, y) | ||
local explosion | local explosion | ||
Line 26: | Line 26: | ||
self.pool[#self.pool + 1] = explosion | self.pool[#self.pool + 1] = explosion | ||
end | end | ||
− | </ | + | </syntaxhighlight> |
{{Event}} | {{Event}} |
Latest revision as of 14:26, 13 July 2023
Available since: Gideros 2011.6
Class: Event
Description
Returns the element on which the event listener was registered.
(object) = Event:getTarget()
Return values
Returns (object) Target of event.
Example
function ExplosionLayer:addExplosion(x, y)
local explosion
...
explosion = MovieClip.new(timeline)
explosion:addEventListener(Event.COMPLETE, self.onExplosionComplete, self)
...
end
function ExplosionLayer:onExplosionComplete(event)
local explosion = event:getTarget()
explosion:removeFromParent()
self.pool[#self.pool + 1] = explosion
end