Difference between revisions of "Sprite:getNumChildren"

From GiderosMobile
Line 8: Line 8:
 
(number) = Sprite:getNumChildren()
 
(number) = Sprite:getNumChildren()
 
</source>
 
</source>
 +
=== Return values ===
 
'''Returns''' (number) The number of children of this sprite.<br/>
 
'''Returns''' (number) The number of children of this sprite.<br/>
 +
=== Examples ===
 +
'''Example'''<br/>
 +
<source lang="lua">local container1 = Sprite.new()<br />
 +
local container2 = Sprite.new()<br />
 +
<br />
 +
local sprite1 = Sprite.new();<br />
 +
local sprite2 = Sprite.new();<br />
 +
<br />
 +
container2:addChild(container1)<br />
 +
container1:addChild(sprite1)<br />
 +
container1:addChild(sprite2)<br />
 +
<br />
 +
print(container1:getNumChildren()) --&gt; 2<br />
 +
print(container2:getNumChildren()) --&gt; 1<br />
 +
print(sprite1:getNumChildren()) --&gt; 0<br />
 +
print(sprite2:getNumChildren()) --&gt; 0</source>

Revision as of 10:39, 23 August 2018

Available since: Gideros 2011.6

Description


Returns the number of children of this sprite.

(number) = Sprite:getNumChildren()

Return values

Returns (number) The number of children of this sprite.

Examples

Example

local container1 = Sprite.new()<br />
local container2 = Sprite.new()<br />
<br />
local sprite1 = Sprite.new();<br />
local sprite2 = Sprite.new();<br />
<br />
container2:addChild(container1)<br />
container1:addChild(sprite1)<br />
container1:addChild(sprite2)<br />
<br />
print(container1:getNumChildren()) --&gt; 2<br />
print(container2:getNumChildren()) --&gt; 1<br />
print(sprite1:getNumChildren()) --&gt; 0<br />
print(sprite2:getNumChildren()) --&gt; 0