在Popscene之后获取黑屏
get black screen after popScene
我刚刚开始学习Cocos2DX,并使用基本的Helloworld项目。我在其中添加了第二秒和一个按钮以更改场景。但是,一旦执行了PopScene方法,屏幕就变成了黑色,并且没有弹出第一个场景。我不知道怎么了。这是我在helloworld.cpp中修改的代码:
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
CCDirector::sharedDirector()->pushScene(SecondScence::scene());
#endif
第二秒中的代码:
#include "SecondScence.h"
USING_NS_CC;
CCScene* SecondScence::scene(){
CCScene* scene=CCScene::create();
SecondScence* layer = SecondScence::create();
scene->addChild(layer);
return scene;
bool SecondScence::init(){
CCLabelTTF* label = CCLabelTTF::create("hfiejfeiojfoej", "Arial", 30);
label->setPosition(ccp(200,200));
this->addChild(label);
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png","CloseSelected.png",this,menu_selector(SecondScence::popScene));
pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width-20, 20));
CCMenu *pMenu = CCMenu::create(pCloseItem,NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu,1);
return true;
}
void SecondScence::popScene(CCObject* pSender){
CCDirector::sharedDirector()->popScene();
}
顺便说一句,我使用cocos2dx 2.2和xcode5,控制台打印消息:cocos2d:cocos2d:deallocing ccdireter 0x6906f0
验证popscene方法未运行两次,也许用户快速点击菜单项(或错误)。
将同时弹出当前和Helloworld场景,而导演没有场景可以显示。这也将解释董事交易。
您可以首先检查导演的runningScene
是否与this
相同(如:第二秒实例),然后致电POPSCENE。
我也有同样的问题,但是我解决了,我认为您可能已经将所有孩子从现场删除,检查您的Onexit或Destructor,以查看这两个功能中是否可用的任何版本/删除选项。
如果场景没有孩子,那将是黑色。
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- 在获取从文件到矢量的每一行之后,数字将被更改或销毁
- 有没有一种简单的方法可以在C++中获取特定索引之后向量中的所有项目?
- 在getline()之后获取字符串
- 从另一个线程调用shared_from_this但在初始化shared_ptr之后时获取bad_weak_ptr
- 获取提升程序选项以在函数范围之后保留
- 如果在获取互斥锁之后发生中断,会发生什么
- 获取 ISO 8601 时间戳 C++ 之前和之后的设置时间
- C 如何在文件中的特定字符串之后获取数字
- 在Popscene之后获取黑屏
- 在 Items.ItemAdd 事件之后获取邮件项目
- C ++拆分字符串并获取空格之后的部分
- 在Javascript服务器应用程序之后获取HTML
- 如何从 9 和 90 中提取 2.9 和 2.09,即获取数字等于最大编号的小数部分.二分位数之后的数字
- 在 RasDial 之后获取 IP 地址/接口号码
- 在 Scala 2.9.3 编译器的擦除阶段之后获取具体类型的符号
- 在特定项之后获取QString的一部分
- 在c++中获取内存之后的strlen
- 如何获取从sstream变量中提取的字符串之后的剩余字符串
- 如何在getline之后获取输入