Difference between revisions of "Sprite:removeFromParent"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
'''Available since:''' Gideros 2011.6<br/>
 
'''Available since:''' Gideros 2011.6<br/>
 +
'''Class:''' [[Sprite]]<br/>
 +
 
=== Description ===
 
=== Description ===
<br />
+
If the sprite has a parent, removes the sprite from the child list of its parent sprite.
If the sprite has a parent, removes the sprite from the child list of its parent sprite. This function is equilavent to:<br />
+
<syntaxhighlight lang="lua">
<br />
+
Sprite:removeFromParent()
&lt;pre&gt;&lt;code&gt;<br />
+
</syntaxhighlight>
function Sprite:removeFromParent()<br />
+
 
local parent = self:getParent()<br />
+
This function is equilavent to:
if parent ~= nil then<br />
+
<syntaxhighlight lang="lua">
parent:removeChild(self)<br />
+
function Sprite:removeFromParent()
end<br />
+
local parent = self:getParent()
end<br />
+
if parent ~= nil then
<br />
+
parent:removeChild(self)
&lt;/code&gt;&lt;/pre&gt;<br />
+
end
<source lang="lua">
+
end
Sprite:removeFromParent()
+
</syntaxhighlight>
</source>
+
 
 +
{{Sprite}}

Latest revision as of 14:33, 13 July 2023

Available since: Gideros 2011.6
Class: Sprite

Description

If the sprite has a parent, removes the sprite from the child list of its parent sprite.

Sprite:removeFromParent()

This function is equilavent to:

function Sprite:removeFromParent()
	local parent = self:getParent()
	if parent ~= nil then
		parent:removeChild(self)
	end
end