Is there a way of checking if a Sprite is visible, taking all of its parents into account? Without being able check if the final Sprite has been added to "stage", I can't seem to figure it out.
I want to use this in my Button class to avoid it triggering if it has been added to a Sprite with setVisible(false), or if it hasn't been added to the stage at all.
Comments
I think that solition only checks for isVisible, and would return true even if the Sprite is not added to the stage (and thus not actually visible)?
stage:contains(mysprite)
http://docs.giderosmobile.com/reference/gideros/Sprite/contains
Fragmenter - animated loop machine and IKONOMIKON - the memory game
local visible=false
if not stage:contains(sprite) then return visible end
as this is maybe native and so perhaps faster then checking one by one all levels of the hierarchy for containment.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: talis, keszegh
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
at the end it depends also on if one tends to set sprites to not visible. if this is less likely (like in my case), then it still may be more efficient to start with a stage:contains and then proceed with the visibility checks.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
I don't know if it will work for you but you may want to try:
Likes: SinisterSoft, totebo