Difference between revisions of "Event:getTarget"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
+
'''Available since:''' Gideros 2011.6<br/>
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''Class:''' [[Event]]<br/>
=== <translate>Description</translate> ===
+
 
<translate><br />
+
=== Description ===
Returns the element on which the event listener was registered.<br />
+
Returns the element on which the event listener was registered.
<br /></translate>
+
<syntaxhighlight lang="lua">
<source lang="lua">
 
 
(object) = Event:getTarget()
 
(object) = Event:getTarget()
</source>
+
</syntaxhighlight>
=== <translate>Return values</translate> ===
+
 
'''<translate>Returns</translate>''' (object) <translate>Target of event.</translate><br/>
+
=== Return values ===
 +
'''Returns''' (object) Target of event.<br/>
 +
 
 +
=== Example ===
 +
<syntaxhighlight lang="lua">
 +
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
 +
</syntaxhighlight>
 +
 
 +
{{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