Here is the complete code of the HelloWorldScene.cpp
implementation file, where we have created and positioned our background, our animated player, and our moving bomb:
#include "HelloWorldScene.h" #include "PauseScene.h" USING_NS_CC; Scene* HelloWorld::createScene() { // 'scene' is an autorelease object auto scene = Scene::create(); // 'layer' is an autorelease object auto layer = HelloWorld::create(); // add layer as a child to scene scene->addChild(layer); // return the scene return scene; }
Next in the init
function, we are going to instantiate and initialize our sprites:
bool HelloWorld::init() { if ( !Layer::init() ) { return false; } _director = Director::getInstance(); _visibleSize = _director->getVisibleSize(); auto origin = _director->getVisibleOrigin(); auto closeItem = MenuItemImage::create("pause.png", "pause_pressed.png", CC_CALLBACK_1(HelloWorld::pauseCallback, this)); closeItem->setPosition(Vec2...