本文整理汇总了C++中CCMenuItem::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItem::setScale方法的具体用法?C++ CCMenuItem::setScale怎么用?C++ CCMenuItem::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItem
的用法示例。
在下文中一共展示了CCMenuItem::setScale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addCtrlPanel
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);
}
示例2: createUI
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);
}
示例3: init
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;
}
示例4: setTouchEnabled
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();
}
示例5: BuildBikes
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);
}
示例6: BuildPowerUps
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;
}
}
示例7: BuildUpgrades
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;
}
}
示例8: setTouchEnabled
// 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;
//.........这里部分代码省略.........
示例9: if
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);
}
}
示例10: glClearColor
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)
{
//.........这里部分代码省略.........
示例11: init
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;
}
示例12: setTouchEnabled
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();
}
示例13: init
//.........这里部分代码省略.........
//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;
}
示例14: setTouchEnabled
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("[email protected]");
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));
//.........这里部分代码省略.........
示例15: BuildMenu
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);
}