1 回答

TA貢獻1784條經驗 獲得超8個贊
新建 win32 程序(可以參照這里),寫好自己的代碼,假設咱們新建一個類PractiseCocos2d,代碼如下:
[cpp] view plain copy print?
#ifndef __PRACTISE_COCOS2D_H__
#define __PRACTISE_COCOS2D_H__
#include "cocos2d.h"
// 播放聲音
#include "SimpleAudioEngine.h"
class Practise : public cocos2d::CCLayerColor {
public:
virtual bool init();
static cocos2d::CCScene* scene();
void callBack(CCObject* pSender);
void menuPushSceneCallBack(CCObject* pSender);
void menuReplaceSceneCallBack(CCObject* pSender);
void menuPopSceneCallBack(CCObject* pSender);
CREATE_FUNC(Practise);// 添加啟動的回調函數
void onEnter();
Practise *layer;
cocos2d::CCSprite *pSprite;
Practise():layer(NULL), pSprite(NULL){};
~Practise();
};
#endif // __PRACTISE_COCOS2D_H__
至于實現就不貼了有點亂 呵呵
然后修改 AppDelegate.cpp 中applicationDidFinishLaunching() 方法,修改如下:
至于實現不是特別重要,主要是 scene 方法
[cpp] view plain copy print?
CCScene* Practise::scene()
{
CCScene* scene = CCScene::create();
Practise* layer = Practise::create();
// layer->autorelease();
scene->addChild(layer);
return scene;
}
- 1 回答
- 0 關注
- 800 瀏覽
添加回答
舉報