LAYER_NODE_FUNC自动创建一个layer,SCENE_NODE_FUNC,自动创建一个scene 1. 看下源码: #define LAYER_NODE_FUNC(layer) \ CC_DEPRECATED_ATTRIBUTE static layer* node() \ { \ layer *pRet = new layer(); \// new 一个layer if (pRet && pRet
在AppDelegate中使用createScene方法,在该方法中使用Scene::create创建一个新场景,然后再用HelloWorld类中的create方法创建helloWorld层(注意,HelloWrold继承的是Layer,所以实际上它是一个层)。CREATE_FUNC是一个预定义的宏,用来创建对象,函数定义如下: 1#defineCREATE_FUNC(__TYPE__) \2static__TYPE__*create() \...
this->runAction(Sequence::create( DelayTime::create(3), CallFunc::create(CC_CALLBACK_0(GameOverLayer::gameOverDone, this)), NULL)); return true; } else { return false; } } void GameOverLayer::gameOverDone() { Director::getInstance()->replaceScene(HelloWorld::createScene()); } GameO...
virtualboolinit();//MyFirstScene层的初始化 CREATE_FUNC(MyFirstScene);//创建MyFirstScene的Create方法 voidEnterSecondScene(Ref *pSender);//创建一个菜单回调函数,这里实现了场景的跳转 }; MyFirstScene.cpp: [cpp]view plaincopy #include "MyFirstScene.h" #include"MySecondScene.h" //MyFirstScene场景...
#define CREATE_FUNC(__TYPE__) static __TYPE__* create() { __TYPE__ *pRet = new __TYPE__(); if (pRet && pRet->init()) { pRet->autorelease(); return pRet; } else { delete pRet; pRet = NULL; return NULL; } }作为函数体内变量...
CREATE_FUNC(ActionFollowTestLayer); }; class ActionScene :public Scene{ public: virtual bool init(); CREATE_FUNC(ActionScene); virtual void restartCallback(Ref *sender); virtual void nextCallback(Ref *sender); virtual void priorCallback(Ref *sender); ...
LAYER_CREATE_FUNC 1. )初始化,那么它就会进入init,这个方法你可以初始化你的layer和一些sprites,如果你想自己重写layer的onEnter/onExit的话,那么务必请注意,你要在你的onEnter/onExit里面写上基类的Base::onEnter、Base::onExit,否则的话,程序会收不到消息的。
Cocos2dx教程18-CallFunc::create新的使用方法 1 CallFunc::create(CC_CALLBACK_0(__Class_Name__::__Fun_Name__, this));等效于CallFunc::create(this, callfunc_selector(__Class_Name__::__Fun_Name__));注:__Class_Name__ 回调方法的所属类名 __Fun_Name__ 回调方法的方法名CC_CALLBACK...
();voidloadScore(int type);voidupdateScore(int addScore);voidresetScore();voidsetScore(int score);intgetScore();voidsetBestScore(int bestScore);intgetBestScore();private:CREATE_FUNC(GameTool);voidupdateBestScore();Label*scoreLabel;Label*bestLabel;int _score;int _bestScore;staticGameTool*_...
cocos2dx Visual studio 方法/步骤 1 创建类class BoundContent : public Layer{public:BoundContent();~BoundContent();static Scene* createScene();virtual bool init();CREATE_FUNC(BoundContent);private:};2 实现类BoundContent::BoundContent(){}BoundContent::~BoundContent(){}Scene* BoundContent::create...