Beispiel #1
0
void SceneGame::addCtrlPanel()
{
	CCMenu* menu = CCMenu::create();
	addChild(menu, Z_MENU);

	CCMenuItemImage* regretItem = CCMenuItemImage::create("regret.jpg", "regret.jpg",
		this, menu_selector(SceneGame::Regret));
	menu->addChild(regretItem, Z_MENU);
	Common::moveNode(regretItem, ccp(160, 60));

	// 启动服务器的按钮
	CCMenuItem* startServerItem = CCMenuItemFont::create("StartServer", this, menu_selector(SceneGame::startServer));
	menu->addChild(startServerItem, Z_MENU);
	Common::moveNode(startServerItem, ccp(160, 0));

	// 启动客户端的按钮
	CCMenuItem* startClientItem = CCMenuItemFont::create("StartClient", this, menu_selector(SceneGame::startClient));
	menu->addChild(startClientItem, Z_MENU);
	Common::moveNode(startClientItem, ccp(160, -60));

	startServerItem->setUserObject(startClientItem);
	startClientItem->setUserObject(startServerItem);

	regretItem->setScale(0.7f);
	startServerItem->setScale(0.7f);
	startClientItem->setScale(0.7f);
}
void IntroScene::createUI()
{
    // Add background image
    CCSprite* bg_spt = CCSprite::create(getResPath(INTRO_BACKGROUND_IMGAE));
    bg_spt->setScaleX(SCALEX);
    bg_spt->setScaleY(SCALEY);
    bg_spt->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
    this->addChild(bg_spt);
    
    // Add description bg
    CCSprite* des_bg = CCSprite::create(getResPath(INTRO_DESCRIPTION_BG_IMG));
    des_bg->setScaleX(SCALEX);
    des_bg->setScaleY(SCALEY * 0.5);
    des_bg->setPosition(ccp(winSize.width * 0.5, 798 * SCALEY));
    this->addChild(des_bg);
    
    // Add description text
    CCSprite* des = CCSprite::create(getResPath(INTRO_DESCRIPTION_IMG));
    des->setScale(MIN(SCALEX, SCALEY));
    des->setPosition(ccp(winSize.width * 0.5, 800 * SCALEY));
    this->addChild(des);
    
    // Add character
    CCSprite* character = CCSprite::create(getResPath(INTRO_CHARACTER_IMG));
    character->setScale(SCALE * 0.9);
    character->setPosition(ccp(167 * SCALEX, 385 * SCALEY));
    this->addChild(character);
    
    // Add blue and yellow chair
    CCSprite* bl_chair = CCSprite::create(getResPath(CHAIR_BLUE_IMG));
    bl_chair->setScale(SCALE * 0.9);
    bl_chair->setPosition(ccp(140 * SCALEX, 243 * SCALEY));
    this->addChild(bl_chair);
    
    CCSprite* yl_chair = CCSprite::create(getResPath(CHAIR_YELLOW_IMG));
    yl_chair->setScale(SCALE * 0.9);
    yl_chair->setPosition(ccp(506 * SCALEX, 243 * SCALEY));
    this->addChild(yl_chair);
    
    // Add play, mainmenu buttons
    CCMenuItem* playItem = CCMenuItemImage::create(getResPath(INTRO_PLAY_BUTTON_IMAGE_NOR), getResPath(INTRO_PLAY_BUTTON_IMAGE_PRS), this, menu_selector(IntroScene::gotoplay));
    playItem->setScale(MIN(SCALEX, SCALEY));
    playItem->setPosition(175 * SCALEX, 50 * SCALEY);
    
    CCMenuItem* mainmenuItem = CCMenuItemImage::create(getResPath(INTRO_MAINMENU_BUTTON_IMAGE_NOR), getResPath(INTRO_MAINMENU_BUTTON_IMAGE_PRS), this, menu_selector(IntroScene::gotoMainMenu));
    mainmenuItem->setScale(MIN(SCALEX, SCALEY));
    mainmenuItem->setPosition(467 * SCALEX, 50 * SCALEY);
    
    CCMenu* menu = CCMenu::create(playItem, mainmenuItem, NULL);
    menu->setPosition(CCPointZero);
    this->addChild(menu);
}
bool CChooseLetterWindow::init()
{	   
	m_Back = Sprite::create("choose_letter.png");
	m_Back->setPosition(600,384); 
	m_Back->setVisible(false);
	addChild(m_Back);
	std::vector<char> m_Letters;
	m_Letters.resize(26);
	m_Letters[0] = 'a'; m_Letters[1] = 'b'; m_Letters[2] = 'c'; m_Letters[3] = 'd'; m_Letters[4] = 'e'; m_Letters[5] = 'f'; m_Letters[6] = 'g'; 
	m_Letters[7] = 'h'; m_Letters[8] = 'i'; m_Letters[9] = 'j'; m_Letters[10] = 'k'; m_Letters[11] = 'l'; m_Letters[12] = 'm'; m_Letters[13] = 'n'; 
	m_Letters[14] = 'o'; m_Letters[15] = 'p'; m_Letters[16] = 'q'; m_Letters[17] = 'r'; m_Letters[18] = 's'; m_Letters[19] = 't'; m_Letters[20] = 'u'; 
	m_Letters[21] = 'v'; m_Letters[22] = 'w'; m_Letters[23] = 'x'; m_Letters[24] = 'y'; m_Letters[25] = 'z'; 

	float startPosX = -460.0f;
	float startPosY = -150.0f;
	float stepX = 45.0f;
	float stepY = 45.0f;
	int columnCount = 6;
	int rowCount = 4;
	int id = 0;
	int currentColumn = 0;
	int currentRow = 0;
	m_pMenu = CCMenu::create();
	for(int i=0;i<m_Letters.size();i++)
	{
		Point pos = Point(startPosX+(currentColumn*stepX),startPosY+(-currentRow*stepY));
		CCMenuItem * button = CCMenuItemImage::create(
			"base.png",
			"fixed.png",
			this,
			menu_selector(CChooseLetterWindow::LetterBtnClick));
		button->setTag(int(m_Letters[i]));
		button->setScale(0.35f);
		button->setPosition(pos);
		LabelTTF * letterLabel = LabelTTF::create("0","helvetica",82);	
		letterLabel->setPosition(button->getContentSize().width/2,button->getContentSize().height/2);
		letterLabel->setColor(Color3B(0,0,0));
		std::string str = "A";
		str[0] = m_Letters[i];
		std::transform(str.begin(), str.end(),str.begin(), ::toupper);
		letterLabel->setString(str);
		button->addChild(letterLabel);
		//letterLabel->setPosition(pos);

		currentColumn++;
		if(currentColumn == columnCount)
		{
			currentColumn = 0;
			currentRow++;
		}
		m_pMenu->addChild(button);
		m_pMenu->setEnabled(false);
	}

	m_Back->addChild(m_pMenu);


	return true;
}
GetPeanuts::GetPeanuts()
{
        // enable touches
    setTouchEnabled( true );
    
    float scale = ScreenHelper::getTextureScale();
    float scaleX = ScreenHelper::getTextureScaleX();
    float scaleY = ScreenHelper::getTextureScaleY();
		
    
    CCSprite *spriteReturn = CCSprite::createWithSpriteFrameName("ctm_Store_Shopping_Btn.png");
    CCSprite *spriteReturnDown = CCSprite::createWithSpriteFrameName("ctm_Store_Shopping_Btn_Down.png");
    
    CCMenuItem *returnButton = CCMenuItemSprite::create(spriteReturn,spriteReturnDown,this,menu_selector(GetPeanuts::returnButtonTapped));
    returnButton->setScale(scale);
    returnButton->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_LEFT,90.0f,130.0f));
    
    CCMenu* backmenu = CCMenu::create(returnButton, NULL);
    backmenu->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_BOTTOM_LEFT));
    addChild(backmenu,4);
    
    setPosition(CCPointMake(-480*scaleX, 0));
    runAction(CCMoveBy::create(0.15f,CCPointMake(480*scaleX, 0)));
        
    bMenuBuilt = false;
    isReturning = false;
        
    if(SaveLoad::m_SaveData.beenToPeanuts==0)
    {
        SaveLoad::m_SaveData.beenToPeanuts=1;
        SaveLoad::Save();
        // [TestFlight passCheckpoint:@"PEANUT_VISIT"];
    }

    scheduleUpdate();
}
void Store::BuildBikes(cocos2d::CCMenu* menu)
{
    float scale = ScreenHelper::getTextureScale();
    
	CCMenuItemImage *topBar = CCMenuItemImage::create("ctm_UI_TransparentButton.png","ctm_UI_TransparentButton.png",this,menu_selector(Store::nullButtonTapped));
	
    topBar->setScale(scale);
    CCLabelTTF* label1 = CCLabelTTF::create("BIKES","Jacoby ICG Black.ttf",20);
    label1->setColor(ccc3(43,197,231));
	label1->setPosition(ccp(-170+CATEGORY_OFFSET,17));
	topBar->addChild(label1);
    
	menu->addChild(topBar);
    
	for(int i = 0; i < NUM_BIKE_ITEMS; i++)
	{
        CCMenuItem *temp = CCMenuItemImage::create("ctm_Store_GrayStrip.png","ctm_Store_GrayStrip.png","ctm_Store_LitStrip.png",this,menu_selector(Store::bikeButtonTapped) );
		
        CCSprite *sprite = CCSprite::createWithSpriteFrameName(s_BikeItemImg[i]);
		sprite->setPosition(ccp(ICON_X,ICON_Y));
		temp->addChild(sprite);
		
        CCSize dim;
        dim.width = 200.0f;
        dim.height = 25.0f;
        
        CCLabelTTF *label = CCLabelTTF::create(s_BikeItemName[i],"Jacoby ICG Black.ttf",20,dim,kCCTextAlignmentLeft);
        label->setColor(ccc3(237,188,0));
        label->setPosition(ccp(NAME_X,NAME_Y));
        temp->addChild(label);
        
		const char *status = NULL;
        if(SaveLoad::m_SaveData.bikes[i] & SaveLoad::SELECTED)
            status = "Selected";
        else if(SaveLoad::m_SaveData.bikes[i] & SaveLoad::UNLOCKED)
		    status = "Unlocked";
        else
            status = "Locked";
        
        dim.width = 400.0f;
        dim.height = 18.0f;
        label = CCLabelTTF::create(status,"Jacoby ICG Black.ttf",15,dim,kCCTextAlignmentLeft);
        label->setColor(ccc3(230,230,230));
        label->setPosition(ccp(DESC_X,DESC_Y));
        temp->addChild(label,0,15);
        
        m_BikeDescriptions[i] = label;
		
        if(SaveLoad::m_SaveData.bikes[i]==0)
        {
            //CGSize dim;
            dim.width = 50.0f;
            dim.height = 20.0f;
            
            char currencyStr[32];
            sprintf(currencyStr,"$%d",s_BikeItemCost[i]);
            
            CCLabelBMFont *BMfontLabel = CCLabelBMFont::create(currencyStr,"JacobyICGBlack18pnt.fnt");
            BMfontLabel->setAnchorPoint(ccp(1.0f,0.5f));
            BMfontLabel->setPosition(ccp(COST_X,COST_Y));
            temp->addChild(BMfontLabel,0,42);
		}
		
        temp->setScale(scale);
        
		menu->addChild(temp);
        m_Bikebuttons[i] = temp;
	}
	
    //add a bottom bar to push things up
    topBar = CCMenuItemImage::create("ctm_UI_TransparentButton.png","ctm_UI_TransparentButton.png",this,menu_selector(Store::nullButtonTapped));
    topBar->setScale(scale);
	menu->addChild(topBar);
}
void Store::BuildPowerUps(cocos2d::CCMenu* menu)
{
    float scale = ScreenHelper::getTextureScale();
    
	CCMenuItemImage *topBar = CCMenuItemImage::create("ctm_UI_TransparentButton.png","ctm_UI_TransparentButton.png",this,menu_selector(Store::nullButtonTapped));
	
    topBar->setScale(scale);
    CCLabelTTF* label1 = CCLabelTTF::create("POWERUPS","Jacoby ICG Black.ttf",20);
    label1->setColor(ccc3(43,197,231));
	label1->setPosition(ccp(-148+CATEGORY_OFFSET,17));
	topBar->addChild(label1);
    
    
	menu->addChild(topBar);
	
	for(int i = 0; i < NUM_POWERUP_ITEMS; i++)
	{
        CCMenuItem *temp = CCMenuItemImage::create("ctm_Store_GrayStrip.png","ctm_Store_GrayStrip.png","ctm_Store_LitStrip.png",this,menu_selector(Store::powerupButtonTapped) );
        
		
		CCSprite *sprite = CCSprite::createWithSpriteFrameName(s_PowerUpItemImg[i]);
		sprite->setPosition(ccp(ICON_X,ICON_Y));
		temp->addChild(sprite);

        char labelString[32];
        if(i==0)
        {
            if(SaveLoad::m_SaveData.numLevelFire)
                sprintf(labelString,"%s(%d)",s_PowerUpItemName[i],SaveLoad::m_SaveData.numLevelFire);
            else
                sprintf(labelString,"%s",s_PowerUpItemName[i]);
        }
        if(i==1)
        {
            if(SaveLoad::m_SaveData.numTimeSlow)
                sprintf(labelString,"%s(%d)",s_PowerUpItemName[i],SaveLoad::m_SaveData.numTimeSlow);
            else
                sprintf(labelString,"%s",s_PowerUpItemName[i]);
        }
        if(i==2)
        {
            if(SaveLoad::m_SaveData.numDoubleNuts)
                sprintf(labelString,"%s(%d)",s_PowerUpItemName[i],SaveLoad::m_SaveData.numDoubleNuts);
            else
                sprintf(labelString,"%s",s_PowerUpItemName[i]);
        }
        
        CCSize dim;
        dim.width = 200.0f;
        dim.height = 25.0f;
        
        
        CCLabelTTF *label = CCLabelTTF::create(labelString,"Jacoby ICG Black.ttf",20,dim,kCCTextAlignmentLeft);
        label->setColor(ccc3(237,188,0));
        label->setPosition(ccp(NAME_X,NAME_Y));
        temp->addChild(label);
        
        m_PowerUpNames[i] = label;
        
        dim.width = 400.0f;
        dim.height = 18.0f;
        label = CCLabelTTF::create(s_PowerUpItemDesc[i],"Jacoby ICG Black.ttf",15,dim,kCCTextAlignmentLeft);
        label->setColor(ccc3(230,230,230));
        label->setPosition(ccp(DESC_X,DESC_Y));
        temp->addChild(label,0,15);
        
		//CGSize dim;
		dim.width = 50.0f;
		dim.height = 20.0f;
        
        char currencyStr[32];
        sprintf(currencyStr,"$%d",s_PowerUpItemCost[i]);
        
        CCLabelBMFont *BMfontLabel = CCLabelBMFont::create(currencyStr,"JacobyICGBlack18pnt.fnt");
        BMfontLabel->setAnchorPoint(ccp(1.0f,0.5f));
        BMfontLabel->setPosition(ccp(COST_X,COST_Y));
		temp->addChild(BMfontLabel);
		
        temp->setScale(scale);
		
		menu->addChild(temp);
        m_PowerUpbuttons[i] = temp;
	}
	
}
void Store::BuildUpgrades(cocos2d::CCMenu* menu)
{
    float scale = ScreenHelper::getTextureScale();
    
	CCMenuItemImage *topBar = CCMenuItemImage::create("ctm_UI_TransparentButton.png","ctm_UI_TransparentButton.png",this,menu_selector(Store::nullButtonTapped));
	
    topBar->setScale(scale);
    CCLabelTTF* label1 = CCLabelTTF::create("UPGRADES","Jacoby ICG Black.ttf",20);
    label1->setColor(ccc3(43,197,231));
	label1->setPosition(ccp(-150+CATEGORY_OFFSET,17));
	topBar->addChild(label1);
    
	menu->addChild(topBar);
	int unlockLevel[NUM_UPGRADE_ITEMS];
    unlockLevel[0] = SaveLoad::m_SaveData.turboLockLevel;
    unlockLevel[1] = SaveLoad::m_SaveData.trampLockLevel;
    unlockLevel[2] = SaveLoad::m_SaveData.timeLockLevel;
    unlockLevel[3] = SaveLoad::m_SaveData.peanutLockLevel;
    unlockLevel[4] = SaveLoad::m_SaveData.trickLockLevel;
    unlockLevel[5] = SaveLoad::m_SaveData.flipLockLevel;
    unlockLevel[6] = SaveLoad::m_SaveData.fireLockLevel;
	
	for(int i = 0; i < NUM_UPGRADE_ITEMS; i++)
	{
		CCMenuItem *temp = CCMenuItemImage::create("ctm_Store_GrayStrip.png","ctm_Store_GrayStrip.png","ctm_Store_LitStrip.png",this,menu_selector(Store::buyUpgradeButtonTapped) );
        
        CCSprite *sprite;
        
        sprite = CCSprite::create("ctm_Store_PurchaseBars.png");
        sprite->setPosition(ccp(POWER_UP_BAR_OFFSET+302-120,POWER_UP_BAR_OFFSET_Y+21));
        temp->addChild(sprite);
        
		if(unlockLevel[i]>=1)
        {
            sprite = CCSprite::create("ctm_Store_LitPurchaseBar.png");
            sprite->setPosition(ccp(POWER_UP_BAR_OFFSET+290-120,POWER_UP_BAR_OFFSET_Y+20));
            temp->addChild(sprite);
		}
		if(unlockLevel[i]>=2)
        {
            sprite = CCSprite::create("ctm_Store_LitPurchaseBar.png");
            sprite->setPosition(ccp(POWER_UP_BAR_OFFSET+305-120,POWER_UP_BAR_OFFSET_Y+20));
            temp->addChild(sprite);
        }
		if(unlockLevel[i]>=3)
        {
            sprite = CCSprite::create("ctm_Store_LitPurchaseBar.png");
            sprite->setPosition(ccp(POWER_UP_BAR_OFFSET+320-120,POWER_UP_BAR_OFFSET_Y+20));
            temp->addChild(sprite);
		}
		sprite = CCSprite::createWithSpriteFrameName(s_UpgradeItemImg[i]);
		sprite->setPosition(ccp(ICON_X,ICON_Y));
		temp->addChild(sprite);
        
        CCSize dim;
        dim.width = 200.0f;
        dim.height = 25.0f;
        
        CCLabelTTF *label = CCLabelTTF::create(s_UpgradeItemName[i],"Jacoby ICG Black.ttf",20,dim,kCCTextAlignmentLeft);
        label->setColor(ccc3(237,188,0));
        label->setPosition(ccp(NAME_X,NAME_Y));
        temp->addChild(label);
        
		
        dim.width = 400.0f;
        dim.height = 18.0f;
        label = CCLabelTTF::create(s_UpgradeItemDesc[i][unlockLevel[i]],"Jacoby ICG Black.ttf",15,dim,kCCTextAlignmentLeft);
        label->setColor(ccc3(230,230,230));        
        label->setPosition(ccp(DESC_X,DESC_Y));
        temp->addChild(label,0,15);
        
        
		//CGSize dim;
		dim.width = 50.0f;
		dim.height = 20.0f;
        char currencyStr[32];
        if(s_UpgradeItemCost[i][unlockLevel[i]] > 0)
            sprintf(currencyStr,"$%d",s_UpgradeItemCost[i][unlockLevel[i]]);
        else
            sprintf(currencyStr,"Max");
        
        CCLabelBMFont *BMfontLabel = CCLabelBMFont::create(currencyStr,"JacobyICGBlack18pnt.fnt");
        BMfontLabel->setAnchorPoint(ccp(1.0f,0.5f));
        BMfontLabel->setPosition(ccp(COST_X,COST_Y));
        m_UpgradeCosts[i] = BMfontLabel;
		temp->addChild(BMfontLabel);
		
        temp->setScale(scale);
		menu->addChild(temp);
        
        m_UpgradeButtons[i] = temp;
	}
}
// initialize your instance here
Store::Store()
{
	
    //SaveLoad::m_SaveData.currency = 300000;
    //SaveLoad::SaveGame();
    // enable touches
    setTouchEnabled( true );
    
    float scale = ScreenHelper::getTextureScale();
    float scaleX = ScreenHelper::getTextureScaleX();
    float scaleY = ScreenHelper::getTextureScaleY();
    
    CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Buttons.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Buttons.plist");
    
    CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Icons.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Icons.plist");
    
    CCSprite *sprite = CCSprite::create("MainBackFiller.png");
    sprite->setScaleX(scaleX*1.2f);
    sprite->setScaleY(scaleY*1.2f);
    sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_CENTER,0.0f,-32.0f));
    addChild(sprite);
    
    sprite = CCSprite::create("ctm_UI_topOverlayA_ver1.png");
    sprite->setScaleX(scaleX);
    sprite->setScaleY(scaleY);
    sprite->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER));
    addChild(sprite,2);
    
    CCLabelTTF *label = CCLabelTTF::create("STORE", "impact.ttf", 42*scale);
    addChild(label, 2);
    label->setColor(ccc3(0,0,0));
    label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,2.0f,-52.0f));
    
    label = CCLabelTTF::create("STORE", "impact.ttf", 42*scale);
    addChild(label, 2);
    label->setColor(ccc3(237,188,0));
    label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,0.0f,-50.0f));
    
    CCMenuItem *BackButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("ctm_Back_Button.png"), CCSprite::createWithSpriteFrameName("ctm_Back_Button_Down.png"), this, menu_selector(Store::backButtonTapped));
    BackButton->setScale(scale);
    BackButton->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_LEFT,50.0f,-50.0f));
    ReturnButton = BackButton;
    
   
    CCSprite *spritePeanut = CCSprite::createWithSpriteFrameName("ctm_UI_Peanuts_Btn_ver1.png");
    CCSprite *spritePeanutDown = CCSprite::createWithSpriteFrameName("ctm_UI_Peanuts_Btn_Down.png");
    sprite = CCSprite::createWithSpriteFrameName("ctm_UI_PeanutsGlow_Btn_ver1.png");
    sprite->setPosition(ccp(136/2, 104/2));
    spritePeanut->addChild(sprite);
        
    CCMenuItem *PeanutsButton = CCMenuItemSprite::create(spritePeanut,spritePeanutDown,this,menu_selector(Store::peanutButtonTapped));
    
    PeanutsButton->setScale(scale);
    PeanutsButton->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_LEFT,90.0f,130.0f));
    
    CCMenu* backmenu = CCMenu::create(BackButton, NULL);
    backmenu->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_BOTTOM_LEFT));
    addChild(backmenu,4);
    
    m_slideControl = CCNode::create();
    addChild(m_slideControl);
    
    CCMenu* peanutmenu = CCMenu::create(PeanutsButton, NULL);
    peanutmenu->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_BOTTOM_LEFT));
    m_slideControl->addChild(peanutmenu,4);
    
    
    CCScrollingMenu *screenMenu = CCScrollingMenu::create();
    screenMenu->setPosition(0,0);
    
    BuildUpgrades(screenMenu);
    BuildPowerUps(screenMenu);
    BuildCharacters(screenMenu);
    BuildBikes(screenMenu);
  
    screenMenu->alignItemsVerticallyWithPadding(-10*scaleY);
    CCSize viewSize;
    viewSize.width = 320.0f*scaleX;
    viewSize.height = 1450.0f*scaleY/(scaleY/scale);
    CCScrollView *scrollView = CCScrollView::create(viewSize,screenMenu);
    //scrollView->setBounceable(false);
    //temp = ComingSoonButton->getPositionX()/scaleX-480.0f;
    //temp += (ComingSoonButton->getContentSize().width)/scale;
    scrollView->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_LEFT,160,275.0f*(scaleY/scale)-(viewSize.height/((scaleY+scale)/2.0f))/2.0f));
    scrollView->setContentSize(screenMenu->getContentSize());
    
    scrollView->setContentOffset(ccp(312.0f/2.0f*scaleX,0.0f));
    scrollView->setDirection(kCCScrollViewDirectionVertical);
    
    m_slideControl->addChild(scrollView);

    
    char currencyStr[32];
    sprintf(currencyStr,"$%d",SaveLoad::m_SaveData.currency);
    
    CCSize dim;
    dim.width = 100.0f;
    dim.height = 25.0f;
    
    m_currency = CCLabelBMFont::create(currencyStr,"JacobyICGBlack22pnt.fnt");
    m_currency->setScale(scale);
    m_currency->setAnchorPoint(ccp(1.0f,0.5f));
    m_currency->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_LEFT,456, 238));
    addChild(m_currency,10);
    
    
    if(SaveLoad::m_SaveData.beenToStore==0)
    {
        SaveLoad::m_SaveData.beenToStore=1;
        SaveLoad::Save();
    //    [TestFlight passCheckpoint:@"STORE_VISIT"];
    }
    
    scheduleUpdate();
}
QuestionMark::QuestionMark()
{
    setTouchEnabled( true );

    float scale = ScreenHelper::getTextureScale();
    float scaleX = ScreenHelper::getTextureScaleX();
    float scaleY = ScreenHelper::getTextureScaleY();
    
    CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Buttons.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Buttons.plist");
    
    CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Icons.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Icons.plist");
    
    CCSprite *sprite = CCSprite::create("MainBackFiller.png");
    sprite->setScaleX(scaleX*1.2f);
    sprite->setScaleY(scaleY*1.2f);
    sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_CENTER,0.0f,-32.0f));
    addChild(sprite);
    
    sprite = CCSprite::create("ctm_UI_topOverlayA_ver1.png");
    sprite->setScaleX(scaleX);
    sprite->setScaleY(scaleY);
    sprite->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER));
    addChild(sprite,2);
    
    CCLabelTTF *label = CCLabelTTF::create("?", "impact.ttf", 42*scale);
    addChild(label, 2);
    label->setColor(ccc3(0,0,0));
    label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,2.0f,-52.0f));
    
    label = CCLabelTTF::create("?", "impact.ttf", 42*scale);
    addChild(label, 2);
    label->setColor(ccc3(237,188,0));
    label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,0.0f,-50.0f));
    
    CCMenuItem *BackButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("ctm_Back_Button.png"), CCSprite::createWithSpriteFrameName("ctm_Back_Button_Down.png"), this, menu_selector(QuestionMark::backButtonTapped));
    BackButton->setScale(scale);
    BackButton->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_LEFT,50.0f,-50.0f));
    
    CCMenu* menu = CCMenu::create(BackButton, NULL);
    menu->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_BOTTOM_LEFT));
    addChild(menu,4);
    
    CCSize dim;
    int randInt = RandomInt(0,100);
    if(randInt>95)
    {
        dim.width = 420*scale;
        dim.height = 250*scale;
        const char *colorText = "\"Surely you can't be serious!\" he says, as he slowly ambles back to his crimson hued overstuffed chair.  You find yourself contemplating the simian who rebuffed your overture so out of hand.  You can't help but admire this modern Grigori Rasputin for his steely determination.  With perhaps undue influence of aqua vitae and plantains coloring your reason, you counter with tremendous vigor.  With all the potency of Hannibal and his terrene leviathan you fill your hands with your own ordure and volley it squarely into his agape maw.";
        
        CCLabelTTF *text = CCLabelTTF::create(colorText,"impact.ttf",16*scale,dim,kCCTextAlignmentCenter);
        text->setColor(ccc3(230,230,230));
        text->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_CENTER, 0.0f, -70.0f));
        addChild(text);
    }
    else if(randInt>5)
    {
        int randomImage = RandomInt(1,14);
        
        CCTextureCache::sharedTextureCache()->addPVRImage("QuestionMark.pvr.ccz");
        CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("QuestionMark.plist");
        
        char temp[64];
        sprintf(temp,"ConceptArt_%02d.png",randomImage);
        CCSprite *image = CCSprite::createWithSpriteFrameName(temp);
        image->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_CENTER, 0.0f, -35.0f));
        image->setScale(0.5f*scale);
        addChild(image);
    }
    else
    {
        dim.width = 420*scale;
        dim.height = 250*scale;
        const char *colorText = "?";
        
        CCLabelTTF *text = CCLabelTTF::create(colorText,"impact.ttf",80*scale,dim,kCCTextAlignmentCenter);
        text->setColor(ccc3(230,230,230));
        text->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_CENTER, 0.0f, -70.0f));
        addChild(text);
    }
}
Loading::Loading()
{
    glClearColor(0.0f/255.0f, 0.0f/255.0f, 0.0f/255.0f, 1.0f);
    setTouchEnabled( true );

    float scale = ScreenHelper::getTextureScale();
    float scaleX = ScreenHelper::getTextureScaleX();
    float scaleY = ScreenHelper::getTextureScaleY();
    
    CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Buttons.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Buttons.plist");
    
    CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Icons.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Icons.plist");
    
    CCTextureCache::sharedTextureCache()->addPVRImage("LoadingScreen.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("LoadingScreen.plist");
    
    CCPoint scalePoint;
    scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
    scalePoint.y += -5*scale;
    CCSprite *sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_Screen_ver2.png");
    sprite->setScale(scale);
    sprite->setPosition(scalePoint);
    addChild(sprite);
    
    
    sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_ProgressScroll_Graphic.png");
    sprite->setScaleX(scaleX);
    sprite->setScaleY(scaleY*1.2f);
    sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_LEFT,-140.0f,-50.0f));
    loadingBar = sprite;
    addChild(sprite,2);
    
    
    sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_TopPanel.png");
    sprite->setScaleX(scaleX);
    sprite->setScaleY(scaleY);
    sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,0.0f,-55.0f));
    addChild(sprite,2);
    
    sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_TopOverlay.png");
    sprite->setScaleX(scaleX);
    sprite->setScaleY(scaleY);
    sprite->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER));
    addChild(sprite,2);
    
    sprite = CCSprite::createWithSpriteFrameName("BackgroundPlate.png");
    sprite->setScale(scale);
    scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
    scalePoint.x += -135.0f*scale;
    scalePoint.y += -97.0f*scale;
    sprite->setPosition(scalePoint);
    addChild(sprite,2);
    
    sprite = CCSprite::createWithSpriteFrameName("BronzeText.png");
    sprite->setScale(scale);
    scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
    scalePoint.x += -135.0f*scale;
    scalePoint.y += -97.0f*scale;
    sprite->setPosition(scalePoint);
    addChild(sprite,2);
    
    CCLabelTTF *label = CCLabelTTF::create(LevelSelect::getLevelName(), "impact.ttf", 42*scale);
    addChild(label, 2);
    label->setColor(ccc3(0,0,0));
    label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,2.0f,-44.0f));
    
    label = CCLabelTTF::create(LevelSelect::getLevelName(), "impact.ttf", 42*scale);
    addChild(label, 2);
    label->setColor(ccc3(237,188,0));
    label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,0.0f,-42.0f));
    
    int currentLevel = LevelSelect::getCurrentLevel();
    if(currentLevel >= BONUS_LEVELSTART)
        g_isTrickLevel = true;
    else
        g_isTrickLevel = false;
    
    
    int medalLevel = SaveLoad::m_SaveData.medalLockLevel;
    int showMedal = 0;
    if(medalLevel==0)
    {
        if(SaveLoad::m_SaveData.levelflags[currentLevel] & SaveLoad::ONE_COCONUT)
            showMedal = 1;
    }
    if(medalLevel==1)
    {
        if(SaveLoad::m_SaveData.levelflags[currentLevel] & SaveLoad::TWO_COCONUT)
            showMedal = 2;
    }
    if(medalLevel==2)
    {
        if(SaveLoad::m_SaveData.levelflags[currentLevel] & SaveLoad::THREE_COCONUT)
            showMedal = 3;
    }
    
    if(!showMedal)
    {
        CCSize dimensions;
        dimensions.width = 100*scale;
        dimensions.height  = 25*scale;
        label = CCLabelTTF::create("Time:", "impact.ttf", 21*scale,dimensions,kCCTextAlignmentLeft);
        addChild(label, 2);
        label->setColor(ccc3(237,188,0));

        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += (-240.0f+90.0f)*scale;
        scalePoint.y += 50.0f*scale;
        label->setPosition(scalePoint);
        
        char tempLabelStr[32];
        sprintf(tempLabelStr,"%.2f",LevelSelect::getLevelGoals()->time);
        label = CCLabelTTF::create(tempLabelStr, "impact.ttf", 21*scale,dimensions,kCCTextAlignmentLeft);
        addChild(label, 2);
        label->setColor(ccc3(255,255,255));
        
        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += (-240.0f+150.0f)*scale;
        scalePoint.y += 50.0f*scale;
        label->setPosition(scalePoint);
                
        label = CCLabelTTF::create("Peanuts:", "impact.ttf", 21*scale,dimensions,kCCTextAlignmentLeft);
        addChild(label, 2);
        label->setColor(ccc3(237,188,0));
        
        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += (-240.0f+90.0f)*scale;
        scalePoint.y += 20.0f*scale;
        label->setPosition(scalePoint);
        
        sprintf(tempLabelStr,"%d",LevelSelect::getLevelGoals()->peanuts);
        label = CCLabelTTF::create(tempLabelStr, "impact.ttf", 21*scale,dimensions,kCCTextAlignmentLeft);
        addChild(label, 2);
        label->setColor(ccc3(255,255,255));
        
        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += (-240.0f+170.0f)*scale;
        scalePoint.y += 20.0f*scale;
        label->setPosition(scalePoint);
        
        label = CCLabelTTF::create("Points:", "impact.ttf", 21*scale,dimensions,kCCTextAlignmentLeft);
        addChild(label, 2);
        label->setColor(ccc3(237,188,0));
        
        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += (-240.0f+90.0f)*scale;
        scalePoint.y += -10.0f*scale;
        label->setPosition(scalePoint);
        
        sprintf(tempLabelStr,"%d",LevelSelect::getLevelGoals()->points);
        label = CCLabelTTF::create(tempLabelStr, "impact.ttf", 21*scale,dimensions,kCCTextAlignmentLeft);
        addChild(label, 2);
        label->setColor(ccc3(255,255,255));

        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += (-240.0f+160.0f)*scale;
        scalePoint.y += -10.0f*scale;
        label->setPosition(scalePoint);        
    }
    else
    {
        CCTextureCache::sharedTextureCache()->addPVRImage("LoadingScreen2.pvr.ccz");
        CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("LoadingScreen2.plist");

        if(showMedal == 1)
            sprite = CCSprite::createWithSpriteFrameName("ctm_BronzeMedalBig.png");
        if(showMedal == 2)
            sprite = CCSprite::createWithSpriteFrameName("ctm_SilverMedalBig.png");
        if(showMedal == 3)
            sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_LargeGold.png");
        
        sprite->setScale(scale);
        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += -135.0f*scale;
        scalePoint.y += 5.0f*scale;
        sprite->setPosition(scalePoint);
        addChild(sprite,2);
    }
    
    CCMenuItem *StoreButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("ctm_Button_17.png"), CCSprite::createWithSpriteFrameName("ctm_Button_17_Down.png"), this, menu_selector(Loading::storeButtonTapped));
    StoreButton->setScale(scale);
    scalePoint = ccp(0,0);
    scalePoint.x += 85.0f*scale;
    scalePoint.y += -100.0f*scale;
    StoreButton->setPosition(scalePoint);
    
    CCMenu* menu = CCMenu::create(StoreButton, NULL);
    menu->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER));
    addChild(menu,4);
    
    
    
    CCMenuItemSprite *items[3];
    //if(SaveLoad::m_SaveData.numDoubleNuts)
    {
        CCSize dim;
        dim.width = 200.0f;
        dim.height = 35.0f;
        CCSprite *barImage = CCSprite::create("ctm_UI_smallGreyStrip_ver1.png");
        CCSprite *barImageSel = CCSprite::create("ctm_UI_smallGreyStrip_ver1.png");
        barImage->setOpacity(0);
        barImageSel->setOpacity(0);
        CCMenuItemSprite *menuImage = CCMenuItemSprite::create(barImage,barImageSel,this,menu_selector(Loading::nutsButtonTapped));
        CCLabelTTF *blabel = CCLabelTTF::create(" Use 2X Peanuts","Jacoby ICG Black.ttf",18,dim,kCCTextAlignmentLeft);
        blabel->setColor(ccc3(237,188,0));
        blabel->setPosition(ccp(157.0f,18.0f));
        menuImage->addChild(blabel,0,1234);
        items[1] = menuImage;
        CCSprite *sprite = CCSprite::createWithSpriteFrameName("ctm_icon_Store_17_2X-peanuts.png");
        sprite->setPosition(ccp(30,23));
        sprite->setScale(0.925f);
        menuImage->addChild(sprite,0,4321);
        menuImage->setScale(scale);
        
        if(!SaveLoad::m_SaveData.numDoubleNuts)
        {
            //[menuImage setIsEnabled:NO];
            blabel->setColor(ccc3(237/2,188/2,0));
            sprite->setColor(ccc3(128,128,128));
        }
        
    }
    //if(SaveLoad::m_SaveData.numLevelFire)
    {
        CCSize dim;
        dim.width = 200.0f;
        dim.height = 35.0f;
        CCSprite *barImage = CCSprite::create("ctm_UI_smallGreyStrip_ver1.png");
        CCSprite *barImageSel = CCSprite::create("ctm_UI_smallGreyStrip_ver1.png");
        barImage->setOpacity(0);
        barImageSel->setOpacity(0);
        CCMenuItemSprite *menuImage = CCMenuItemSprite::create(barImage,barImageSel,this,menu_selector(Loading::fireButtonTapped));
        CCLabelTTF *blabel = CCLabelTTF::create(" Use Permanent Fire","Jacoby ICG Black.ttf",18,dim,kCCTextAlignmentLeft);
        blabel->setColor(ccc3(237,188,0));
        blabel->setPosition(ccp(157.0f,18.0f));
        menuImage->addChild(blabel,0,1234);
        items[2] = menuImage;
        CCSprite *sprite = CCSprite::createWithSpriteFrameName("ctm_icon_Store_18_Fire.png");
        sprite->setPosition(ccp(30,23));
        sprite->setScale(0.925f);
        menuImage->addChild(sprite,0,4321);
        menuImage->setScale(scale);
        
        if(!SaveLoad::m_SaveData.numLevelFire)
        {
            //[menuImage setIsEnabled:NO];
            blabel->setColor(ccc3(237/2,188/2,0));
            sprite->setColor(ccc3(128,128,128));
        }
    }
    //if(SaveLoad::m_SaveData.numTimeSlow)
    {
        
        CCSize dim;
        dim.width = 200.0f;
        dim.height = 35.0f;
        CCSprite *barImage = CCSprite::create("ctm_UI_smallGreyStrip_ver1.png");
        CCSprite *barImageSel = CCSprite::create("ctm_UI_smallGreyStrip_ver1.png");
        barImage->setOpacity(0);
        barImageSel->setOpacity(0);
        CCMenuItemSprite *menuImage = CCMenuItemSprite::create(barImage,barImageSel,this,menu_selector(Loading::timeButtonTapped));
        CCLabelTTF *blabel = CCLabelTTF::create(" Use Slow Clock","Jacoby ICG Black.ttf",18,dim,kCCTextAlignmentLeft);
        blabel->setColor(ccc3(237,188,0));
        blabel->setPosition(ccp(157.0f,18.0f));
        menuImage->addChild(blabel,0,1234);
        items[0] = menuImage;
        CCSprite *sprite = CCSprite::createWithSpriteFrameName("ctm_icon_Store_16_Slow-Clock.png");
        sprite->setPosition(ccp(30,23));
        sprite->setScale(0.925f);
        menuImage->addChild(sprite,0,4321);
        menuImage->setScale(scale);
        
        if(!SaveLoad::m_SaveData.numTimeSlow)
        {
            //[menuImage setIsEnabled:NO];
            blabel->setColor(ccc3(237/2,188/2,0));
            sprite->setColor(ccc3(128,128,128));
        }

        
    }
    CCMenu *powerUpMenu = CCMenu::create(items[0], items[1], items[2], NULL);
    
    powerUpMenu->alignItemsVerticallyWithPadding(-10.0);
    scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
    scalePoint.x += 100.0f*scale;
    scalePoint.y += 10.0f*scale;
    powerUpMenu->setPosition(scalePoint);
    addChild(powerUpMenu);
    
    
    m_TimeOut = 3.0f;
    scheduleUpdate();
}
bool SelectLevelScene::init(){
    
    if(!CCScene::init()){
        return false;
    }
    
    CCSprite* bg = CCSprite::create(Images::game::game_bg_jpg);
	addChild(bg, -1);
	bg->setAnchorPoint(ccp(0, 0));
    
	CCMenu* menu = CCMenu::create();
	addChild(menu, 1);
	menu->setAnchorPoint(ccp(0, 0));
	menu->setPosition(ccp(0, 0));
    
	CCMenuItem* backItem = UIUtil::getSingleImageBtn(
                                                     Images::common::back);
	menu->addChild(backItem);
	backItem->setTarget(this, menu_selector(SelectLevelScene::onClickBtn));
	backItem->setTag(-1);
	backItem->setAnchorPoint(ccp(1, 0));
    LayoutUtil::layoutTo(backItem, 0, 1, bg, 0, 1, 4, -4);
    
    _stageImg = CCSprite::create(Images::selectLevel::level1);
    _stageClickedImg = CCSprite::create(Images::selectLevel::level1);
    _stageClickedImgMask = CCSprite::create(Images::selectLevel::level1);
    _stageClickedImgMask->setColor(ccBLACK);
    _stageClickedImgMask->setOpacity(80);
    _stageClickedImg->addChild(_stageClickedImgMask, 1);
    LayoutUtil::layoutToParentCenter(_stageClickedImgMask, _stageClickedImg);
    
    CCMenuItem* stageItem = CCMenuItemSprite::create(_stageImg, _stageClickedImg);
    stageItem->setTarget(this, menu_selector(SelectLevelScene::onClickBtn));
    stageItem->setScale(1.3);
    stageItem->setTag(1);
    menu->addChild(stageItem);
    LayoutUtil::layoutToParentCenter(stageItem, this);
    
    CCMenuItem* leftArrow = UIUtil::getSingleImageBtn(Images::selectLevel::icon_arrow);
    leftArrow->setTarget(this, menu_selector(SelectLevelScene::prev));
    menu->addChild(leftArrow);
    LayoutUtil::layoutTo(leftArrow, 1, 0.5, stageItem, 0, 0.5, -18);
    
    CCSprite* leftArrowBg = CCSprite::create(Images::selectLevel::icon_arrow);
    leftArrowBg->setScale(1.1);
    leftArrowBg->setColor(ccBLACK);
    addChild(leftArrowBg, 0);
    LayoutUtil::layoutToCenter(leftArrowBg, leftArrow);
    
    
    CCMenuItem* rightArrow = UIUtil::getSingleImageBtn(Images::selectLevel::icon_arrow);
    rightArrow->setTarget(this, menu_selector(SelectLevelScene::next));
    menu->addChild(rightArrow);
    rightArrow->setScaleX(-1);
    LayoutUtil::layoutTo(rightArrow, 0, 0.5, stageItem, 1, 0.5, 18);
    
    CCSprite* rightArrowBg = CCSprite::create(Images::selectLevel::icon_arrow);
    rightArrowBg->setScaleX(-1.1);
    rightArrowBg->setScaleY(1.1);
    rightArrowBg->setColor(ccBLACK);
    addChild(rightArrowBg, 0);
    LayoutUtil::layoutToCenter(rightArrowBg, rightArrow);
    
    _stageIndexText = CCLabelTTF::create("01/11", "arial-bold", 30);
    _stageIndexText->setColor(ccBLACK);
    addChild(_stageIndexText, 1);
    LayoutUtil::layoutTo(_stageIndexText, 0.5, 0, stageItem, 0.5, 1, 0, -20);
    
    CCLabelTTF* title = CCLabelTTF::create("选择难度", "arial-bold", 38);
    title->setColor(ccBLACK);
    addChild(title, 1);
    LayoutUtil::layoutTo(title, 0.5, 0, _stageIndexText, 0.5, 1, 0, 20);
    
    MusicBtn* musicBtn = MusicBtn::create();
    addChild(musicBtn, 1);
	LayoutUtil::layoutTo(musicBtn, 0, 0, bg, 0, 0, 5, 5);
    
    _curLevel = 0;
    
    AdUtil::showAd();
    
    return true;
}
Options::Options()
{
    setTouchEnabled( true );

    float scale = ScreenHelper::getTextureScale();
    float scaleX = ScreenHelper::getTextureScaleX();
    float scaleY = ScreenHelper::getTextureScaleY();
    
    CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Buttons.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Buttons.plist");
    
    CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Icons.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Icons.plist");
    
    CCSprite *sprite = CCSprite::create("MainBackFiller.png");
    sprite->setScaleX(scaleX*1.2f);
    sprite->setScaleY(scaleY*1.2f);
    sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_CENTER,0.0f,-32.0f));
    addChild(sprite);
    
    sprite = CCSprite::create("ctm_UI_topOverlayA_ver1.png");
    sprite->setScaleX(scaleX);
    sprite->setScaleY(scaleY);
    sprite->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER));
    addChild(sprite,2);
    
    CCLabelTTF *label = CCLabelTTF::create("OPTIONS", "impact.ttf", 42*scale);
    addChild(label, 2);
    label->setColor(ccc3(0,0,0));
    label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,2.0f,-52.0f));
    
    label = CCLabelTTF::create("OPTIONS", "impact.ttf", 42*scale);
    addChild(label, 2);
    label->setColor(ccc3(237,188,0));
    label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,0.0f,-50.0f));
    
    CCMenuItem *BackButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("ctm_Back_Button.png"), CCSprite::createWithSpriteFrameName("ctm_Back_Button_Down.png"), this, menu_selector(Options::backButtonTapped));
    BackButton->setScale(scale);
    BackButton->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_LEFT,50.0f,-50.0f));
    
    CCMenuItem *QuestionMarkButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("ctm_Button_20.png"), CCSprite::createWithSpriteFrameName("ctm_Button_20_Down.png"), this, menu_selector(Options::questionButtonTapped));
    QuestionMarkButton->setScale(scale);
    QuestionMarkButton->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_CENTER,0.0f,65.0f));
    
    CCMenuItem *MoreGamesButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("MoreGames.png"), CCSprite::createWithSpriteFrameName("MoreGames_dn.png"), this, menu_selector(Options::moreGamesButtonTapped));
    MoreGamesButton->setScale(scale);
    MoreGamesButton->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_LEFT,55.0f,65.0f));
    
    CCMenuItem *CreditsButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("Credits.png"), CCSprite::createWithSpriteFrameName("Credits_dn.png"), this, menu_selector(Options::creditsButtonTapped));
    CreditsButton->setScale(scale);
    CreditsButton->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_RIGHT,-55.0f,65.0f));
    
    CCLabelTTF *optionsLabel = NULL;
    if(SaveLoad::m_SaveData.sfxVolume <= 0.0f)
        optionsLabel = CCLabelTTF::create("SFX:  OFF", "impact.ttf", 40*scale);
    else
        optionsLabel = CCLabelTTF::create("SFX:  ON", "impact.ttf", 40*scale);
    
    CCMenuItemLabel *SoundFX = CCMenuItemLabel::create(optionsLabel, this, menu_selector(Options::sfxButtonTapped));
    SoundFX->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_CENTER, 0, 20));
    
    
    
    if(SaveLoad::m_SaveData.musicVolume <= 0.0f)
        optionsLabel = CCLabelTTF::create("Music:  OFF", "impact.ttf", 40*scale);
    else
        optionsLabel = CCLabelTTF::create("Music:  ON", "impact.ttf", 40*scale);
    
    CCMenuItemLabel *Music = CCMenuItemLabel::create(optionsLabel, this, menu_selector(Options::musicButtonTapped));
    Music->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_CENTER, 0, -20));
    
    
    
    CCMenu* menu = CCMenu::create(BackButton, QuestionMarkButton, MoreGamesButton, CreditsButton, SoundFX, Music, NULL);
    menu->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_BOTTOM_LEFT));
    addChild(menu,4);
    
    scheduleUpdate();
}
Beispiel #13
0
bool GameSceneLayer::init(){
	bool bRet = false;
	do{
		CC_BREAK_IF(!CCLayer::init());
		setKeypadEnabled(true);

		//CCLOG("init1");
		//创建物理世界
		b2Vec2 gravity;
		gravity.Set(0.0f,-10.0f);
		m_pMyworld = new b2World(gravity);
		m_pMyworld->SetAllowSleeping(true);

		m_pMyContactListener = new MyContactListener();
		m_pMyworld->SetContactListener(m_pMyContactListener);

		//m_pDebugDraw = new GLESDebugDraw( PT_RATIO );
		//m_pMyworld->SetDebugDraw(m_pDebugDraw);
		//uint32 flags = 0;
		//flags += b2Draw::e_shapeBit;
		//flags += b2Draw::e_jointBit;
		//flags += b2Draw::e_aabbBit;
		//flags += b2Draw::e_pairBit;
		//flags += b2Draw::e_centerOfMassBit;
		//m_pDebugDraw->SetFlags(flags);

		//创建一个地面
		//b2BodyDef groundboxDef;
		////groundboxDef.

		//b2Body *groundBody = m_pMyworld->CreateBody(&groundboxDef);
	
		//b2EdgeShape groundbox;
		////groundbox.m_type
		//groundbox.Set(b2Vec2(0,220/32),b2Vec2(640.0f/32,220/32));
		//groundBody->CreateFixture(&groundbox,0);

		//groundbox.Set(b2Vec2(0,0/32),b2Vec2(0,480.0f/32));
		//groundBody->CreateFixture(&groundbox,0);

		//groundbox.Set(b2Vec2(640.0f/32,0/32),b2Vec2(640.0f/32,480.0f/32));
		//groundBody->CreateFixture(&groundbox,0);

		//groundbox.Set(b2Vec2(0,480.0f/32),b2Vec2(640.0f/32,480.0f/32));
		//groundBody->CreateFixture(&groundbox,0);

		//创建几个动态刚体

		//for (int i = 0; i < 4; i++){

		//	CCSprite *sprite = CCSprite::create("image 277.png");
		//	sprite->setPosition(ccp(200+100*i,200));
		//	addChild(sprite);
		//	addBoxbodyFromSprite(sprite);
		//	//b2BodyDef bodydef;
		//	//bodydef.type = b2_dynamicBody;
		//	//bodydef.position.Set(200/32+100/32*i,200/32);

		//	//b2Body *body = m_pMyworld->CreateBody(&bodydef);

		//	//b2PolygonShape dynamicbox;
		//	//dynamicbox.SetAsBox(0.5f,0.5f);

		//	//b2FixtureDef fixturedef;
		//	//fixturedef.shape = &dynamicbox;
		//	//fixturedef.density = 1.0f;
		//	//fixturedef.friction = 0.3f;
		//	//fixturedef.restitution = 0.5f;
		//	//body->CreateFixture(&fixturedef);
		//}

		//init 
		CCSprite* bg;
		if (Setting::g_icurrentGate < 10)
		{
			 bg = CCSprite::create("gamebg_1.png");
		}else
		{
		  bg = CCSprite::create("gamebg_2.png");
		}
		bg->setPosition(ccp(Setting::g_ResolusionWidth/2,Setting::g_ResolusionHeight/2));
		addChild(bg,-1);

		m_bDrawlineFlag = false;
		m_LineEndpos = m_LineStartpos = ccp(105,155);

		m_iResuduoMonsterNum = 0;
		//CCLOG("init2");
		initTiledMap();


		//添加一个炮台
		CCSprite*cannonSprite = CCSprite::createWithSpriteFrameName("cannon.png");
		addChild(cannonSprite,1);
		cannonSprite->setPosition(ccp(105,155));
		cannonSprite->setTag(m_iCannonSpriteTag);

		CCSprite*batterySprite = CCSprite::createWithSpriteFrameName("battery.png");
		addChild(batterySprite,1);
		batterySprite->setPosition(ccp(100,140));
		batterySprite->setTag(m_iBatterySpriteTag);

		CCAnimation *pCannonAnimation = CCAnimation::create();
		CCSpriteFrameCache *framecache = CCSpriteFrameCache::sharedSpriteFrameCache();
		for(int i = 0 ; i < 5 ; i++){
			pCannonAnimation->addSpriteFrame(framecache->spriteFrameByName(CCString::createWithFormat("cannon%d.png",i+1)->getCString()));
		}
		pCannonAnimation->setDelayPerUnit(0.08f);
		pCannonAnimation->setRestoreOriginalFrame(true);
		m_pCannonAnimate = CCAnimate::create(pCannonAnimation);
		m_pCannonAnimate->retain();
		m_pCannonAnimate->setTag(m_iCannonAnimateTag);

		CCAnimation *pBatteryAnimation = CCAnimation::create();
		for (int i = 0 ; i < 3 ; i++)	{
			pBatteryAnimation->addSpriteFrame(framecache->spriteFrameByName(CCString::createWithFormat("battery%d.png",i+1)->getCString()));
		}
		pBatteryAnimation->setDelayPerUnit(0.08f);
		pBatteryAnimation->setRestoreOriginalFrame(true);
		m_pBatteryAnimate = CCAnimate::create(pBatteryAnimation);
		m_pBatteryAnimate->retain();


		CCMenuItem* menuItem = CCMenuItemImage::create("button/btn_pause.png","button/btn_pause.png",this,menu_selector(GameSceneLayer::onPause));
		menuItem->setPosition(ccp(60,460));
		menuItem->setScale(0.5f,0.5f);
		CCMenu* menu = CCMenu::create(menuItem,NULL);
		menu->setPosition(ccp(0,0));
        menu->setAnchorPoint(ccp(0,0));
		this->addChild(menu,10);



		schedule(schedule_selector(GameSceneLayer::tick));

		bRet = true;

		
	} while (0);
	return bRet;
}
Credits::Credits()
{
    setTouchEnabled( true );
    
    float scale = ScreenHelper::getTextureScale();
    float scaleX = ScreenHelper::getTextureScaleX();
    float scaleY = ScreenHelper::getTextureScaleY();
    
    CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Buttons.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Buttons.plist");
    
    CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Icons.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Icons.plist");
    
    CCSprite *sprite = CCSprite::create("MainBackFiller.png");
    sprite->setScaleX(scaleX*1.2f);
    sprite->setScaleY(scaleY*1.2f);
    sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_CENTER,0.0f,-32.0f));
    addChild(sprite);
    
    sprite = CCSprite::create("ctm_UI_topOverlayA_ver1.png");
    sprite->setScaleX(scaleX);
    sprite->setScaleY(scaleY);
    sprite->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER));
    addChild(sprite,2);
    
    CCLabelTTF *label = CCLabelTTF::create("CREDITS", "impact.ttf", 42*scale);
    addChild(label, 2);
    label->setColor(ccc3(0,0,0));
    label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,2.0f,-52.0f));
    
    label = CCLabelTTF::create("CREDITS", "impact.ttf", 42*scale);
    addChild(label, 2);
    label->setColor(ccc3(237,188,0));
    label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,0.0f,-50.0f));
    
    
    
    
    sprite = CCSprite::create("box2d_logo2.png");
    sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_CENTER,0.0f,-10.0f));
    sprite->setScale(0.75f*scale);
    addChild(sprite);
    
    sprite = CCSprite::create("*****@*****.**");
    sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_RIGHT,-90.0f,-20.0f));
    sprite->setScale(0.75f*scale);
    addChild(sprite);
    
    
    ////////////////////////////////////////////////////
    CCSize dim;
    dim.width = 300;
    dim.height = 50*scale;
    
    dim.width = 150*scale;
    CCLabelTTF *art = CCLabelTTF::create("Art","impact.ttf",20*scale,dim,kCCTextAlignmentLeft);
    art->setColor(ccc3(237,188,0));
    art->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_LEFT,90.0f,40.0f));
    addChild(art);
    
    CCLabelTTF *ken = CCLabelTTF::create("Ken Keys","impact.ttf",20*scale,dim,kCCTextAlignmentLeft);
    ken->setColor(ccc3(230,230,230));
    ken->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_LEFT,90.0f,20.0f));
    addChild(ken);
    
    CCLabelTTF *garrett = CCLabelTTF::create("Garrett Wren","impact.ttf",20*scale,dim,kCCTextAlignmentLeft);
    garrett->setColor(ccc3(230,230,230));
    garrett->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_LEFT,90.0f,0.0f));
    addChild(garrett);
    
    
    
    
    CCLabelTTF *programming = CCLabelTTF::create("Programming","impact.ttf",20*scale,dim,kCCTextAlignmentLeft);
    programming->setColor(ccc3(237,188,0));
    programming->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_LEFT,90.0f,-35.0f));
    addChild(programming);
    
    CCLabelTTF *ryan = CCLabelTTF::create("Ryan McBride","impact.ttf",20*scale,dim,kCCTextAlignmentLeft);
    ryan->setColor(ccc3(230,230,230));
    ryan->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_LEFT,90.0f,-55.0f));
    addChild(ryan);
    
    CCLabelTTF *audio = CCLabelTTF::create("Audio","impact.ttf",20*scale,dim,kCCTextAlignmentLeft);
    audio->setColor(ccc3(237,188,0));
    audio->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_LEFT,90.0f,-85.0f));
    addChild(audio);
    
    CCLabelTTF *pete = CCLabelTTF::create("Peter Lehman","impact.ttf",20*scale,dim,kCCTextAlignmentLeft);
    pete->setColor(ccc3(230,230,230));
    pete->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_LEFT,90.0f,-105.0f));
    addChild(pete);
    
    
    dim.width = 300*scale;
    CCLabelTTF *ludicrous = CCLabelTTF::create("© 2013 Ludicrous Games LLC","impact.ttf",24*scale,dim,kCCTextAlignmentRight);
    ludicrous->setAnchorPoint(ccp(1.0f,0.5f));
    ludicrous->setColor(ccc3(237,188,0));
    ludicrous->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_RIGHT,-15.0f,-95.0f));
    addChild(ludicrous);
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    CCMenuItem *BackButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("ctm_Back_Button.png"), CCSprite::createWithSpriteFrameName("ctm_Back_Button_Down.png"), this, menu_selector(Credits::backButtonTapped));
    BackButton->setScale(scale);
    BackButton->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_LEFT,50.0f,-50.0f));
    
    CCMenu* menu = CCMenu::create(BackButton, NULL);
    menu->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_BOTTOM_LEFT));
    addChild(menu,4);
}
void GetPeanuts::BuildMenu()
{
    float scale = ScreenHelper::getTextureScale();
    float scaleX = ScreenHelper::getTextureScaleX();
    float scaleY = ScreenHelper::getTextureScaleY();
    
    CCMenu *screenMenu = CCMenu::create();
    
    CCSize dim;
    dim.width = 200.0f;
    dim.height = 35.0f;
    
    for(int i = 0; i < 4; i++)
    {
        
        CCMenuItem *temp = CCMenuItemImage::create("ctm_Store_GrayStrip.png","ctm_Store_LitStrip.png","ctm_Store_LitStrip.png",this,menu_selector(GetPeanuts::buyButtonTapped) );
        
        
        CCSprite *sprite = NULL;
        switch(i)
        {
            case 0:
                sprite = CCSprite::createWithSpriteFrameName("ctm_PeanutGraphic_A.png");
                break;
            case 1:
                sprite = CCSprite::createWithSpriteFrameName("ctm_PeanutGraphic_B.png");
                break;
            case 2:
                sprite = CCSprite::createWithSpriteFrameName("ctm_PeanutGraphic_C.png");
                break;
            case 3:
                sprite = CCSprite::createWithSpriteFrameName("ctm_PeanutGraphic_D.png");
                break;
        }
        sprite->setPosition(ccp(312/2-16,33));
        temp->addChild(sprite);
        
        const char *amount;
        const char *cost;
        switch(i)
        {
            case 0:
                amount = "3,000";
                cost = "$1.99";
                break;
            case 1:
                amount = "35,000";
                cost = "$7.99";
                break;
            case 2:
                amount = "100,000";
                cost = "$14.99";
                break;
            case 3:
                amount = "300,000";
                cost = "$24.99";
                break;
        }
        CCLabelTTF *label = CCLabelTTF::create(amount,"Jacoby ICG Black.ttf",30,dim,kCCTextAlignmentRight);
        label->setColor(ccc3(237,188,0));
        label->setPosition(ccp(200,46));
        temp->addChild(label);
        
        
        CCSize dim;
        dim.width = 70.0f;
        dim.height = 20.0f;
        
        label = CCLabelTTF::create(cost,"Jacoby ICG Black.ttf",20,dim,kCCTextAlignmentRight);
        label->setColor(ccc3(230,230,230));
        label->setPosition(ccp(260,23));
        temp->addChild(label);
        
        temp->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_CENTER,-250.0f,-i*50));
        temp->setScale(scale);
        screenMenu->addChild(temp);
        m_MenuItems[i] = temp;
    }
    screenMenu->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_CENTER,86,-119));
    addChild(screenMenu);
}