How to make a invisible sprite or layer? please help me.

I knew a method for making invisible sprite in cocos2d-iphone.

It is spritename.visible = NO or Yes.

However, I couldn’t find it in cocos2d-x reference.

please help me, How to make a invisible sprite. and recovery visible option.

Invoke this function:

spritename->setIsVisible(true);

I invoke to you God’s bless. Thank you.

and I found a little good method also

it is just for CCSprite and Layer, not CCProgress

if ( 100 < m_pos.y && m_pos.y < k )
{
// visible sprite and layer
m_bar~~>setOpacity ;
m_layer~~>setOpacity ( 255 );
m_layer~~>setColor );
}
else
{
// disappear sprite and layer.
m_bar~~>setOpacity ( 0 );
m_layer->setOpacity ( 0 );
}

Progress class doesn’t have setOpacity ( ). That’s so bad news.

1 Like

On the performance view, use setIsVisible(false) to hide the node is better than setOpacity(0).
CCNode::visit() will return immediately if m_bIsVisible false, while it will draw again even if the opacity 0.

visit ( )… oops. I want to test that…

but I don’t know a visit ( ). I need a more reference.

Thank you really!.