[Cocos2d-x 2.0.2] - TransitionPage effect shows error "GetShaderProgram()" when using the scene inherited from CCLayercolor

[Cocos2d-x 2.0.2] - TransitionPage effect shows error "GetShaderProgram()" when using the scene inherited from CCLayercolor
0.0 0


I ran into a problem when implementing the transition page effect. First, I inherite the “HelloWorldScene” from CCLayerColor. The code is follow:

class HelloWorldScene : public cocos2d::CCLayerColor
    virtual bool init();  
    static cocos2d::CCScene* scene();

    virtual void menuCloseCallback(CCObject* pSender);
    virtual void NewGameCallback(CCObject *pSender);

bool HelloWorldScene::init()
    bool bRet = false;
        // super init first

    CC_BREAK_IF(! CCLayerColor::initWithColor( ccc4(255,255,255,255) ));
        CC_BREAK_IF(! CCLayer::init());

        // add your codes below...

Next, the transition page effect. To make a demo, I just want to transtion to the same scene. So, the code is follow.

void HelloWorldScene::NewGameCallback(CCObject *pSender)
    CCScene *s = new TransitionHelloWorldPage();  // empty class
    CCLayer* pLayer = new HelloWorldScene();

    CCScene* pScene = FlipXLeftOver::transitionWithDuration(3,s);
    if (pScene) {

What’s wrong is that when the “NewGameCallback” is called, the transition page effect is not totally completed. Instead, it halts in the half way, and the VS pops the debug info.

Thus, I try to add a new constructor in “HelloWorldScene”.

HelloWorldScene::HelloWorldScene() {
    CCLayerColor::initWithColor( ccc4(255,255,255,255) );

Now, it works well for me, but new problem occurs. That label menu I use in this scene shows overlaps. But here, I guess the all the sprite and label loads twice? (One in constructor, one in init()).

Besides, if I delete init() in constructor, it works well. The label will not overlaps and the transition can complete. But one thing is that after the transition, the screen turns to white.
My purpose is to transition to the same page. So, after transition, the sprite and label should show again.

Someone know how to fix the problem without implementingconstructor? or how to set the background color without inheriting from CCLayerColor?

I upload my code, hoping someone could take a look.

CCOS2.0.2 InitWithColor.jpg (35.0 KB)

CCOS2.0.2 MenuItemLabel Overlaps.jpg (13.8 KB)

HelloWorldScene.cpp.zip (3.2 KB)


BTW, I just upgrade from cocos2d-x 1.0.3 to 2.0.2. I never ran into any problem with the same code under 1.0.3, but why the app crashes under 2.0.2?
It’s terrible.


Hello, any update? :frowning:


Well,I have entered the same problem and fix it.
My advice is trying to apply ‘initWithColor’ in another way differently with that you used to.
(PS:Or just copy code in TestApp if suitable)
Now my solution is:

NowConnectingLayer *pRet = new NowConnectingLayer();
if (pRet && pRet~~>init && pRet~~>initDialog(label,fontName,fontSize,wordCount,width,height))
return pRet;
delete pRet;
pRet = NULL;
return NULL;

bool NowConnectingLayer::init(short width, short height)
return CCLayerColor::initWithColor(ccc4(0, 0, 0, 100),width,height);


I use cocos2d-x 2.1.1.