#include "MainScene.h" #include "SimpleAudioEngine.h" USING_NS_CC; Scene* MainScene::createScene() { return MainScene::create(); } // Print useful error message instead of segfaulting when files are not there. static void problemLoading(const char* filename) { printf("Error while loading: %s\n", filename); printf("Depending on how you compiled you might have to add 'Resources/' in front of filenames in HelloWorldScene.cpp\n"); } // on "init" you need to initialize your instance bool MainScene::init() { ////////////////////////////// // 1. super init first if ( !Scene::init() ) { return false; } auto bg = cocos2d::LayerColor::create(Color4B(55,71,79,255)); this-> addChild(bg , 0); auto visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); //This is Error?? DrawNode *rects; Vec2 vert[4]; vert[0] = Vec2(origin.x , origin.y + visibleSize.height / 2); vert[1] = Vec2(origin.x , origin.y + visibleSize.height); vert[2] = Vec2(origin.x + visibleSize.width, origin.y + visibleSize.height); vert[3] = Vec2(origin.x + visibleSize.width, origin.y + visibleSize.height / 2 ); Color4B warna = Color4B(38,50,56,255); Color4F aa = Color4F(Color4B(warna)); rects -> drawPolygon(vert, 4, aa, 1, aa); this -> addChild(rects, 1); //////////////////////////////////////////////////////////////////////////////////// return true; } void MainScene::menuCloseCallback(Ref* pSender) { //Close the cocos2d-x game scene and quit the application Director::getInstance()->end(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) exit(0); #endif /*To navigate back to native iOS screen(if present) without quitting the application ,do not use Director::getInstance()->end() and exit(0) as given above,instead trigger a custom event created in RootViewController.mm as below*/ //EventCustom customEndEvent("game_scene_close_event"); //_eventDispatcher->dispatchEvent(&customEndEvent); }