Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
setVisible() doesn't set child objects — Gideros Forum

setVisible() doesn't set child objects

BlueByLiquidBlueByLiquid Member
edited March 2013 in General questions
I call setVisible(false) on a parent sprite and then call "isVisible()" on the objects children but the children returns true. The child objects disappear just as expected but any calls to their isVisible() method returns true. any ideas?


  • I think this is the what we [ atleast me :D ] are expecting when parent is invisible make all its children also invisible and when again we make it visible all the children must have visibility which was set previously means if 5 are visible and 3 are invisible then they must have to come in same way.

    all you need to do is find a way to get visibility of parent sprite

  • Well it seems like there should be a "visibleOnScreen()" call then as checking the parent in many situations checking the parent multiple levels would create a huge amount of coupling that would be thrown off if moved to another sprite.
  • hgvyas123hgvyas123 Guru
    Accepted Answer
    ohh yes i had made one quick function try it i think it will work i had tested it upto 3 parent
    function Sprite:isVisibleOnScreen()
    	local mySprite = self
    	if mySprite:isVisible() == false then
    		return false
    		while mySprite ~= nil do
    			local dummySprite = mySprite
    			mySprite = dummySprite:getParent()
    			if mySprite ~= nil then
    				if mySprite:isVisible() == false then
    					return false
    	return true

  • @hgvyas123,

    Thanks! i will check it out. Seems so handy it should be in the SDK proper
  • Have you checked out @ar2rsawseen 's GiderosCodingEasy library. It includes many enhancements that people have thought should really be part of the base SDK. One of them is a method, Sprite:isVisibleDeeply(), which does what you want, I think.

    Best regards

    Likes: hgvyas123

    +1 -1 (+1 / -0 )Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    @bowerandy funny that you mention it, because lots of stuff coming from you (I think even including isVisibleDeeply :D )
Sign In or Register to comment.