本文整理汇总了C++中CCMenuItemImage::runAction方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemImage::runAction方法的具体用法?C++ CCMenuItemImage::runAction怎么用?C++ CCMenuItemImage::runAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemImage
的用法示例。
在下文中一共展示了CCMenuItemImage::runAction方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initSceneChoose
//添加3个选关按钮
void MenuScene::initSceneChoose()
{
float pngWidth = 362.0;
float xSpace = (size.width - pngWidth*3)/4;
//添加练习场菜单项
CCActionInterval* scaleToex1 = CCScaleTo::create(kScaleDuration1, kScaleRitio, kScaleRitio-0.03);
CCActionInterval* scaleToex2 = CCScaleTo::create(kScaleDuration1, kScaleRitio-0.02, kScaleRitio);
CCSequence* sequence1 = CCSequence::create(scaleToex1,scaleToex2,NULL);
CCActionInterval* rotate1 = CCRepeatForever::create(sequence1);
CCMenuItemImage *exersize = CCMenuItemImage::create("ZF_Shoot_Button_lxc.png", "ZF_Shoot_Button_lxc.png", this, menu_selector(MenuScene::menuChoseScene));
exersize->setPosition(ccp(xSpace+pngWidth/2, size.height/2));
exersize->setScale(kScaleRitio);
exersize->setTag(kExserciseTag);
exersize->runAction(rotate1);
//添加平民场菜单项
CCActionInterval* scaleTope1 = CCScaleTo::create(kScaleDuration1, kScaleRitio, kScaleRitio-0.03);
CCActionInterval* scaleTope2 = CCScaleTo::create(kScaleDuration1, kScaleRitio-0.02, kScaleRitio);
CCSequence* sequence2 = CCSequence::create(scaleTope1,scaleTope2,NULL);
CCActionInterval* rotate2 = CCRepeatForever::create(sequence2);
CCMenuItemImage *people = CCMenuItemImage::create("ZF_Shoot_Button_pmc.png", "ZF_Shoot_Button_pmc.png", this, menu_selector(MenuScene::menuChoseScene));
people->setPosition(ccp(xSpace*2+pngWidth*1.5, size.height/2));
people->setScale(kScaleRitio);
people->setTag(kPeopleTag);
people->runAction(rotate2);
//添加富豪场菜单项
CCActionInterval* scaleTori1 = CCScaleTo::create(kScaleDuration1, kScaleRitio, kScaleRitio-0.03);
CCActionInterval* scaleTori2 = CCScaleTo::create(kScaleDuration1, kScaleRitio-0.02, kScaleRitio);
CCSequence* sequence3 = CCSequence::create(scaleTori1,scaleTori2,NULL);
CCActionInterval* rotate3 = CCRepeatForever::create(sequence3);
CCMenuItemImage *rich = CCMenuItemImage::create("ZF_Shoot_Button_hhc.png", "ZF_Shoot_Button_hhc.png", this, menu_selector(MenuScene::menuChoseScene));
rich->setPosition(ccp(xSpace*3+pngWidth*2.5, size.height/2));
rich->setScale(kScaleRitio);
rich->setTag(kRichTag);
rich->runAction(rotate3);
//集成到菜单容器
richMenu = CCMenu::create(rich,people,exersize,NULL);
richMenu->setPosition(CCPointZero);
this->addChild(richMenu,1);
}
示例2: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemWithNormalImage(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 80, 120) );
pCloseItem->setScale(3);
pCloseItem->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(1.0f, 360)));
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
/////////////////////////////
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Thonburi", 34);
// ask director the window size
CCSize size = CCDirector::sharedDirector()->getWinSize();
// position the label on the center of the screen
pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
// add the label as a child to this layer
this->addChild(pLabel, 1);
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png");
// position the sprite on the center of the screen
pSprite->setPosition( ccp(size.width/2, size.height/2) );
// add the sprite as a child to this layer
this->addChild(pSprite, 0);
return true;
}
示例3: initButton
//添加顶部按钮
void MenuScene::initButton()
{
//免费富币
CCMenuItemImage *freeImage = CCMenuItemImage::create("ZF_Shoot_Button_coin.png", "ZF_Shoot_Button_coin1.png",this,menu_selector(MenuScene::menuCloseCallBack));
freeImage->setPosition(ccp(size.width/2, size.height-55));
freeImage->setTag(1);
CCActionInterval* scaleTofree1 = CCScaleTo::create(kScaleDuration, 1, 0.95);
CCActionInterval* scaleTofree2 = CCScaleTo::create(kScaleDuration, 0.96, 1);
CCSequence* sequence1 = CCSequence::create(scaleTofree1,scaleTofree2,NULL);
CCActionInterval* rotate1 = CCRepeatForever::create(sequence1);
freeImage->runAction(rotate1);
//商城
CCMenuItemImage *buyImage = CCMenuItemImage::create("ZF_Shoot_Button_shop.png", "ZF_Shoot_Button_shop1.png",this,menu_selector(MenuScene::menuCloseCallBack));
buyImage->setPosition(ccp(size.width/2+205, size.height-55));
buyImage->setTag(2);
CCActionInterval* scaleTobuy1 = CCScaleTo::create(kScaleDuration, 1, 0.95);
CCActionInterval* scaleTobuy2 = CCScaleTo::create(kScaleDuration, 0.96, 1);
CCSequence* sequence2 = CCSequence::create(scaleTobuy1,scaleTobuy2,NULL);
CCActionInterval* rotate2 = CCRepeatForever::create(sequence2);
buyImage->runAction(rotate2);
//玩家指南
CCMenuItemImage *guideIamge = CCMenuItemImage::create("ZF_Shoot_Button_help.png", "ZF_Shoot_Button_help1.png",this,menu_selector(MenuScene::menuCloseCallBack));
guideIamge->setPosition(ccp(size.width/2+405, size.height-55));
guideIamge->setTag(4);
CCActionInterval* scaleTopl1 = CCScaleTo::create(kScaleDuration, 1, 0.95);
CCActionInterval* scaleTopl2 = CCScaleTo::create(kScaleDuration, 0.96, 1);
CCSequence* sequence4 = CCSequence::create(scaleTopl1,scaleTopl2,NULL);
CCActionInterval* rotate4 = CCRepeatForever::create(sequence4);
guideIamge->runAction(rotate4);
sceneMenu = CCMenu::create(freeImage,buyImage,guideIamge,NULL);
sceneMenu->setPosition(CCPointZero);
this->addChild(sceneMenu, 1);
}
示例4: BtnUpInCallback
void UIStory::BtnUpInCallback(CCObject* pSender)
{
CCMenuItemImage* pBtn = (CCMenuItemImage*)pSender;
pBtn->stopAllActions();
pBtn->runAction(CCScaleTo::actionWithDuration(0.1f, CCGetScaleX()));
if ( pBtn->getTag() == 1002 )
{
//continue
//SceneManager::SharedSceneManager()->JumpToGameLevel(1);
if(NextGameLevel != 6)
{
SceneManager::SharedSceneManager()->JumpToNextStage(NextGameLevel);
}
else
{
SceneManager::SharedSceneManager()->JumpToStartPanel();
}
}
}
示例5: BtnUpOutCallback
void UIStory::BtnUpOutCallback(CCObject* pSender)
{
CCMenuItemImage* pBtn = (CCMenuItemImage*)pSender;
pBtn->stopAllActions();
pBtn->runAction(CCScaleTo::actionWithDuration(0.1f, CCGetScaleX()));
}
示例6: init
bool OverMenu::init(CCNode* layer_)
{
if(!CCLayer::init()){
return false;
}
layer=layer_;
layer->addChild(this,50);
this->schedule(schedule_selector(OverMenu::tick));
int score=((GameLayer*)layer)->gamebody->score;
if(((GameLayer*)layer)->gamebody->game_mode==MODE_SHUANGZI){
score=((GameLayer*)layer)->gamebody->score+((GameLayer*)layer)->gamebody2->score;
}
bool ishigh=false;
int modeid=CCUserDefault::sharedUserDefault()->getIntegerForKey("gamemode");
char modehighscore[200];
sprintf(modehighscore, "highscore%d",modeid);
int highscore=CCUserDefault::sharedUserDefault()->getIntegerForKey(modehighscore);
if(score>highscore){
highscore=score;
CCUserDefault::sharedUserDefault()->setIntegerForKey(modehighscore, highscore);
CCUserDefault::sharedUserDefault()->flush();
ishigh=true;
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sound/newscore.mp3", false);
}
{
CCMenuItemImage *button = CCMenuItemImage::create(
"game/black.jpg",
"game/black.jpg",
this,
NULL );
CCMenu* Menu = CCMenu::create(button, NULL);
Menu->setPosition(CCPointZero);
this->addChild(Menu,-1);
button->setAnchorPoint(ccp(0.5f,0));
button->setPosition(ccp(screenSize.width*0.5f,0));
button->setOpacity(150);
}
{
pane=CCSprite::create("over/back.png");
this->addChild(pane,1);
pane->setScale(0.3f*screenSize.height/pane->getContentSize().height);
pane->setPosition(ccpPercent(50, 155));
{
CCMoveTo* a1=CCMoveTo::create(0.4f, ccpPercent(50, 60));
pane->runAction(a1);
}
{
CCLabelTTF* word = CCLabelTTF::create("游戏结束", "ttf/word.ttf", pane->getContentSize().height*0.2f);
word->setAnchorPoint(ccp(0.5f,0.5f));
pane->addChild(word, 10);
word->setPosition(ccpContent(pane->getContentSize(), 50, 120));
word->setColor(ccGRAY);
}
{
char* name;
GAME_MODE gamemode=((GameLayer*)layer)->game_mode;
char* gamecenterid;
if(gamemode==MODE_WANMEI){
name=(char*)"完美模式";
gamecenterid=(char*)"com.adultdream.mengmengda.wanmei";
}
if(gamemode==MODE_SHANDIAN){
name=(char*)"闪电模式";
gamecenterid=(char*)"com.adultdream.mengmengda.shandian";
}
if(gamemode==MODE_NIUZHUAN){
name=(char*)"扭转模式";
gamecenterid=(char*)"com.adultdream.mengmengda.niuzhuan";
}
if(gamemode==MODE_SHUANGZI){
name=(char*)"双子模式";
gamecenterid=(char*)"com.adultdream.mengmengda.shuangzi";
}
if(gamemode==MODE_XIANSHI){
name=(char*)"限时模式";
gamecenterid=(char*)"com.adultdream.mengmengda.xianshi";
}
if(gamemode==MODE_JINGDIAN){
name=(char*)"经典模式";
gamecenterid=(char*)"com.adultdream.mengmengda.jingdian";
}
CCLabelTTF* word = CCLabelTTF::create(name, "ttf/word.ttf", pane->getContentSize().height*0.15f);
word->setAnchorPoint(ccp(0.5f,0.5f));
pane->addChild(word, 10);
word->setPosition(ccpContent(pane->getContentSize(), 50, 80));
//.........这里部分代码省略.........