CCScene* EggScrambleModeLayer::scene(int levelNumber) { CCScene * scene = NULL; do { // 'scene' is an autorelease object scene = CCScene::create(); CC_BREAK_IF(! scene); // 'layer' is an autorelease object GameLayer *layer = EggScrambleModeLayer::create(levelNumber); CC_BREAK_IF(! layer); layer->setName("GameLayer"); // add layer as a child to scene scene->addChild(layer); } while (0); // return the scene return scene; }
CCScene* TutorialScene::scene(bool firstTime) { // 'scene' is an autorelease object CCScene* scene = CCScene::create(); // 'layer' is an autorelease object TutorialScene* layer = TutorialScene::create(firstTime); std::cout << "FT: " << firstTime << "\n"; if (firstTime) { User::getInstance()->setPlayed(); } // add layer as a child to scene scene->addChild(layer); // return the scene return scene; }
CCScene * MainLayer::scene() { CCScene *scene = CCScene::create(); if (scene && scene->init()) { if (scene) { /*-- 背景 --*/ CCLayer *bgLayer = BgLayer::create(); scene->addChild(bgLayer); MainLayer *layer = MainLayer::create(); scene->addChild(layer); } return scene; } else { CC_SAFE_DELETE(scene); return NULL; } }
//section被选中之后 void LevelManager::sectionSelected(int sectionId,CCPoint sectionPos) { m_iLastSectionId = sectionId; CCUserDefault::sharedUserDefault()->setIntegerForKey(CCString::createWithFormat("Last_season%d_seation", m_iLastSeasonId)->getCString(), m_iLastSectionId); CCUserDefault::sharedUserDefault()->flush(); //// 隐藏 //SectionSelectorLayer::getCurrentInstance()->setVisible(false); //MaskLayer::getCurrentInsstance()->setVisible(false); // SectionSelectorLayer::getCurrentInstance()->removeFromParentAndCleanup(true); // MaskLayer::getCurrentInsstance()->removeFromParentAndCleanup(true); CCDirector::sharedDirector()->getRunningScene()->removeAllChildren(); LoadingLayer* layer = new LoadingLayer(Intent_Section2GameIn,m_iLastSeasonId); CCScene* pScene = CCDirector::sharedDirector()->getRunningScene(); pScene->addChild(layer); layer->release(); }
CCScene* RS_Main::scene(int nGameLevel) { CCScene * scene = NULL; do { // 'scene' is an autorelease object scene = CCScene::create(); CC_BREAK_IF(! scene); // 'layer' is an autorelease object RS_Main *layer = RS_Main::create(nGameLevel); CC_BREAK_IF(! layer); // add layer as a child to scene scene->addChild(layer); } while (0); // return the scene return scene; }
CCScene*HelloWorld::scene() { // 'scene' is an autorelease object. CCScene *scene =CCScene::create(); // 'layer' is an autorelease object. HelloWorld *layer =HelloWorld::create(); // add layer as a child to scene scene->addChild(layer,1); GameHUD * gameHUD = GameHUD::sharedHUD(); scene->addChild(gameHUD,2); DataModel *m = DataModel::getModel(); m->setGameLayer(layer); m->setGameHUDLayer(gameHUD); // return the scene return scene; }
CCScene* baseSwitheScene(int layerId) { CCScene * pScene = CCScene::create(); CCLayer *payler = NULL; switch (layerId) { case 1: payler = new ViewMainLayer(); break; case 2: payler = new ViewListLayer(); break; default: break; } payler->autorelease(); pScene->addChild(payler); return pScene; // CCDirector::sharedDirector()->runWithScene(pScene); // return; }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); // turn on display FPS pDirector->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object CCScene *pScene = new PuzzleScene; pScene->init(); // run pDirector->runWithScene(pScene); return true; }
CCScene* MovieMenu::scene() { CCScene * scene = NULL; do { // 'scene' is an autorelease object scene = CCScene::create(); CC_BREAK_IF(! scene); // 'layer' is an autorelease object MovieMenu *layer = MovieMenu::create(); CC_BREAK_IF(! layer); // add layer as a child to scene scene->addChild(layer); } while (0); // return the scene return scene; }
void StartMenu::menuCallback(CCObject* pSender) { int tag = dynamic_cast<CCNode*>(pSender)->getTag(); if(tag == 0){ CCScene *scene = CCScene::create(); scene->addChild(GameLayer::create()); CCDirector::sharedDirector()->replaceScene(CCTransitionMoveInR::transitionWithDuration(1.2,scene)); } else if (tag == 1) { CCScene *scene = Options::scene(); CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(1.2, scene)); } else if(tag == 2) { CCDirector::sharedDirector()->end(); //CCScene *scene = About::scene(); //CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(1.2, scene)); } }
cocos2d::CCScene* SwarmGame::scene() { CCScene * scene = NULL; do /* enclose the body in a 'break-able' closure */ { // 'scene' is an autorelease object scene = CCScene::node(); CC_BREAK_IF(! scene); // 'layer' is an autorelease object SwarmGame* layer = SwarmGame::node(); CC_BREAK_IF(! layer); // add layer as a child to scene scene->addChild(layer); } while (0); // return the scene return scene; }
void HSGameShopLayer::setVisible(bool visible) { #define HS_Shop_Tag 0x75699 CCLayer::setVisible(visible); if(visible) { Shop_FlyIn(*m_p_shop_frame,m_shop_frame_Position); CCScene* pScene = CCDirector::sharedDirector()->getRunningScene(); if (!pScene->getChildByTag(HS_Shop_Tag)) { pScene->addChild(this,HS_Shop_Tag,HS_Shop_Tag); } } else { CCScene* pScene = CCDirector::sharedDirector()->getRunningScene(); if (pScene->getChildByTag(HS_Shop_Tag)) { pScene->removeChildByTag(HS_Shop_Tag); } } }
void RCLoadingScene::playNextScene() { // CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Imagesetfile/mainScene1.plist"); // CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Imagesetfile/mainScene2.plist"); // CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Imagesetfile/mainScene3.plist"); // CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Imagesetfile/mainScene4.plist"); // RCSceneManager::sharedSceneManager()->switchToOnePieceGameScene(); switch (m_loadingSceneTag) { case kLoadingGameScene: { CCScene* scene = CCScene::create(); RCGameScene* node = RCGameScene::create(); scene->addChild(node); CCDirector::sharedDirector()->replaceScene(scene); node->addTileMap(m_tileMapName.c_str()); } break; default: break; } }
void Java_org_cocos2dx_hellocpp_HelloCpp_keyReleased(JNIEnv* env, jobject thiz, jint player, jint keyCode) { CCDirector *pDirector = CCDirector::sharedDirector(); if(pDirector != NULL) { CCScene *scene = pDirector->getRunningScene(); if(scene != NULL) { Game* layer = (Game*)scene->getChildByTag(1001); if(layer != NULL) { layer->keyControllerReleased(player, keyCode); } else { CCDirector *pDirector = CCDirector::sharedDirector(); CCScene *scene_ = Game::scene(); pDirector->replaceScene(scene_); } } } }
//------------------------------------------------------------------------------ bool initScenes(CCScene * pScene, CCScene** inScene, CCScene ** outScene) { CCAssert(pScene != NULL, "Argument scene must be non-nil"); CCScene * pOutScene = (CCScene*)CCDirector::sharedDirector()->getNotificationNode(); if (pOutScene == NULL) { pOutScene = CCScene::create(); pOutScene->init(); pOutScene->onEnter(); } pOutScene->retain(); pScene->retain(); CCAssert(pScene != pOutScene, "Incoming scene must be different from the outgoing scene"); *inScene = pScene; *outScene = pOutScene; return true; }
void DirectBurn::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) { if (UiManager::Singleton().IsInUi()) return; CCSetIterator iter = pTouches->begin(); for (; iter != pTouches->end(); iter++) { CCTouch* pTouch = (CCTouch*)(*iter); CCPoint touchPos = pTouch->getLocation(); m_fireBall = new FireBall(); m_fireBall->setPosition(touchPos); m_fireBall->SetCanDirectBurn(true); CCScene* pScene = CCDirector::sharedDirector()->getRunningScene(); pScene->addChild(m_fireBall); m_pStreak = CCMotionStreak::create(1.0f, 3.0f, 10.0f, ccWHITE, "streak.png"); pScene->addChild(m_pStreak); } }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); Settings::applySettings(); CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize(); CCSize designSize = CCSizeMake(480, 320); if (screenSize.height > 320) { CCSize resourceSize = CCSizeMake(960, 640); std::vector<std::string> searchPaths; searchPaths.push_back("hd"); // pFileUtils->setSearchPaths(searchPaths); pDirector->setContentScaleFactor(resourceSize.height/designSize.height); } CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder); // turn on display FPS pDirector->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); CCScene * pScene = CCScene::create(); CCLayer * pLayer = new TestController(); pLayer->autorelease(); pScene->addChild(pLayer); pDirector->runWithScene(pScene); return true; }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector* director = CCDirector::sharedDirector(); director->setOpenGLView(CCEGLView::sharedOpenGLView()); // turn on display FPS director->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this director->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object CCScene * scene = CCScene::create(); GameScreen * gameScreen = GameScreen::create(); scene->addChild(gameScreen); // run director->runWithScene(scene); return true; }
CCScene* HelloWorld::scene() { // 'scene' is an autorelease object CCScene *scene = CCScene::create(); //const char *levelPath = CCFileUtils::sharedFileUtils()->fullPathForFilename("level0.xml").c_str(); std::string levelPath = CCFileUtils::sharedFileUtils()->getWritablePath() + kLevelName; LevelFileHelper *lh ; if (CCFileUtils::sharedFileUtils()->isFileExist(levelPath)) { lh = new LevelFileHelper(levelPath.c_str()); }else{ lh = new LevelFileHelper( CCFileUtils::sharedFileUtils()->fullPathForFilename(kLevelName).c_str()); } // add layer as a child to scene CCLayer* layer = new HelloWorld(lh); scene->addChild(layer); layer->release(); return scene; }
void GameLayer::fanHuiButt(cocos2d::extension::UIButton *pSender, TouchEventType type) { if (type == TOUCH_EVENT_BEGAN) { PLAY_EFFECT(TAP_EFFECT); }else if (type == TOUCH_EVENT_MOVED) { CCLog("(moving moving 移动)"); }else if (type == TOUCH_EVENT_ENDED) { CCLog(" begin = end = 0 总长:%ld", _standardAnswer.length()); begin = end = 0; CCScene *scene = CCScene::create(); //添加场景 GamePasses *gamePass = GamePasses::create(); scene->addChild(gamePass); CCTransitionScene *transition = GlobalUserDefault::instance()->randomTransitionScene(scene); CCDirector::sharedDirector()->replaceScene(transition); } }
void GameLayer::getGoldButt(cocos2d::extension::UIButton *pSender, TouchEventType type) { if (type == TOUCH_EVENT_BEGAN) { PLAY_EFFECT(TAP_EFFECT); }else if (type == TOUCH_EVENT_MOVED) { CCLog("(moving moving 移动)"); }else if (type == TOUCH_EVENT_ENDED) { CCLog("(end ++ --),%d",end + 1); end++; CCScene *scene = CCScene::create(); //添加场景 CGShop *gameLayer = CGShop::create(); //章节 scene->addChild(gameLayer); CCTransitionScene *transition = CCTransitionProgressInOut::create(0.2, scene); // CCTransitionScene *transition = GlobalUserDefault::instance()->randomTransitionScene(scene); CCDirector::sharedDirector()->replaceScene(transition); } }
// 返回场景类的指针 CCScene* OptionLayer::scene(){ CCScene* sc = NULL; do { sc = CCScene::create(); CC_BREAK_IF( !sc ); OptionLayer* layer = OptionLayer::create(); CC_BREAK_IF( !layer ); sc->addChild( layer ); } while (0); return sc; }
CCScene* HelloWorld::scene() { CCLOG("HelloWorld::scene"); CCScene * scene = NULL; do { // 'scene' is an autorelease object scene = CCScene::create(); CC_BREAK_IF(! scene); // 'layer' is an autorelease object HelloWorld *layer = HelloWorld::create(); CC_BREAK_IF(! layer); // add layer as a child to scene scene->addChild(layer); } while (0); // return the scene return scene; }
CCScene* GameScene::scene(const char* key, int idx, string name, int money) { // 'scene' is an autorelease object CCScene *scene = CCScene::create(); // 'layer' is an autorelease object GameScene *layer = GameScene::create(); memcpy(layer->key, key, 8); layer->myIdx = idx; layer->player_info[0].setPlayerName(name); layer->player_info[0].setMoney(money); layer->initPlayerUI(); layer->updatePlayerInfo(); // add layer as a child to scene scene->addChild(layer); // return the scene return scene; }
CCScene* SP_Main::scene(SELECT_GAME game) { CCScene * scene = NULL; do { // 'scene' is an autorelease object scene = CCScene::create(); CC_BREAK_IF(! scene); // 'layer' is an autorelease object SP_Main *layer = SP_Main::create(game); CC_BREAK_IF(! layer); // add layer as a child to scene scene->addChild(layer); } while (0); // return the scene return scene; }
CCScene* MainScene::scene() { CCScene * scene = NULL; do { // Create our Scene scene = CCScene::create(); CC_BREAK_IF(! scene); // Create and Add the MainScene Layer MainScene *layer = MainScene::create(); CC_BREAK_IF(! layer); scene->addChild(layer); // Create and Add the GameScene Layer GameScene *layer1 = GameScene::create(); CC_BREAK_IF(! layer1); scene->addChild(layer1); } while (0); return scene; }
//////////////////////////////////////////////////////// // // TouchesMainScene // //////////////////////////////////////////////////////// void TouchesMainScene::showCurrentTest() { CCLayer* pLayer = NULL; switch (m_nCurCase) { case 0: pLayer = new TouchesPerformTest1(true, TEST_COUNT, m_nCurCase); break; case 1: pLayer = new TouchesPerformTest2(true, TEST_COUNT, m_nCurCase); break; } s_nTouchCurCase = m_nCurCase; if (pLayer) { CCScene* pScene = CCScene::node(); pScene->addChild(pLayer); pLayer->release(); CCDirector::sharedDirector()->replaceScene(pScene); } }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector* pDirector = CCDirector::sharedDirector(); CCEGLView* pEGLView = CCEGLView::sharedOpenGLView(); pDirector->setOpenGLView(pEGLView); // turn on display FPS pDirector->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / FPS); // create a scene. it's an autorelease object CCScene *pScene = CCScene::create(); CCLayer *pSplashLayer = new Splash(); pSplashLayer->autorelease(); pScene->addChild(pSplashLayer); pDirector->runWithScene(pScene); return true; }
void S131More::showDetail(CCObject* pSender) { CCMenuItemSprite *aItem = (CCMenuItemSprite *)pSender; CCScene *newScene = CCScene::create(); newScene->addChild(S132Detail::create()); switch (aItem->getTag()) { case btnTag: newScene->addChild(S132Detail::create()); break; case btnTag+1: newScene->addChild(S132Detail::create()); break; default: break; } CCDirector::sharedDirector()->replaceScene(CCTransitionSlideInR::create(0.0f, newScene)); }
void S4HeZuo::menuCallback(CCObject* pSender) { removeUIKit(); AppDelegate::isTextViewExist = true; textView->removeTextView(1); CCMenuItemSprite *aItem = (CCMenuItemSprite *)pSender; CCScene *newScene = CCScene::create(); AppDelegate::S2Alpha = 0.0; AppDelegate::S4SelectNavi = aItem->getTag()-btnTag; if(AppDelegate::S4SelectNavi ==9) { newScene->addChild(S45ShowVideo::create()); //CCMessageBox("no video", "no video"); } else { newScene->addChild(S41Detail::create()); } CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(0.0f, newScene)); }