本文整理汇总了C++中CCMenuItemImage::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemImage::addChild方法的具体用法?C++ CCMenuItemImage::addChild怎么用?C++ CCMenuItemImage::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemImage
的用法示例。
在下文中一共展示了CCMenuItemImage::addChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timeButtonTapped
void Loading::timeButtonTapped(CCObject*object)
{
//if(s_isStorePopupActive)return;
AudioManager::PlayEffect(AUDIO_SELECT);
if(g_SlowClock || SaveLoad::m_SaveData.numTimeSlow)
{
if(g_SlowClock)
{
CCMenuItemImage *item = ((CCMenuItemImage*)object);
item->removeChildByTag(10,true);
SaveLoad::m_SaveData.numTimeSlow++;
SaveLoad::Save();
g_SlowClock = false;
}
else
{
SaveLoad::m_SaveData.numTimeSlow--;
SaveLoad::Save();
g_SlowClock = true;
CCMenuItemImage *item = ((CCMenuItemImage*)object);
CCSprite *checkMark = CCSprite::createWithSpriteFrameName("ctm_Loading_SelectedGreenTick.png");
checkMark->setPosition(ccp(227.0f,22.0f));
item->addChild(checkMark,0,10);
}
}
else
{
//[self addChild:[StorePopup node]];
}
}
示例2: createPauseLayer
void GameLayer::createPauseLayer() {
Context *context = Context::sharedContext();
CCSize s = CCDirector::sharedDirector()->getWinSize();
/* 半透明层 */
CCLayerColor* pauseLayer = CCLayerColor::create();
pauseLayer->setContentSize(CCSizeMake(s.width, s.height));
pauseLayer->setColor(ccc3(0, 0, 0));
pauseLayer->setOpacity(150);
CCMenu *menu = CCMenu::create();
//回到游戏
CCMenuItemImage *resumebg = CCMenuItemImage::create(("btn_big.png"),
("btn_big.png"));
resumebg->setTarget(this, menu_selector(GameLayer::onResumeItem));
CCMenuItemFont *resumetxt = CCMenuItemFont::create(LOCAL_RESOURCES->valueByKey("i18n_resume")->getCString());
resumebg->setAnchorPoint(ccp(0.5, 0.5));
resumebg->setPosition(ccpp(0, 0));
resumetxt->setPosition(
ccp(resumebg->getContentSize().width / 2,
resumebg->getContentSize().height / 2));
resumetxt->setAnchorPoint(ccp(0.5, 0.5));
resumetxt->setColor(context->getFontColor());
resumebg->addChild(resumetxt);
menu->addChild(resumebg);
//回到菜单
CCMenuItemImage *backbg = CCMenuItemImage::create(("btn_big.png"),
("btn_big.png"));
backbg->setTarget(this, menu_selector(GameLayer::onBackItem));
CCMenuItemFont *backtxt = CCMenuItemFont::create(LOCAL_RESOURCES->valueByKey("i18n_back")->getCString());
backbg->setAnchorPoint(ccp(0.5, 0.5));
backbg->setPosition(ccpp(0, -0.12));
backtxt->setPosition(
ccp(backbg->getContentSize().width / 2,
backbg->getContentSize().height / 2));
backtxt->setAnchorPoint(ccp(0.5, 0.5));
backtxt->setColor(context->getFontColor());
backbg->addChild(backtxt);
menu->addChild(backbg);
pauseLayer->addChild(menu);
CCDirector::sharedDirector()->getRunningScene()->addChild(pauseLayer, 0,
TAG_LAYER_PAUSE);
}
示例3: showStartInfo
void MainGameScene::showStartInfo()
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCMenuItemImage* pStartItem;
pStartItem = CCMenuItemImage::create("logo_Info2.png", "logo_Info2.png",this,menu_selector(MainGameScene::startGame));
pStartItem->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
pStartItem->setScale(0.7);
CCSize pStartItemSize = pStartItem->getContentSize();
CCLabelTTF* startLabel1;
startLabel1 = CCLabelTTF::create("Let's Arrows", "Copperplate", 60.0);
startLabel1->setColor(ccc3(0, 0, 0));
startLabel1->setPosition(ccp(pStartItemSize.width * 0.5 ,pStartItemSize.height * 0.7));
pStartItem->addChild(startLabel1);
CCString* levelStr = CCString::createWithFormat("Lv:%d",m_level);
CCLabelTTF* levelLabel;
levelLabel = CCLabelTTF::create(levelStr->getCString(), "Copperplate", 60.0);
levelLabel->setColor(ccc3(0, 0, 0));
levelLabel->setPosition(ccp(pStartItemSize.width * 0.5 ,pStartItemSize.height * 0.5));
pStartItem->addChild(levelLabel);
CCString* minCountString = CCString::createWithFormat("MIN %d TOUCH",minimamCount);
CCLabelTTF* startLabel2;
startLabel2 = CCLabelTTF::create(minCountString->getCString(), "Copperplate", 50.0);
startLabel2->setColor(ccc3(0, 0, 0));
startLabel2->setPosition(ccp(pStartItemSize.width * 0.5 ,pStartItemSize.height * 0.2));
pStartItem->addChild(startLabel2);
CCMenu* pMenu = CCMenu::create(pStartItem,NULL);
pMenu->setPosition(CCPointZero);
pMenu->setTag(tagStartInfo);
this->addChild(pMenu);
}
示例4: addButton
bool PopupLayer::addButton(const char *normalImage, const char *selectedImage, const char *title, int tag){
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCPoint pCenter = ccp(winSize.width / 2, winSize.height / 2);
CCMenuItemImage* menuImage = CCMenuItemImage::create(normalImage, selectedImage, this, menu_selector(PopupLayer::buttonCallback));
menuImage->setTag(tag);
menuImage->setPosition(pCenter);
CCSize imenu = menuImage->getContentSize();
CCLabelTTF* ttf = CCLabelTTF::create(title, "", 20);
ttf->setColor(ccc3(0, 0, 0));
ttf->setPosition(ccp(imenu.width / 2, imenu.height / 2));
menuImage->addChild(ttf);
getMenuButton()->addChild(menuImage);
return true;
}
示例5:
CCLayer * GameLayer::createPauseButtonLayer() {
CCMenu *layer = CCMenu::create();
//暂停
CCMenuItemImage *pausebg = CCMenuItemImage::create(("btn_small.png"),
("btn_small.png"));
CCSprite *pausetxt = CCSprite::create("btn_pause.png");
pausebg->setTarget(this, menu_selector(GameLayer::onPauseItem));
pausebg->setAnchorPoint(ccp(0, 0.5));
pausebg->setPosition(ccpp(-0.49, 0.42));
pausetxt->setPosition(
ccp(pausebg->getContentSize().width / 2,
pausebg->getContentSize().height / 2));
pausetxt->setAnchorPoint(ccp(0.5, 0.5));
pausebg->addChild(pausetxt);
layer->addChild(pausebg);
return layer;
}
示例6: addButton
bool ModelDialog::addButton(const char *normalImage, const char *selectedImage, const char *title, const float xPosition , const float yPosition, int tag ){
CCPoint position = ccp(xPosition, yPosition);
CCMenuItemImage* menuImage = CCMenuItemImage::create(normalImage, selectedImage, this, menu_selector(ModelDialog::buttonCallback));
menuImage->setTag(tag);
menuImage->setPosition(position);
CCSize imenu = menuImage->getContentSize();
CCLabelTTF* ttf = CCLabelTTF::create(title, "", 20);
ttf->setColor(ccc3(0, 0, 0));
ttf->setPosition(ccp(imenu.width / 2, imenu.height / 2));
menuImage->addChild(ttf);
mButtonArray->addObject(menuImage);
return true;
}
示例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: init
bool MainMenu::init()
{
bool bRet = false;
if(CCLayer::init())
{
CCSize size = CCDirector::sharedDirector()->getWinSize();
hiScore = getHightScore();
crystals = getCrystals();
CCSprite* scoreBar = CCSprite::create("Menu/scoreBar.png");
scoreBar->setPosition(ccp(size.width,size.height));
scoreBar->setAnchorPoint(ccp(1,1));
this->addChild(scoreBar,10);
CCSprite* logo = CCSprite::create("logo.png");
logo->setAnchorPoint(ccp(0,1));
logo->setPosition(ccp(0,size.height));
this->addChild(logo,5);
CCString* hiScoreStr = CCString::createWithFormat("HIGHT SCORE : %d",hiScore);
scoreT = CCLabelTTF::create(hiScoreStr->getCString(),"",20.0f);
scoreT->setHorizontalAlignment(kCCTextAlignmentCenter);
scoreT->setAnchorPoint(ccp(0.5,0.0));
scoreT->setColor(ccc3(0,255,255));
scoreT->setPosition(ccp(300,142));
scoreBar->addChild(scoreT);
menusLayer = CCLayer::create();
this->addChild(menusLayer,1);
mmL = CCLayer::create();
mmL->setPosition(0,0);
mmL->setScale(0.5f);
mmL->runAction(
CCScaleTo::create(0.5f,1.0f)
);
//moveMenuToNode(mmL);
menusLayer->addChild(mmL,2);
CCSprite* bgM = CCSprite::create("Menu/tabled.png");
bgM->setPosition(CCPointZero);
bgM->setAnchorPoint(CCPointZero);
mmL->addChild(bgM);
omL = CCLayer::create();
omL->setPosition(-1024,0);
omL->setScale(0.5);
menusLayer->addChild(omL,2);
CCSprite* bgO = CCSprite::create("Menu/tabled.png");
bgO->setPosition(CCPointZero);
bgO->setAnchorPoint(CCPointZero);
omL->addChild(bgO);
gmL = CCLayer::create();
gmL->setPosition(1024,0);
gmL->setScale(0.5);
menusLayer->addChild(gmL,2);
CCSprite* bgG = CCSprite::create("Menu/tabled.png");
bgG->setPosition(CCPointZero);
bgG->setAnchorPoint(CCPointZero);
gmL->addChild(bgG);
CCMenuItemImage* ngB = CCMenuItemImage::create(
"Menu/button_normal.png",
"Menu/button_pushed.png",
this,
menu_selector(MainMenu::newGameClicked)
);
CCLabelTTF* ngL = CCLabelTTF::create("NEW GAME","",40.0f);
ngL->setPosition(ccp(200,110));
ngL->setAnchorPoint(ccp(0.5,0.5));
ngL->setHorizontalAlignment(kCCTextAlignmentCenter);
//ngL->setColor(ccc3(119,207,7));
ngB->addChild(ngL);
CCMenuItemImage* opB = CCMenuItemImage::create(
"Menu/button_normal.png",
"Menu/button_pushed.png",
this,
menu_selector(MainMenu::optionsClicked)
);
CCLabelTTF* opL = CCLabelTTF::create("OPTIONS","",40.0f);
opL->setPosition(ccp(200,110));
opL->setAnchorPoint(ccp(0.5,0.5));
opL->setHorizontalAlignment(kCCTextAlignmentCenter);
//opL->setColor(ccc3(119,207,7));
opB->addChild(opL);
CCMenuItemImage* exB = CCMenuItemImage::create(
"Menu/button_normal.png",
"Menu/button_pushed.png",
this,
menu_selector(MainMenu::exitClick)
);
CCLabelTTF* exL = CCLabelTTF::create("EXIT","",40.0f);
exL->setPosition(ccp(200,110));
exL->setAnchorPoint(ccp(0.5,0.5));
exL->setHorizontalAlignment(kCCTextAlignmentCenter);
//exL->setColor(ccc3(119,207,7));
exB->addChild(exL);
ngB->setPosition(size.width/2,350);
opB->setPosition(size.width/2,220);
exB->setPosition(size.width/2,90);
//.........这里部分代码省略.........
示例9: init
bool TitleScene::init()
{
//debug
this->debugBoot = false;
// 初期化色を変更
if (!CCLayerColor::initWithColor(ccc4(0xFF,0xEF,0xFF,0xFF))) //RGBA
{
return false;
}
//GameCenterにログイン
Cocos2dExt::NativeCodeLauncher::loginGameCenter();
//一回もクリアしたことなければチュートリアル表示
CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
string tutorialKey = ConstCommon::getTutorialKey();
this->firstTimeGame = ! userDefault->getBoolForKey(tutorialKey.c_str());
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCSprite* pA = CCSprite::create("logo_A.png");
float originSize = ((size.width * 0.937) / 6) / pA->getContentSize().width;
pA->setPosition(ccp(size.width * 0.1, size.height * 0.8));
//pA->setScale(0.6);
pA->setScale(originSize);
pA->runAction(Animation::titleCharaAction(originSize));
this->addChild(pA);
CCSprite* pR = CCSprite::create("logo_R.png");
pR->setPosition(ccp(size.width * 0.26, size.height * 0.8));
//pR->setScale(0.6);
pR->setScale(originSize);
pR->runAction(CCSequence::create(CCDelayTime::create(0.05),Animation::titleCharaAction(originSize),NULL));
this->addChild(pR);
CCSprite* pR2 = CCSprite::create("logo_R.png");
pR2->setPosition(ccp(size.width * 0.42, size.height * 0.8));
//pR2->setScale(0.6);
pR2->setScale(originSize);
pR2->runAction(CCSequence::create(CCDelayTime::create(0.1),Animation::titleCharaAction(originSize),NULL));
this->addChild(pR2);
CCSprite* pO = CCSprite::create("logo_O.png");
pO->setPosition(ccp(size.width * 0.58, size.height * 0.8));
//pO->setScale(0.6);
pO->setScale(originSize);
pO->runAction(CCSequence::create(CCDelayTime::create(0.15),Animation::titleCharaAction(originSize),NULL));
this->addChild(pO);
CCSprite* pW = CCSprite::create("logo_W.png");
pW->setPosition(ccp(size.width * 0.74, size.height * 0.8));
//pW->setScale(0.6);
pW->setScale(originSize);
pW->runAction(CCSequence::create(CCDelayTime::create(0.2),Animation::titleCharaAction(originSize),NULL));
this->addChild(pW);
CCSprite* pS = CCSprite::create("logo_S.png");
pS->setPosition(ccp(size.width * 0.9, size.height * 0.8));
//pS->setScale(0.6);
pS->setScale(originSize);
pS->runAction(CCSequence::create(CCDelayTime::create(0.25),Animation::titleCharaAction(originSize),NULL));
this->addChild(pS);
//start button
CCMenuItemImage* pStartItem;
pStartItem = CCMenuItemImage::create("button1.png", "button1.png",this,menu_selector(TitleScene::menuStartCallback));
pStartItem->setPosition(ccp(size.width * 0.5, size.height * 0.3));
pStartItem->setScale((size.width * 0.4) / pStartItem->getContentSize().width);
CCLabelTTF* startLabel;
startLabel = CCLabelTTF::create("PLAY", "Arial", 30.0);
CCSize pStartItemSize = pStartItem->getContentSize();
startLabel->setPosition(ccp(pStartItemSize.width / 2 ,pStartItemSize.height / 2));
pStartItem->addChild(startLabel);
CCMenu* pMenu = CCMenu::create(pStartItem,NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu);
if(! this->firstTimeGame){
//チュートリアルを再度受けられるようにボタン生成
//start button
CCMenuItemImage* pTutorItem;
pTutorItem = CCMenuItemImage::create("button2.png", "button2.png",this,menu_selector(TitleScene::menuTutorCallback));
pTutorItem->setPosition(ccp(size.width * 0.5, size.height * 0.4));
pTutorItem->setScale((size.width * 0.4) / pTutorItem->getContentSize().width);
CCLabelTTF* tutorLabel;
//.........这里部分代码省略.........
示例10:
CCMenuItemImage* Objects2dFactory::textButton(CCNode* scene, CCMenu* menu, string value, string normalImagePath, string selectedImagePath, string disabledImagePath,
float positionX, float positionY, float width, float height, SEL_MenuHandler selector, void* selectorArg, AlignX alignX, AlignY alignY, ccColor3B textColor, int zOrder)
{
// Check arguments validity
if(scene == NULL ||menu == NULL || !selector)
return NULL;
// Create a button menu item
CCMenuItemImage *button = CCMenuItemImage::create(
normalImagePath.c_str(),
selectedImagePath.c_str(),
disabledImagePath.c_str(),
scene,
selector);
if(!button)
return NULL;
if (selectorArg != NULL)
{
button->setUserData(selectorArg);
}
// Place the menu item in the given position
button->setPosition(ccp(positionX, positionY));
// Set menu item anchor
button->setAnchorPoint(ccp(Constants::getAnchorValue(alignX), Constants::getAnchorValue(alignY)));
// Set menu item height
float buttonHeight = button->boundingBox().size.height;
float buttonPosScaleHeight = buttonHeight;
if (height > 0) // if height is defined, it is setted
{
button->setScaleY(height / buttonHeight);
buttonPosScaleHeight = height;
}
// Create a label and initialize with the given string
CCLabelTTF* pLabel = CCLabelTTF::create(value.c_str(), "Arial"/*string(Constants::getResourcesPath() + "SOResources/Fonts/AlphaFridgeMagnetsAllCap.ttf").c_str()*/,
buttonPosScaleHeight * 0.6f);
if(!pLabel)
return NULL;
// Set color
pLabel->setColor(textColor);
// Set menu item width
float buttonWidth = button->boundingBox().size.width;
float buttonPosScaleWidth = buttonWidth;
if (width > 0) // if width is defined, it is setted
{
button->setScaleX(width / buttonWidth);
buttonPosScaleWidth = width;
}
else // otherwise, we will compare the text width with the button width
{
float textWidth = pLabel->boundingBox().size.width;
if (textWidth * 1.25 > buttonWidth) // if the width adapted to the text is bigger than the button width, adapted width must be setted, otherwise, button width must stay as it was
{
button->setScaleX(textWidth * 1.25f / buttonWidth);
buttonPosScaleWidth = textWidth * 1.25f;
}
}
// Place the label; must be in the center of the button
pLabel->setPosition(ccp(buttonPosScaleWidth * 0.5f * 1/button->getScaleX(), buttonPosScaleHeight * 0.5f * 1/button->getScaleY()));
// Set label centered anchor
pLabel->setAnchorPoint(ccp(Constants::getAnchorValue(Centered), Constants::getAnchorValue(Middle)));
// Add label to button
button->addChild(pLabel);
// Set label scale; the inverse of button scale, so label can be as it would be if it was a child of scene
pLabel->setScaleY(1/button->getScaleY());
pLabel->setScaleX(1/button->getScaleX());
// If label is larger than button
if (pLabel->boundingBox().size.width * button->getScaleX() > button->boundingBox().size.width)
{
// Label must be rescaled
float newScale = button->boundingBox().size.width / (pLabel->boundingBox().size.width * button->getScaleX());
pLabel->setScaleX(pLabel->getScaleX() * newScale);
}
// Add button to the menu
menu->addChild(button, zOrder);
return button;
}
示例11: createLevelImage
CCMenuItemImage* LevelSelectScene::createLevelImage(int level)
{
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCString* levelString = CCString::createWithFormat("%d",level);
//bestScoreも初期化
CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
highScoreKey = ConstCommon::getHighScoreKey(level);
best_score[level-1] = userDefault->getFloatForKey(highScoreKey.c_str(),99);
//minScoreも初期化
CCString* jsonFileName = CCString::createWithFormat("Lv%d.json",level);
GameData* gm = new GameData(jsonFileName->getCString());
min_score[level-1] = gm->getMinScore();
int rank;
if(min_score[level-1] >= best_score[level-1]){
rank = 3;
}else if( min_score[level-1] <= best_score[level-1] + 8){
rank = 2;
}else{
rank = 1;
}
int fileNum = ((level - 1) / 3) + 1;
if(fileNum > 5){
fileNum = fileNum - (( fileNum / 5) * 5) + 1;
}
CCString* filePathName = CCString::createWithFormat("level_circle_%d.png",fileNum);
CCMenuItemImage* pLevel;
pLevel = CCMenuItemImage::create(filePathName->getCString(), filePathName->getCString(),this,menu_selector(LevelSelectScene::menuStartCallback));
pLevel->setScale(0.25);
pLevel->setScale( ((size.width * 0.585) / 3) / pLevel->getContentSize().width );
int posLevel = level - (15 * ((level - 1) / 15));
pLevel->setPosition(ccp(
size.width * (((((posLevel - 1) % 3) + 1) * 0.3) - 0.1),
size.height * (0.9 - (((posLevel - 1) / 3 ) * 0.128)) - 70
));
CCSize pLevelSize = pLevel->getContentSize();
if(best_score[level-1] != 99){
for (int i=0; i < rank; i++) {
CCSprite* pStar = CCSprite::create("level_star.png");
if(i == 0){
pStar->setPosition(ccp(pLevelSize.width * 0.5 - pStar->getContentSize().width, pLevelSize.height * 0.75));
}else if(i == 1){
pStar->setPosition(ccp(pLevelSize.width * 0.5, pLevelSize.height * 0.75));
}else{
pStar->setPosition(ccp(pLevelSize.width * 0.5 + pStar->getContentSize().width, pLevelSize.height * 0.75));
}
pLevel->addChild(pStar);
}
}
CCLabelTTF* levelLabel;
levelLabel = CCLabelTTF::create(levelString->getCString(), "Arial", 150.0);
levelLabel->setColor(ccc3(0x00,0x00,0x00));
levelLabel->setPosition(ccp(pLevelSize.width / 2 ,pLevelSize.height / 2));
pLevel->addChild(levelLabel);
pLevel->setTag(level);
return pLevel;
}
示例12: makeResumeDaialog
void MainGameScene::makeResumeDaialog()
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
//CCSpriteで作ると、タッチ判定無効とかめんどくさいからBGもMenuItemで作る
CCMenuItemImage* resumeBG = CCMenuItemImage::create("logo_Info2.png","logo_Info2.png");
resumeBG->setScale(0.7);
resumeBG->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
resumeBG->setEnabled(false);
CCSize pResumeBGSize = resumeBG->getContentSize();
CCLabelTTF* resumeLabel;
resumeLabel = CCLabelTTF::create(NKLocalizedString::LocalizedString("resume", "RESUME"), "Copperplate", 60.0);
resumeLabel->setColor(ccc3(0, 0, 0));
resumeLabel->setPosition(ccp(pResumeBGSize.width * 0.5 ,pResumeBGSize.height * 0.7));
resumeBG->addChild(resumeLabel);
CCMenuItemImage* titleItem = CCMenuItemImage::create("button1.png","button1.png" ,this, menu_selector(MainGameScene::tapTitleButton));
titleItem->setPosition(ccp(winSize.width * 0.3, winSize.height * 0.47));
CCLabelTTF* titleLabel;
titleLabel = CCLabelTTF::create("TITLE", "Arial", 30.0);
CCSize pTitleItemSize = titleItem->getContentSize();
titleLabel->setPosition(ccp(pTitleItemSize.width / 2 ,pTitleItemSize.height / 2));
titleItem->addChild(titleLabel);
titleItem->setScale(0.8);
CCMenuItemImage* returnGameItem = CCMenuItemImage::create("button2.png","button2.png" ,this, menu_selector(MainGameScene::returnMainGame));
returnGameItem->setPosition(ccp(winSize.width * 0.7, winSize.height * 0.47));
CCLabelTTF* returnGameLabel;
returnGameLabel = CCLabelTTF::create("CANCEL", "Arial", 30.0);
CCSize pReturnGameSize = returnGameItem->getContentSize();
returnGameLabel->setPosition(ccp(pReturnGameSize.width / 2 ,pReturnGameSize.height / 2));
returnGameItem->addChild(returnGameLabel);
returnGameItem->setScale(0.8);
CCMenuItemImage* retryGameItem = CCMenuItemImage::create("button3.png","button3.png" ,this, menu_selector(MainGameScene::doRetry));
retryGameItem->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.39));
CCLabelTTF* retryGameLabel;
retryGameLabel = CCLabelTTF::create("RETRY", "Arial", 30.0);
CCSize pRetryGameSize = retryGameItem->getContentSize();
retryGameLabel->setPosition(ccp(pRetryGameSize.width / 2 ,pRetryGameSize.height / 2));
retryGameItem->addChild(retryGameLabel);
retryGameItem->setScale(0.8);
CCMenu* resumeDialog = CCMenu::create(resumeBG, titleItem, returnGameItem,retryGameItem,NULL);
resumeDialog->setPosition(CCPointZero);
resumeDialog->setTag(tagResumeDialog);
resumeDialog->setOpacity(0);
resumeDialog->setZOrder(Z_ORDER_RESUME_DIALOG);
resumeDialog->setEnabled(false);
this->addChild(resumeDialog);
}
示例13:
TanSuoLayer::TanSuoLayer()
{
m_nFontSize = 24;
m_nMaxCountDestroy = 3;
m_bIsJieFeng = false;
m_nSelectProId = -1;
mBg = BaseSprite::create("xunbao_bg.png");
addChild(mBg);
mBg->setPosition(ccp(mWinSize.width/2, mBg->getContentSize().height/2));
mMainMenu = CCMenu::create();
mBg->addChild(mMainMenu, 10);
mMainMenu->setPosition(ccp(0,0));
CCMenuItemImage *yijian = CCMenuItemImage::create(
"xunbao_anniu_yijianxunbao.png",
"xunbao_anniu_yijianxunbao_select.png",
this, menu_selector(TanSuoLayer::menuItemClicked_TanSuo));
mMainMenu->addChild(yijian, 0, Tag_MenuItem_YiJianTanSuo);
yijian->setPosition(ccp(548,mBg->getContentSize().height-674));
Button *tansuo = Button::create();
tansuo->loadTextures("xunbao_anniu_xunbao.png","xunbao_anniu_xunbao_select.png","xunbao_anniu_xunbao_select.png",UI_TEX_TYPE_LOCAL);
/*CCMenuItemImage *tansuo = CCMenuItemImage::create(
"xunbao_anniu_xunbao.png",
"xunbao_anniu_xunbao_select.png",
this, menu_selector(TanSuoLayer::menuItemClicked_TanSuo));*/
tansuo->addTouchEventListener(this,SEL_TouchEvent(&TanSuoLayer::clickXunBao));
UILayer* layer = UILayer::create();
layer->ignoreAnchorPointForPosition(false);
layer->setContentSize(tansuo->getContentSize());
layer->setAnchorPoint(ccp(0.5,0.5));
layer->addWidget(tansuo);
layer->setPosition(320,mBg->getContentSize().height-674);//以前cpp(x,y) 现在左边 都是Point 比如颜色 ccWHITE 也改成了Color3B::WHITE
mBg->addChild(layer);
tansuo->setPosition(ccp(tansuo->getContentSize().width / 2 , tansuo->getContentSize().height / 2));
m_sXunBaoSpr = CCSprite::create("xunbao_anniu_xunbao_xiaoguo.png");
m_sXunBaoSpr->setPosition(ccp(320,mBg->getContentSize().height-674));
mBg->addChild(m_sXunBaoSpr);
m_sXunBaoSpr->runAction(CCRepeatForever::create(CCSequence::create(CCFadeOut::create(1.0f),CCFadeIn::create(1.0f),NULL)));
//mMainMenu->addChild(tansuo, 0, Tag_MenuItem_TanSuo);
//tansuo->setPosition(ccp(320,mBg->getContentSize().height-674));
{
CCMenuItemImage *jiefen = CCMenuItemImage::create(
"xunbao_anniu_jiechufengyin.png",
"xunbao_anniu_jiechufengyin_select.png",
this, menu_selector(TanSuoLayer::menuItemClicked_TanSuo));
mMainMenu->addChild(jiefen, 0, Tag_MenuItem_JieFen);
jiefen->setPosition(ccp(320,mBg->getContentSize().height-437));
jiefen->setVisible(false);
CCSprite *img = CCSprite::create("xunbao_anniu_jiechufengyin_xiaoguo.png");
jiefen->addChild(img);
img->setPosition(ccp(jiefen->getContentSize().width/2, jiefen->getContentSize().height/2));
img->runAction(CCRepeatForever::create(CCSequence::create(
CCFadeTo::create(1, 50), CCFadeTo::create(1, 255), NULL)));
}
mMainMenu->setVisible(false);
//title
CCLabelTTF *tilte = CCLabelTTF::create(LFStrings::getValue("XunBaoShuoMing").c_str(), fontStr_kaiti, m_nFontSize);
mBg->addChild(tilte);
tilte->setColor(fonColor_PuTong);
tilte->setPosition(ccp(mBg->getContentSize().width/2, mBg->getContentSize().height-110));
//2
CCLabelTTF *la1 = CCLabelTTF::create(LFStrings::getValue("XunBaoJieFeng").c_str(), fontStr_kaiti, m_nFontSize);
mBg->addChild(la1);
la1->setAnchorPoint(ccp(0, 0.5));
la1->setColor(fonColor_CiYao);
la1->setPosition(ccp(134, mBg->getContentSize().height-140));
CCLabelTTF *la2 = CCLabelTTF::create((LFStrings::getValue("shenbing")+LFStrings::getValue("zhuangbei")).c_str()
, fontStr_kaiti, m_nFontSize);
la1->addChild(la2);
la2->setColor(ImageManager::getManager()->getShowColor(ZhuangbeiColour_Chuanqi, false, false));
la2->setPosition(ccp(la1->getContentSize().width+la2->getContentSize().width/2, la1->getContentSize().height/2));
la1->setPositionX((mBg->getContentSize().width-la1->getContentSize().width-la2->getContentSize().width)/2);
}
示例14: setSystemMail
void MailInfoListLayer::setSystemMail(Email mail)
{
//CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,-132,true);
ListMenu *menu = ListMenu::create();
menu->setPosition(CCPointZero);
menu->setAnchorPoint(CCPointZero);
menu->setContentSize(this->getContentSize());
addChild(menu);
m_mMenu = menu;
//m_mMenu->runAction(CCCallFuncND::create(this, callfuncND_selector(MailInfoListLayer::changeMenuPriority_callfuncND), (void*)(-133)));
m_eEmail = mail;
sortMail(mail);
int count = 0;
int height = m_nHeight;
int width = count * 100;
m_nWidth = width;
count = 0;
int side = 50;
int bWidth = 0;
int _width = 0;
int pos_x = 0;
for (map<string,string>::iterator iter = m_lThingsList.begin(); iter != m_lThingsList.end() ; iter ++)
{
CCSprite *cailiaoSpr = CCSprite::create("daoju_kuang_bg.png");
cailiaoSpr->setScale(0.7f);
bWidth = cailiaoSpr->getContentSize().width * cailiaoSpr->getScaleX();
cailiaoSpr->setPosition(ccp(count * bWidth + ( side * ( count * 2 + 1 ) ) + bWidth / 2 ,height - cailiaoSpr->getContentSize().height * cailiaoSpr->getScaleY() / 2 - 5));
addChild(cailiaoSpr);
CCSprite *daojuSpr = CCSprite::create(iter->first.c_str());
daojuSpr->setScale(0.7f);
bWidth = daojuSpr->getContentSize().width * cailiaoSpr->getScaleX();
daojuSpr->setPosition(ccp(cailiaoSpr->getContentSize().width / 2, cailiaoSpr->getContentSize().height / 2));
cailiaoSpr->addChild(daojuSpr);
CCLabelTTF *nameTTF = CCLabelTTF::create(iter->second.c_str(),fontStr_kaiti,25.0f);
nameTTF->setPosition(ccp(cailiaoSpr->getPositionX(),nameTTF->getContentSize().height / 2 + 5));
addChild(nameTTF);
nameTTF->setColor(ccWHITE);
_width += cailiaoSpr->getPositionX() - pos_x;
pos_x = cailiaoSpr->getPositionX();
count ++;
}
_width += bWidth / 2 + side;
for (vector<Flat_DuanzaoGroupZBInfo>::iterator iter = mail.equipVec.begin(); iter != mail.equipVec.end() ; iter ++)
{
CCLabelTTF *nameTTF = CCLabelTTF::create(iter->zhuangbei_name.c_str(),fontStr_kaiti,25.0f);
nameTTF->setPosition(ccp(count * bWidth + ( side * ( count * 2 + 1 ) ) + bWidth / 2 + nameTTF->getContentSize().height / 2 ,nameTTF->getContentSize().height / 2 + 20));
addChild(nameTTF);
nameTTF->setColor(ccWHITE);
//string nameTemp = CS::getItemName(iter->zb_group_id) + LFStrings::getValue("zhi") + LFStrings::getValue("suipian") + getStrByInt(iter->suipian_id);
string equipfile = iter->zhuangbei_pic;
equipfile = "minute_" + equipfile + ".png";
m_lThingsList.insert(map<string,string>::value_type(equipfile,iter->zhuangbei_name));
string diwenStr = ImageManager::getManager()->getImageData_DiWen_WithBianKuang(iter->zhuangbei_colour);
CCMenuItemImage *eqDiwenImg = CCMenuItemImage::create(diwenStr.c_str(), diwenStr.c_str(), this,
menu_selector(MailInfoListLayer::menuItemClicked_Equip));
m_mMenu->addChild(eqDiwenImg);
eqDiwenImg->setTag(iter->zb_group_id);
eqDiwenImg->setScale(0.8f);
bWidth = eqDiwenImg->getContentSize().width * eqDiwenImg->getScaleX();
eqDiwenImg->setPosition(ccp( nameTTF->getPositionX(),nameTTF->getPositionY() + nameTTF->getContentSize().height / 2 + eqDiwenImg->getContentSize().height / 2 + 5));
CCSprite *daojuSpr = CCSprite::create(equipfile.c_str());
daojuSpr->setScale(0.24f);
bWidth = daojuSpr->getContentSize().width * eqDiwenImg->getScaleX();
daojuSpr->setPosition(ccp(eqDiwenImg->getContentSize().width / 2, eqDiwenImg->getContentSize().height / 2));
eqDiwenImg->addChild(daojuSpr);
/*CCSprite *cailiaoSpr = CCSprite::create("daoju_kuang_bg.png");
cailiaoSpr->setScale(0.7f);
bWidth = cailiaoSpr->getContentSize().width * cailiaoSpr->getScaleX();
cailiaoSpr->setPosition(ccp(count * bWidth + ( side * ( count * 2 + 1 ) ) + bWidth / 2 ,height - cailiaoSpr->getContentSize().height * cailiaoSpr->getScaleY() / 2 - 5));
addChild(cailiaoSpr);*/
_width += eqDiwenImg->getPositionX() - pos_x;
pos_x = eqDiwenImg->getPositionX();
count ++;
}
_width += bWidth / 2 + side;
m_nWidth = _width;
this->setContentSize(CCSizeMake(m_nWidth,m_nHeight));
}
示例15: 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;
}
}