1 回答

TA貢獻(xiàn)1784條經(jīng)驗 獲得超8個贊
新建 win32 程序(可以參照這里),寫好自己的代碼,假設(shè)咱們新建一個類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);// 添加啟動的回調(diào)函數(shù)
void onEnter();
Practise *layer;
cocos2d::CCSprite *pSprite;
Practise():layer(NULL), pSprite(NULL){};
~Practise();
};
#endif // __PRACTISE_COCOS2D_H__
至于實現(xiàn)就不貼了有點(diǎn)亂 呵呵
然后修改 AppDelegate.cpp 中applicationDidFinishLaunching() 方法,修改如下:
至于實現(xiàn)不是特別重要,主要是 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 關(guān)注
- 807 瀏覽
添加回答
舉報