Created
February 12, 2014 07:46
-
-
Save Kogarasi/8951507 to your computer and use it in GitHub Desktop.
Scene Class for Cocos2dx v3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "cocos2d.h" | |
template <typename T> | |
class BaseScene : public cocos2d::Layer { | |
public: | |
static cocos2d::Scene* createScene(){ | |
auto scene = cocos2d::Scene::create(); | |
auto layer = T::create(); | |
scene->addChild( layer ); | |
return scene; | |
} | |
static T* create(){ | |
auto scene = new T(); | |
if( scene && scene->init() ){ | |
scene->autorelease(); | |
return scene; | |
} else { | |
delete scene; | |
return nullptr; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment