#include "cocos2d.h" using namespace cocos2d; int main() { // create the director auto director = Director::getInstance(); // create a scene auto scene = Scene::create(); // run the scene director->runWithScene(scene); // start executing the game loop director->startAnimation(); return 0; }
#include "cocos2d.h" using namespace cocos2d; class MainMenu : public Scene { public: CREATE_FUNC(MainMenu); virtual bool init() { if(!Scene::init()) { return false; } // add menu items to the scene // ... return true; } }; int main() { // create the director auto director = Director::getInstance(); // create and run the main menu scene director->runWithScene(MainMenu::create()); // start executing the game loop director->startAnimation(); return 0; }This example creates a custom scene called MainMenu and runs it with the director using the runWithScene method. The MainMenu scene is then created and any necessary content is added to it before the game loop is started. Package library: Cocos2d-x.