So I found that Cocosbuilder assumes a default CCLayerColor opacity of 255, but Cocos2dx defaults to 0. This causes CCLayerColors created in Cocosbuilder to not display if they have a opacity of 255. I fixed this by changing the following in CCLayerColor::init():
CCSize s = CCDirector::sharedDirector()->getWinSize();
return initWithColor(ccc4(0,0,0,0), s.width, s.height);
To:
CCSize s = CCDirector::sharedDirector()->getWinSize();
return initWithColor(ccc4(0,0,0,255), s.width, s.height);
This is similar to what CCLayerGradient already does.
否则不会显示
本文解决了Cocos2d-x中CCLayerColor默认透明度设置为0导致的问题。通过将初始化时的透明度从0更改为255,使得在Cocosbuilder创建的CCLayerColor能够正常显示。
1519

被折叠的 条评论
为什么被折叠?



