本文整理汇总了C++中CCMenuItemLabel::runAction方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemLabel::runAction方法的具体用法?C++ CCMenuItemLabel::runAction怎么用?C++ CCMenuItemLabel::runAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemLabel
的用法示例。
在下文中一共展示了CCMenuItemLabel::runAction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool Options::init()
{
if (!CCLayer::init()) {
return false;
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCSprite *sp = CCSprite::create(s_loading);
sp->setAnchorPoint(CCPointZero);
addChild(sp, 0, 1);
CCTexture2D *imageCache = CCTextureCache::sharedTextureCache()->addImage(s_menuTitle);
CCSprite *title = CCSprite::createWithTexture(imageCache, CCRectMake(0, 0, 134, 34));
title->setPosition(ccp(winSize.width/2, winSize.height - 60));
addChild(title);
CCMenuItemFont *menuTitle = CCMenuItemFont::create("Sound");
menuTitle->setFontName("Arial");
menuTitle->setFontSize(18);
menuTitle->setEnabled(false);
CCMenuItemFont::setFontName("Arial");
CCMenuItemFont::setFontSize(26);
CCMenuItemToggle *toggle = CCMenuItemToggle::createWithTarget(this, menu_selector(Options::setOptions), CCMenuItemFont::create("On"),CCMenuItemFont::create("Off"), NULL);
int selectId = Config::sharedConfig()->getAudioState()? 0 : 1;
toggle->setSelectedIndex(selectId);
CCLabelBMFont *backLb = CCLabelBMFont::create("Go Back", s_font);
CCMenuItemLabel *goBack = CCMenuItemLabel::create(backLb, this, menu_selector(Options::goBack));
goBack->setScale(0.6);
CCActionInterval *fadeIn = CCFadeTo::create(1, 80);
CCActionInterval *fadeOut = CCFadeTo::create(1, 255);
CCEaseSineInOut *ease1 = CCEaseSineInOut::create(fadeIn);
CCEaseSineInOut *ease2 = CCEaseSineInOut::create(fadeOut);
CCFiniteTimeAction *seq = CCSequence::create(ease1, ease2, NULL);
// 这里也是,参数必须强转,否则NDK编译不过
goBack->runAction(CCRepeatForever::create((CCActionInterval*)seq));
CCMenu *menu = CCMenu::create( menuTitle, toggle, goBack, NULL);
menu->alignItemsInColumns(2,1);
addChild(menu);
CCPoint pos = goBack->getPosition();
pos.y -= 50;
goBack->setPosition(pos);
return true;
}
示例2: endScene
void HelloWorld::endScene( EndReason endReason ) {
if (_gameOver)
return;
_gameOver = true;
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
/*
char message[10] = "You Win";
if ( endReason == KENDREASONLOSE)
strcpy(message,"You Lose");
*/
char message[12] = { 0 };
sprintf(message, "Score: %d", _score);
CCLabelBMFont * label ;
label = CCLabelBMFont::create(message, "fonts/Arial.fnt");
label->setScale(0.1);
label->setPosition(ccp(winSize.width/2 , winSize.height*0.6));
this->addChild(label);
CCLabelBMFont * restartLabel;
strcpy(message,"Restart");
restartLabel = CCLabelBMFont::create(message, "fonts/Arial.fnt");
CCMenuItemLabel *restartItem = CCMenuItemLabel::create(restartLabel, this, menu_selector(HelloWorld::restartTapped) );
restartItem->setScale(0.1);
restartItem->setPosition( ccp(winSize.width/2, winSize.height*0.4));
CCMenu *menu = CCMenu::create(restartItem, NULL);
menu->setPosition(CCPointZero);
this->addChild(menu);
// clear label and menu
restartItem->runAction(CCScaleTo::create(0.5, 1.0));
label ->runAction(CCScaleTo::create(0.5, 1.0));
// Terminate update callback
this->unscheduleUpdate();
}
示例3: init
bool About::init()
{
if (!CCLayer::init()) {
return false;
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCSprite *sp = CCSprite::create(s_bg01);
sp->setPosition(ccp(winSize.width / 2, winSize.height / 2));
addChild(sp, 0, 1);
CCTexture2D *imageCache = CCTextureCache::sharedTextureCache()->addImage(s_menuTitle);
CCSprite *title = CCSprite::createWithTexture(imageCache, CCRectMake(0, 36, 100, 34));
title->setPosition(ccp(winSize.width/2, winSize.height - 60));
addChild(title);
CCLabelTTF *about = CCLabelTTF::create(" Thanks to cocos2d!", "Arial Bold", 32, CCSizeMake(winSize.width * 0.85, 320), kCCTextAlignmentLeft);
about->setPosition(ccp(winSize.width / 2, winSize.height / 2 ));
addChild(about);
CCLabelBMFont *backLb = CCLabelBMFont::create("Go Back", s_font);
CCMenuItemLabel *goBack = CCMenuItemLabel::create(backLb, this, menu_selector(About::goBack));
goBack->setScale(0.6f);
CCActionInterval *fadeIn = CCFadeTo::create(1, 80);
CCActionInterval *fadeOut = CCFadeTo::create(1, 255);
CCEaseSineInOut *ease1 = CCEaseSineInOut::create(fadeIn);
CCEaseSineInOut *ease2 = CCEaseSineInOut::create(fadeOut);
CCFiniteTimeAction *seq = CCSequence::create(ease1, ease2, NULL);
// 参数必须要强转,不然ndk编译不过
goBack->runAction(CCRepeatForever::create((CCActionInterval*)seq));
CCMenu *menu = CCMenu::create(goBack, NULL);
menu->setPosition(winSize.width / 2, winSize.height/2 - 60);
addChild(menu);
return true;
}