void GameLotteryLayer::onBtnRewardCallback(CCObject* pSender) { if (m_bTempSoundOn) { SoundPlayer::play(SNDI_CLICK); } unschedule(schedule_selector(GameLotteryLayer::removeHint)); enableBtns(); // delete hint CCMenuItemSprite* item = static_cast<CCMenuItemSprite*> (pSender); unRegisterMenuItem(item); item->runAction(CCSequence::create( CCCallFunc::create(item, callfunc_selector(CCMenuItemSprite::removeFromParent)), NULL)); m_ptrMenuHint = NULL; // reset circle m_ptrCircle->setRotation(0.0f); // delete the highLight CCNode* ptrLight = m_ptrCircle->getChildByTag(LIGHT_TAG); if(ptrLight) { ptrLight->removeFromParent(); } chargeNewDay(); }
void GameOverLayer::createPlayAgainButton() { // Create the startButton CCSprite *playAgainButtonSpriteUp = CCSprite::createWithSpriteFrameName("playagain_button.png"); CCSprite *playAgainButtonSpriteDown = CCSprite::createWithSpriteFrameName("playagain_button.png"); // Scale the down to 90% so that it looks like the button was pressed playAgainButtonSpriteDown->setScale(0.9f); CCMenuItemSprite *playAgainButton = CCMenuItemSprite::create(playAgainButtonSpriteUp, playAgainButtonSpriteDown, this, menu_selector(GameOverLayer::playAgainButtonTouched)); playAgainButton->setPositionX(-playAgainButton->getContentSize().width/1.2); playAgainButton->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(1.0f, 1.2f), CCScaleTo::create(1.0f, 1.0f)))); // Create the mainButton CCSprite *mainButtonSpriteUp = CCSprite::createWithSpriteFrameName("main_button.png"); CCSprite *mainButtonSpriteDown = CCSprite::createWithSpriteFrameName("main_button.png"); // Scale the down to 90% so that it looks like the button was pressed mainButtonSpriteDown->setScale(0.9f); CCMenuItemSprite *mainButton = CCMenuItemSprite::create(mainButtonSpriteUp, mainButtonSpriteDown, this, menu_selector(GameOverLayer::mainButtonTouched)); mainButton->setPositionX(mainButton->getContentSize().width/1.2); // Create the start game menu CCMenu *gameMenu = CCMenu::create(playAgainButton, mainButton, NULL); // Set the initial position off screen gameMenu->setPosition(ccp(SCREEN_WIDTH/2, -SCREEN_HEIGHT)); // Set the tag of the start menu so that we can refer to it later using getChildByTag(...) gameMenu->setTag(kGameOverLayer_PlayAgainMenu); // Create and run an animation that will slide the start game menu in from below the screen to its intended location CCActionInterval *moveAction = CCMoveTo::create(0.3f, ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.15)); CCFiniteTimeAction *easeIn = CCEaseIn::create(moveAction, 0.2f); gameMenu->runAction(easeIn); // Add the start menu to the layer this->addChild(gameMenu); }
void GameScene::restart(CCObject* obj) { CC_SAFE_RELEASE(pipeArray); CC_SAFE_RELEASE(hitCheckArray); stopAllActions(); unscheduleAllSelectors(); CCMenuItemSprite* item = (CCMenuItemSprite*)obj; CCScaleTo* scale = CCScaleTo::create(0.1f, 1.2f); CCScaleTo* scale2 = CCScaleTo::create(0.1f, 1.0f); CCSequence* seq = CCSequence::create(scale, scale2, NULL); item->runAction(seq); CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(1.5f, GameScene::scene())); }
// on "init" you need to initialize your instance bool GameLayer::init() { if (!CCLayer::init()) return false; SCREEN_WIDTH = CCDirector::sharedDirector()->getWinSize().width; SCREEN_HEIGHT = CCDirector::sharedDirector()->getWinSize().height; bPaused = false; //Jerry--LB receiveRank(); CCSprite* sprite = ThemeManager::sharedInstance()->spriteWithImageFile("background.png");//ThemeManager::sharedInstance()->spriteWithImageFile("background.png"); sprite->setScaleX(SCREEN_WIDTH/sprite->getContentSize().width); sprite->setScaleY(SCREEN_HEIGHT/sprite->getContentSize().height); sprite->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT/2)); this->addChild(sprite,1); float iMenuWidthOffset = 0.55; CCSprite* startNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_start.png"); CCSprite* startSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_start.png"); CCMenuItemSprite* pStartItemSprite = CCMenuItemSprite::itemWithNormalSprite(startNormal, startSelected, this, menu_selector(GameLayer::startButtonClick)); CCMenu* pStartMenu = CCMenu::menuWithItems(pStartItemSprite,NULL); pStartMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.6)); pStartItemSprite->setScale(LL_BUTTON_SCALE_VALUE); //Jerry--Action CCScaleTo* large=CCScaleTo::actionWithDuration(0.5,0.7*LL_SCREEN_SCALE_VALUE); CCScaleTo* small=CCScaleTo::actionWithDuration(0.5,LL_BUTTON_SCALE_VALUE); CCDelayTime *waiting=CCDelayTime::actionWithDuration(1.0f); CCFiniteTimeAction* action= CCSequence::actions(waiting,large,small,waiting,NULL); CCActionInterval* actionShake=CCRepeatForever::actionWithAction((CCActionInterval*)action); pStartItemSprite->stopAllActions(); pStartItemSprite->runAction(actionShake); this->addChild(pStartMenu, 3); /*CCSprite* leaderboardNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png"); CCSprite* leaderboardSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png"); CCSprite* leaderboardDisabled = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png"); CCMenuItemSprite* pleaderboardItemSprite = CCMenuItemSprite::itemWithNormalSprite(leaderboardNormal, leaderboardSelected, leaderboardDisabled, this, menu_selector(GameLayer::levelButtonClick)); pleaderboardItemSprite->setScale(0.8); CCMenu* pleaderboardMenu = CCMenu::menuWithItems(pleaderboardItemSprite,NULL); pleaderboardMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.4)); this->addChild(pleaderboardMenu, 3);*/ CCSprite* instructionNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_instruction.png"); CCSprite* instructionSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_instruction.png"); CCMenuItemSprite* pinstructionItemSprite = CCMenuItemSprite::itemWithNormalSprite(instructionNormal, instructionSelected,this, menu_selector(GameLayer::instructionButtonClick)); pinstructionItemSprite->setScale(LL_BUTTON_SCALE_VALUE); CCMenu* pinstructionMenu = CCMenu::menuWithItems(pinstructionItemSprite,NULL); pinstructionMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.5)); this->addChild(pinstructionMenu, 3); CCSprite* quitNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_quit.png"); CCSprite* quitSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_quit.png"); quitSelected->setScale(1.1); CCMenuItemSprite* pquitItemSprite = CCMenuItemSprite::itemWithNormalSprite(quitNormal, quitSelected, this, menu_selector(GameLayer::finishButtonClick)); pquitItemSprite->setScale(LL_BUTTON_SCALE_VALUE); CCMenu* pquitMenu = CCMenu::menuWithItems(pquitItemSprite,NULL); pquitMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.2)); this->addChild(pquitMenu, 3); //Jerry--Code CCSprite* lbNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png"); CCSprite* lbSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png"); lbSelected->setScale(1.1); CCMenuItemSprite* plbItemSprite = CCMenuItemSprite::itemWithNormalSprite(lbNormal, lbSelected, this, menu_selector(GameLayer::leaderboardButtonClick)); plbItemSprite->setScale(LL_BUTTON_SCALE_VALUE); CCMenu* plbMenu = CCMenu::menuWithItems(plbItemSprite,NULL); plbMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.4)); this->addChild(plbMenu, 3); //Jerry--Code CCSprite* thNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_theme.png"); CCSprite* thSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_theme.png"); thSelected->setScale(1.1); CCMenuItemSprite* pthItemSprite = CCMenuItemSprite::itemWithNormalSprite(thNormal, thSelected, this, menu_selector(GameLayer::themeButtonClick)); pthItemSprite->setScale(LL_BUTTON_SCALE_VALUE); CCMenu* pthMenu = CCMenu::menuWithItems(pthItemSprite,NULL); pthMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.3)); this->addChild(pthMenu, 3); if(getFlags("INPUT_NICKNAME_FLAG") == 0) { updateNickname(NULL); setFlags("INPUT_NICKNAME_FLAG", 1); } //InitBdAd(); //showDoSplash(); PlatformManager::sharedInstance()->showBanner(); PlatformManager::sharedInstance()->showInter(); //showDoBanner(); return true; }