Cocos2d is not limited to iOS development. Cocos2d-X is a C++ port of Cocos2d-iPhone. Using Cocos2d-X we can develop games for many platforms including Mac, PC, Linux, Android, and more. In this recipe, we will install Cocos2d-X XCode templates, create a simple Cocos2d-X application, and introduce the Cocos2d-X testbed.
Execute the following code:
#include "HelloWorldScene.h" #include "SimpleAudioEngine.h" using namespace cocos2d; using namespace CocosDenshion; CCScene* HelloWorld::scene() { //'scene' is an autorelease object CCScene *scene = CCScene::node(); //'layer' is an autorelease object HelloWorld *layer = HelloWorld::node(); //Add layer as a child to scene scene->addChild(layer); return scene; } // on "init" you need to initialize your instance bool HelloWorld::init() { //Super initialization if ( !CCLayer::init() ) { return...