Difference between revisions of "Sprite:getNumChildren"

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 />
+
Returns the number of children of this sprite.
Returns the number of children of this sprite.<br />
+
<syntaxhighlight lang="lua">
<br />
 
<source lang="lua">
 
 
(number) = Sprite:getNumChildren()
 
(number) = Sprite:getNumChildren()
</source>
+
</syntaxhighlight>
 +
 
 
=== Return values ===
 
=== Return values ===
'''Returns''' (number) The number of children of this sprite.<br/>
+
'''Returns''' (number) the number of children of this sprite<br/>
 +
 
 
=== Examples ===
 
=== Examples ===
'''Example'''<br/>
+
<syntaxhighlight lang="lua">
<source lang="lua">local container1 = Sprite.new()<br />
+
local container1 = Sprite.new()
local container2 = Sprite.new()<br />
+
local container2 = Sprite.new()
<br />
+
 
local sprite1 = Sprite.new();<br />
+
local sprite1 = Sprite.new();
local sprite2 = Sprite.new();<br />
+
local sprite2 = Sprite.new();
<br />
+
 
container2:addChild(container1)<br />
+
container2:addChild(container1)
container1:addChild(sprite1)<br />
+
container1:addChild(sprite1)
container1:addChild(sprite2)<br />
+
container1:addChild(sprite2)
<br />
+
 
print(container1:getNumChildren()) --&gt; 2<br />
+
print(container1:getNumChildren()) --> 2
print(container2:getNumChildren()) --&gt; 1<br />
+
print(container2:getNumChildren()) --> 1
print(sprite1:getNumChildren()) --&gt; 0<br />
+
print(sprite1:getNumChildren()) --> 0
print(sprite2:getNumChildren()) --&gt; 0</source>
+
print(sprite2:getNumChildren()) --> 0
 +
</syntaxhighlight>
 +
 
 +
{{Sprite}}

Latest revision as of 14:33, 13 July 2023

Available since: Gideros 2011.6
Class: Sprite

Description

Returns the number of children of this sprite.

(number) = Sprite:getNumChildren()

Return values

Returns (number) the number of children of this sprite

Examples

local container1 = Sprite.new()
local container2 = Sprite.new()

local sprite1 = Sprite.new();
local sprite2 = Sprite.new();

container2:addChild(container1)
container1:addChild(sprite1)
container1:addChild(sprite2)

print(container1:getNumChildren()) --> 2
print(container2:getNumChildren()) --> 1
print(sprite1:getNumChildren()) --> 0
print(sprite2:getNumChildren()) --> 0