步骤:
1.新建一个Cocos2d-x项目
2.在include中添加SecondScene.h文件,添加代码
3.在source中添加SecondScene.cpp文件,添加代码
4.在HelloWorldScene.cpp中的增加和修改代码
1.新建一个Cocos2d-x项目并运行,保证可以运行起来
2.在include中添加SecondScene.h文件,添加代码
#include "cocos2d.h"
using namespace cocos2d;
class SecondScene : public cocos2d::CCScene
{
public:
virtual bool init();
CREATE_FUNC(SecondScene);
static cocos2d::CCScene* scene();
public:
CCLayer *m_layer;
};
3.在source中添加SecondScene.cpp文件,添加代码
#include "SecondScene.h"
using namespace cocos2d;
bool SecondScene::init()
{
bool bRet = false;
do
{
//实例化精灵
CCSprite *m_sprite = CCSprite::create("CloseNormal.png");
CC_BREAK_IF(!m_sprite);
//设置精灵位置
m_sprite->setPosition(ccp(100, 100));
/