Showing posts with label Menu from basic to advanced. Show all posts
Showing posts with label Menu from basic to advanced. Show all posts

Saturday, January 17, 2015

[Tutorial] Cocos2d-x: Menu, from basic to advanced

Now, let's start. Create a new Project named Menu as follow, using cmd 

>cocos new menu -p com.vn.menu -l cpp -d f:android/project

After new Project is created, you should run this command

>cocos compile -s f:android/project/menu -p win32


This is the first compile, purpose is linking to libraries in Engine. The first time to compile is so long. The next compile will be much faster because we only change some in Class and Resource.

Step 1) Copy code and run
You open Classes folder as following path E:/android/project/menu/Classes with 4 familiar files. But here we won't use class HelloWorldScene but replace by 2 other classes: MenuLayer and SceneManger.

You delete 2 files HelloWorldScene.cpp and HelloWorldScene.h, download source files Here and copy 4 files in zip file into Classes folder. And then you open file AppDelegate.cpp, in the second line #include you replace HelloWorldScene.h by  SceneManager.h, 
Delete the line auto scene = HelloWorld::createScene();
and director->runWithScene(scene); đi nhé. 
Add the following command SceneManager::goMenu(); into under the two above lines

Done, before compiling and running you open file Menu.vcxproj as following path E:/android/project/menu/proj.win32/ and find "HelloWorldScene.cpp" You will see 4 files here when compiled (HelloWorldScene.h, HelloWorldScene.cpp, AppDelegate.cpp, AppDelegate.h )

Because you deleted files HelloWorldScene.h and HelloWorldScene.cpp so here you delete too. And add 4 files SceneManager.h, SceneManager.cpp, MenuLayer.h , MenuLayer.cpp into Menu.vcxproj for compiler to process these 4 files when we compile again to run, as follow:

Posted By Live Blog11:21 PM

Choose an Android item