本来按网上示例用RenderTexture截屏作为暂停菜单的背景,不过总是报错,有大神知道为什么吗?
关键代码:
…
bool TutorialSence::init()
{
if (!Layer::init())
{
return false;
}
...
auto visibleSize = Director::getInstance()->getVisibleSize();
auto origin = Director::getInstance()->getVisibleOrigin();
...
mRenderTexture = RenderTexture::create(visibleSize.width, visibleSize.height, Texture2D::PixelFormat::RGBA8888);
mRenderTexture->retain();
return true;
}
…
void TutorialSence::onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event) {
switch (keyCode) {
case EventKeyboard::KeyCode::KEY_BACKSPACE:
onMenuItemSelectedWithTag(TUTORIAL_TAG_MENU);
break;
}
}
void TutorialSence::onMenuItemSelected(Ref* pSender) {
onMenuItemSelectedWithTag(((Node *)pSender)->getTag());
}
void TutorialSence::onMenuItemSelectedWithTag(int tag) {
switch (tag) {
case TUTORIAL_TAG_MENU:
auto visibleSize = Director::getInstance()->getVisibleSize();
auto origin = Director::getInstance()->getVisibleOrigin();
mRenderTexture->beginWithClear(0.0f, 0.0f, 0.0f, 0.0f);
getParent()->visit();
mRenderTexture->end();
auto _schedule = getParent()->getScheduler();
_schedule->schedule(schedule_selector(TutorialSence::onCatchImage), this, 0.0f,0,0.f, false);
break;
}
}
void TutorialSence::onCatchImage(float dt) {
// Director::getInstance()->pushScene(GameMenuSence::createScene(mRenderTexture));
}
报错的函数栈如下:
TowerDefense.exe!cocos2d::GLProgram::use() 行 370 C++
TowerDefense.exe!cocos2d::QuadCommand::useMaterial() 行 122 C++
TowerDefense.exe!cocos2d::Renderer::drawBatchedQuads() 行 474 C++
TowerDefense.exe!cocos2d::Renderer::flush() 行 506 C++
TowerDefense.exe!cocos2d::Renderer::visitRenderQueue(const cocos2d::RenderQueue & queue) 行 314 C++
TowerDefense.exe!cocos2d::Renderer::visitRenderQueue(const cocos2d::RenderQueue & queue) 行 309 C++
TowerDefense.exe!cocos2d::Renderer::render() 行 350 C++
TowerDefense.exe!cocos2d::Director::drawScene() 行 312 C++
TowerDefense.exe!cocos2d::DisplayLinkDirector::mainLoop() 行 1101 C++
TowerDefense.exe!cocos2d::Application::run() 行 92 C++
TowerDefense.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) 行 17 C++
TowerDefense.exe!__tmainCRTStartup() 行 528 C
TowerDefense.exe!wWinMainCRTStartup() 行 377 C
kernel32.dll!761e336a() 未知
下面的框架可能不正确和/或缺失,没有为 kernel32.dll 加载符号]
ntdll.dll!76f99f72() 未知
ntdll.dll!76f99f45() 未知