Fade in/out effect

Fade in/out effect
0.0 0


I want to show/hide a CCLayer with fade in/out effects when i try with the method below nothing happens. (cocos2d-x version 2.2.2)

void MainScene::setMenuVisibility(bool value)
        CCFadeIn* fadeIn = CCFadeIn::create(5);

        CCFadeOut* fadeOut = CCFadeOut::create(5);



Before FadeIn/Out you have to setOpacity(0) or setOpacity(255). Don’t setVisible(false).


Thanks for your help but i can’t find the setOpacity method


Layer class seem don’t have setOpacity method, but Sprite has: http://www.cocos2d-x.org/reference/native-cpp/V2.2.2/d8/de9/group__sprite__nodes.html#ga7f9374d8fd4db565312b125795a877ff
Maybe it help.


try CCLayerColor


You cannot use CCFadeIn/CCFadeOut on CCLayer , because we cannot manipulate the opacity of CCLayer (thats y it does not have any setOpacity() method). But if you want to use those actions you can use CCLayerColor instead.