Sprite:isOnStage

From GiderosMobile
Revision as of 12:16, 18 October 2025 by MoKaLux (talk | contribs) (Created page with "__NOTOC__ '''Available since:''' Gideros 2022.1.3<br/> '''Class:''' Sprite<br/> === Description === Returns whether the Sprite is on stage. <syntaxhighlight lang="lua"> (...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Available since: Gideros 2022.1.3
Class: Sprite

Description

Returns whether the Sprite is on stage.

(bool) = Sprite:isOnStage()

Return values

Returns (bool) a value of true if sprite is on stage, false otherwise

Example

local sprite = Sprite.new()
local pix = Pixel.new(0xff0000, 1, 32, 32)
pix2 = pix:clone()
pix3 = pix:clone()
pix2:setColor(0x00ff00)
pix3:setColor(0x0000ff)
-- position
pix:setPosition(1*32, 1*32)
pix2:setPosition(1.5*32, 1.5*32)
pix3:setPosition(2*32, 2*32)
-- order
sprite:addChildrenAt ( { pix, pix2, pix3 } )
stage:addChild(sprite)

pix:removeFromParent()
print(pix:isOnStage(), pix2:isOnStage(), pix3:isOnStage()) -- false, true, true