本文整理汇总了C++中CCMenu::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenu::setScale方法的具体用法?C++ CCMenu::setScale怎么用?C++ CCMenu::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenu
的用法示例。
在下文中一共展示了CCMenu::setScale方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setover
void GameMain::setover() {
CCMenu* pMenu = (CCMenu *)this->getChildByTag(25);
pMenu->setVisible(true);
pMenu->setEnabled(true);
gameover->setVisible(true);
gameover->setScale(0);
pMenu->setScale(0);
pMenu->runAction(CCScaleTo::create(0.5,1));
gameover->runAction(CCScaleTo::create(0.5,0.5));
isover = true;
}
示例2: setOver
void GameMainLayer::setOver()
{
//游戏结束
CCMenu *pMenu = (CCMenu *)this->getChildByTag(25);
pMenu->setVisible(true);
pMenu->setEnabled(true);
pMenu->setScale(0);
pMenu->runAction(CCScaleTo::create(0.5f, 1));
gameOver->setVisible(true);
gameOver->setScale(0);
gameOver->runAction(CCScaleTo::create(0.5f, 0.5f));
this->isOver = true;
}
示例3: init
bool UserInputScene::init()
{
if (!CCLayer::init())
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();
cache->addSpriteFramesWithFile("welcome.plist","welcome.png");
CCSprite* bgSprite = CCSprite::create("login_2.png");
bgSprite->setAnchorPoint(CCPointZero);
bgSprite->setPosition(ccp(origin.x,origin.y));
this->addChild(bgSprite,9);
CCSprite* buttonSprite = CCSprite::create("start.png");
//buttonSprite->setAnchorPoint(CCPointZero);
//buttonSprite->setScale(0.5f);
//buttonSprite->setPosition(ccp(origin.x+visibleSize.width/2,origin.y));
//this->addChild(buttonSprite);
SEL_MenuHandler startSelect= (SEL_MenuHandler)menu_selector(UserInputScene::startGame);
CCMenuItemSprite* startMenu = CCMenuItemSprite::create(buttonSprite,
buttonSprite, buttonSprite, this,
startSelect );
CCMenu* menu = CCMenu::create(startMenu,NULL);
menu->setPosition(ccp(origin.x+visibleSize.width/2,origin.y));
menu->setScale(0.5f);
addChild(menu,10);
CCSize editBoxSize = CCSizeMake(visibleSize.width - 100, 60);
// top
m_pEditName = CCEditBox::create(editBoxSize, CCScale9Sprite::create("username.png"));
m_pEditName->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height*3/4));
m_pEditName->setFontSize(25);
m_pEditName->setFontColor(ccRED);
m_pEditName->setPlaceHolder("Name:");
m_pEditName->setPlaceholderFontColor(ccWHITE);
m_pEditName->setMaxLength(8);
m_pEditName->setReturnType(kKeyboardReturnTypeDone);
m_pEditName->setDelegate(this);
addChild(m_pEditName,10);
m_pEditPassword = CCEditBox::create(editBoxSize, CCScale9Sprite::create("username.png"));
m_pEditPassword->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));
m_pEditPassword->setFontColor(ccGREEN);
m_pEditPassword->setPlaceHolder("Password:");
m_pEditPassword->setMaxLength(6);
m_pEditPassword->setInputFlag(kEditBoxInputFlagPassword);
m_pEditPassword->setInputMode(kEditBoxInputModeSingleLine);
m_pEditPassword->setDelegate(this);
addChild(m_pEditPassword,10);
//////////////////////////////////////////////////////////////////////////
//UILayer* ul = UILayer::create();
//UILayout* widget = dynamic_cast<UILayout*>(GUIReader::shareReader()->widgetFromJsonFile("SelectSong1_1.json"));
//ul->addWidget(widget);
//Button* startBT = (Button*)ul->getWidgetByName("Button_28");
//startBT->addTouchEventListener(this,toucheventselector(UserInputScene::startGame));
//////////////////////////////////////////////////////////////////////////
return true;
}
示例4: onEnter
void GameScene::onEnter()
{
CCNode::onEnter();
// 把图片添加进全局的精灵框帧缓存中
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/flappy_frame.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/flappy_packer.plist");
// 获得窗体大小
CCSize winSize =CCDirector::sharedDirector()->getWinSize();
// 添加背景图片1被设置位置
CCSprite *bg= CCSprite::create("ui/bg.png");
bg->setAnchorPoint(ccp(0,0));
bg->setPosition(ccp(0,0));
bg->setScale(0.7);
this->addChild(bg);
// 添加背景图片2被设置位置
ground1 =CCSprite::create("ui/ground.png");
ground1->setAnchorPoint(ccp(0,0));
ground1->setPosition(ccp(0,0));
ground1->setScaleY(0.7);
ground1->setZOrder(10);
this->addChild(ground1);
// 添加ground
ground2 =CCSprite::create("ui/ground.png");
ground2->setAnchorPoint(ccp(0,0));
ground2->setPosition(ccp(winSize.width,0));
ground2->setZOrder(10);
ground2->setScaleY(0.7);
this->addChild(ground2);
// 添加FlappyBirdLogo
CCSprite *flappyBird =CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("flappybird.png"));
flappyBird->setPosition(ccp(winSize.width/2,winSize.height/4*3));
flappyBird->setScale(0.6);
flappyBird->setTag(TAG_LOGO);
this->addChild(flappyBird);
// 添加GameOver
CCSprite *gameOver=CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("gameover.png"));
gameOver->setPosition(ccp(winSize.width/2,winSize.height/4*3));
gameOver->setScale(0.6);
gameOver->setTag(TAG_OVER);
gameOver->setZOrder(10);
gameOver->setVisible(false);
this->addChild(gameOver);
// 添加GetReady精灵
CCSprite *getready =CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("getready.png"));
getready->setPosition(ccp(winSize.width/2,winSize.height/4*3-50));
getready->setScale(0.6);
getready->setTag(TAG_READY);
getready->setVisible(false);
this->addChild(getready);
// 添加开始按钮
CCSprite *normalStart =CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("start.png"));
CCSprite *pressStart =CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("start1.png"));
CCMenuItemImage* startBtn=CCMenuItemImage::create();
startBtn->initWithNormalSprite(normalStart,pressStart,NULL,this,menu_selector(GameScene::gameStart));
CCMenu *menuStart =CCMenu::create(startBtn,NULL);
menuStart->setPosition(ccp(winSize.width/16,ground1->boundingBox().size.height/2-30));
menuStart->setTag(TAG_START_BTN);
menuStart->setScale(0.6);
menuStart->setZOrder(10);
this->addChild(menuStart);
// 添加退出按钮
CCSprite *normalEnd =CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("grade.png"));
CCMenuItemImage *endBtn =CCMenuItemImage::create();
endBtn->initWithNormalSprite(normalEnd,normalEnd,NULL,this,menu_selector(GameScene::gameEnd));
CCMenu *menuEnd =CCMenu::create(endBtn,NULL);
menuEnd->setPosition(ccp(winSize.width/2,ground1->boundingBox().size.height/2-30));
menuEnd->setTag(Tage_End_BTN);
menuEnd->setScale(0.6);
menuEnd->setZOrder(10);
this->addChild(menuEnd);
// 添加click图片
CCSprite *click =CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("click.png"));
click->setPosition(ccp(winSize.width/2,winSize.height/2));
click->setScale(0.6);
click->setTag(TAG_CLICK);
click->setVisible(false);
this->addChild(click);
this->birdReadyAction();
// 添加Score
CCLabelBMFont *score=CCLabelBMFont::create("0","fonts/futura-48.fnt");
score->setPosition(ccp(winSize.width/2,winSize.height/4*3+60));
score->setTag(TAG_SCORE);
score->setVisible(false);
score->setZOrder(10);
this->addChild(score);
// 添加记录
CCSprite *record =CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("base.png"));
record->setPosition(ccp(winSize.width/2,winSize.height/2+30));
record->setScaleX(0.6);
record->setScaleY(0.6);
record->setTag(TAG_RECORD);
record->setVisible(false);
record->setZOrder(10);
this->addChild(record);
hose=Hose::create();
this->addChild(hose);
// 预加载音效
preloadMusic();
// 设置可触摸
this->setTouchEnabled(true);
//.........这里部分代码省略.........
示例5: menuStartCallback
void LevelSelectScene::menuStartCallback(CCObject *pSender)
{
CCMenu* levelSelectMenu = (CCMenu*)this->getChildByTag(tagLevelSelectMenuDialog);
if(levelSelectMenu){
levelSelectMenu->setOpacity(128);
levelSelectMenu->setEnabled(false);
}
CCMenuItemImage* targetLevelImage = (CCMenuItemImage*)pSender;
m_level = targetLevelImage->getTag();
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCMenuItemImage* startMenuBG = CCMenuItemImage::create("logo_Info2.png","logo_Info2.png");
startMenuBG->setScale(0.7);
startMenuBG->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
startMenuBG->setEnabled(false);
CCString* levelStr = CCString::createWithFormat("Lv:%d",m_level);
CCSize pStartBGSize = startMenuBG->getContentSize();
CCLabelTTF* levelLabel;
levelLabel = CCLabelTTF::create(levelStr->getCString(), "Copperplate", 60.0);
levelLabel->setColor(ccc3(0, 0, 0));
levelLabel->setPosition(ccp(pStartBGSize.width * 0.5 ,pStartBGSize.height * 0.75));
startMenuBG->addChild(levelLabel);
//ハイスコアを表示
CCString* bestStr = CCString::createWithFormat("MIN:%d BEST:%d",min_score[m_level-1],best_score[m_level-1]);
CCLabelTTF* bestLabel;
bestLabel = CCLabelTTF::create(bestStr->getCString(), "Copperplate", 60.0);
bestLabel->setColor(ccc3(0, 0, 0));
bestLabel->setPosition(ccp(pStartBGSize.width * 0.5 ,pStartBGSize.height * 0.5));
startMenuBG->addChild(bestLabel);
CCMenuItemImage* titleItem = CCMenuItemImage::create("button1.png","button1.png" ,this, menu_selector(LevelSelectScene::startGame));
titleItem->setPosition(ccp(winSize.width * 0.3, winSize.height * 0.42));
CCLabelTTF* titleLabel;
titleLabel = CCLabelTTF::create("START", "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(LevelSelectScene::hiddenStartMenu));
returnGameItem->setPosition(ccp(winSize.width * 0.7, winSize.height * 0.42));
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);
CCMenu* resumeDialog = CCMenu::create(startMenuBG, titleItem, returnGameItem, NULL);
resumeDialog->setPosition(CCPointZero);
resumeDialog->setTag(tagStartMenuDialog);
resumeDialog->setScale(winSize.width/640);
this->addChild(resumeDialog);
}
示例6: init
bool Level::init()
{
if (!CCLayer::init()) {
return false;
}
/*预加载音效*/
SimpleAudioEngine::sharedEngine()->preloadEffect("confirm.mp3");
/*添加背景*/
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCSprite* spBackGround = CCSprite::create("levelBackground.png");
spBackGround->setPosition(ccp(size.width*0.5, size.height*0.5));
addChild(spBackGround);
/*创建图片菜单项*/
CCMenuItemImage *item1 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel1));
CCMenuItemImage *item2 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel2));
CCMenuItemImage *item3 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel3));
CCMenuItemImage *item4 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel4));
CCMenuItemImage *item5 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel5));
/*创建返回菜单项*/
CCMenuItemImage *itemBack = CCMenuItemImage::create("display_back.png", "display_back.png", this, menu_selector(Level::backToMenu));;
/*设置菜单项大小*/
item1->setScale(0.45);
item2->setScale(0.45);
item3->setScale(0.45);
item4->setScale(0.45);
item5->setScale(0.45);
/*创建菜单*/
CCMenu* menu1 = CCMenu::create(item1, item2, item3, item4, item5, NULL);
menu1->setPosition(ccp(size.width * 0.5, size.height * 0.55));
menu1->alignItemsHorizontallyWithPadding(70);
CCMenu* menuBack = CCMenu::create(itemBack, NULL);
addChild(menuBack);
menuBack->setPosition(ccp(size.width * 0.36, size.height * 0.05));
menuBack->setScale(0.7);
menuBack->setColor(ccc3(0, 32, 240));
/*创建图片菜单项*/
CCMenuItemImage *item6 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel6));
CCMenuItemImage *item7 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel7));
CCMenuItemImage *item8 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel8));
CCMenuItemImage *item9 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel9));
CCMenuItemImage *item10 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel10));
/*设置菜单项大小*/
item6->setScale(0.45);
item7->setScale(0.45);
item8->setScale(0.45);
item9->setScale(0.45);
item10->setScale(0.45);
/*创建菜单*/
CCMenu* menu2 = CCMenu::create(item6, item7, item8, item9, item10, NULL);
menu2->setPosition(ccp(size.width * 1.5, size.height * 0.55));
menu2->alignItemsHorizontallyWithPadding(70);
/*-----------------------*/
/*创建图片菜单项*/
CCMenuItemImage *item11 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel11));
CCMenuItemImage *item12 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel12));
CCMenuItemImage *item13 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel13));
CCMenuItemImage *item14 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel14));
CCMenuItemImage *item15 = CCMenuItemImage::create("level_normal.png", "level_selected.png", this, menu_selector(Level::chooseLevel15));
/*设置菜单项大小*/
item11->setScale(0.45);
item12->setScale(0.45);
item13->setScale(0.45);
item14->setScale(0.45);
item15->setScale(0.45);
/*创建菜单*/
CCMenu* menu3 = CCMenu::create(item11, item12, item13, item14, item15, NULL);
menu3->setPosition(ccp(size.width * 2.5, size.height * 0.55));
menu3->alignItemsHorizontallyWithPadding(70);
/*添加关卡锁*/
lock2 = CCSprite::create("lock.png");
lock3 = CCSprite::create("lock.png");
lock4 = CCSprite::create("lock.png");
lock5 = CCSprite::create("lock.png");
lock6 = CCSprite::create("lock.png");
lock7 = CCSprite::create("lock.png");
lock8 = CCSprite::create("lock.png");
lock9 = CCSprite::create("lock.png");
lock10 = CCSprite::create("lock.png");
lock11 = CCSprite::create("lock.png");
lock12 = CCSprite::create("lock.png");
lock13 = CCSprite::create("lock.png");
lock14 = CCSprite::create("lock.png");
lock15 = CCSprite::create("lock.png");
item2->addChild(lock2);
//.........这里部分代码省略.........