小白一枚,按照教程在CocoStudio上制作了一个游戏的初始场景,然后在VS2015的项目上修改了代码,想要替换HelloWorld的画面,也就是在vs上导入.csb文件,修改代码后,程序可运行,但是是黑屏的,画面并不能正常显示。找了很多办法,始终没有解决,请大神指点一下,告诉一下解决方法吧,谢谢!
这是代码
h文件
#pragma once
#ifndef __Login_SCENE_H__
#define __Login_SCENE_H__
#include "cocos2d.h"
class Login : public cocos2d::Layer
{
public:
static cocos2d::Scene* createScene();
virtual bool init();
// a selector callback
void menuCloseCallback(cocos2d::Ref* pSender);
};
CREATE_FUNC(Login);
#endif // __Login_SCENE_H__
cpp文件
#include "LoginScene.h"
#include "SimpleAudioEngine.h"
#include "cocostudio/CocoStudio.h"
#include "ui/CocosGUI.h"
USING_NS_CC;
using namespace cocostudio::timeline;
Scene* Login::createScene()
{
// 'scene' is an autorelease object
auto scene = Scene::create();
// 'layer' is an autorelease object
auto layer = Login::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
// on "init" you need to initialize your instance
bool Login::init()
{
//////////////////////////////
// 1. super init first
if (!Layer::init())
{
return false;
}
auto pNode = CSLoader::createNode("MainScene.csb");
auto rootNode = CSLoader::createNode("LoginScene.csb");
this->addChild(pNode);
this->addChild(rootNode);
return true;
}
void Login::menuCloseCallback(Ref* pSender)
{
//Close the cocos2d-x game scene and quit the application
Director::getInstance()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
/*To navigate back to native iOS screen(if present) without quitting the application ,do not use Director::getInstance()->end() and exit(0) as given above,instead trigger a custom event created in RootViewController.mm as below*/
//EventCustom customEndEvent("game_scene_close_event");
//_eventDispatcher->dispatchEvent(&customEndEvent);
}