本文整理汇总了C++中CCLayer::runAction方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayer::runAction方法的具体用法?C++ CCLayer::runAction怎么用?C++ CCLayer::runAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLayer
的用法示例。
在下文中一共展示了CCLayer::runAction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setContentAccess
//SetContentAccess
//state
//1 - active
//2 - passive
void CurrentGroupLayer::setContentAccess(bool state)
{
CCLayer* spr = (CCLayer*)this->getChildByTag(ID_CONTROLLAYER);
spr->stopAllActions();
CCActionInterval* scalein = CCScaleTo::actionWithDuration(0.2f,1.2f,1.2f);
CCActionInterval* scaleout = CCScaleTo::actionWithDuration(0.2f,1.0f,1.0f);
CCActionInterval* fadetoin = CCFadeTo::actionWithDuration(0.2f,255);
CCActionInterval* fadetoout = CCFadeTo::actionWithDuration(0.2f,180);
if(state)
{
((CCSprite*)(spr->getChildByTag(ID_TEXTFIELD)))->runAction(CCEaseInOut::actionWithAction((CCActionInterval*)fadetoin->copy()->autorelease(),2.0f));
((CCSprite*)(spr->getChildByTag(ID_COLORBOX)))->runAction(CCEaseInOut::actionWithAction((CCActionInterval*)fadetoin->copy()->autorelease(),2.0f));
((CCSprite*)(spr->getChildByTag(ID_STRIPE)))->runAction(CCEaseInOut::actionWithAction((CCActionInterval*)fadetoin->copy()->autorelease(),2.0f));
spr->runAction(CCEaseInOut::actionWithAction((CCActionInterval*)scalein->copy()->autorelease(),2.0f));
m_isAccessable = true;
} else {
((CCSprite*)(spr->getChildByTag(ID_TEXTFIELD)))->runAction(CCEaseInOut::actionWithAction((CCActionInterval*)fadetoout->copy()->autorelease(),2.0f));
((CCSprite*)(spr->getChildByTag(ID_COLORBOX)))->runAction(CCEaseInOut::actionWithAction((CCActionInterval*)fadetoout->copy()->autorelease(),2.0f));
((CCSprite*)(spr->getChildByTag(ID_STRIPE)))->runAction(CCEaseInOut::actionWithAction((CCActionInterval*)fadetoout->copy()->autorelease(),2.0f));
spr->runAction(CCEaseInOut::actionWithAction((CCActionInterval*)scaleout->copy()->autorelease(),2.0f));
//hide keyboard
this->onClickTrackNode(0);
m_isAccessable = false;
}
}
示例2: CCPointMake
MainLayer::MainLayer()
{
setIsTouchEnabled(true);
CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini);
CCLayer* layer = CCLayerColor::layerWithColor(ccc4(255,255,0,255));
addChild(layer, -1);
addChild(sprite, 0, kTagSprite);
sprite->setPosition( CCPointMake(20,150) );
sprite->runAction( CCJumpTo::actionWithDuration(4, CCPointMake(300,48), 100, 4) );
layer->runAction( CCRepeatForever::actionWithAction(
(CCActionInterval*)( CCSequence::actions(
CCFadeIn::actionWithDuration(1),
CCFadeOut::actionWithDuration(1),
NULL) )
) );
}
示例3: ccTouchEnded
void GiftListView::ccTouchEnded( CCTouch *pTouch, CCEvent *pEvent )
{
this->unschedule(schedule_selector(GiftListView::touchUpdate));
//CCLOG("touch end-------");
if (mNowSeledItem)
{
if (!mIsClickEnable)
return;
mNowSeledItem->setStatus(GiftItem::nor);
if (mApater !=NULL)
mApater->onSelItem(mNowSeledItem);
mNowSeledItem = NULL;
return;
}
CCLayer* minDisPage = (CCLayer*)mPages.objectAtIndex(0);
int minDis = abs(minDisPage->getPositionX());
int minx = minDisPage->getPositionX();
int minPage = 1;
int i=1;
//CCLOG("list move m:%f t:%f v:%f",mMovex,mTimer,abs(mMovex/mTimer));
if ( abs(mMovex/mTimer)>500)//滑动速度很快,翻页
{
CCLOG("move far!!!");
int dis = (mMovex<0)?1:-1;
int nextPage = (mPageCurr+dis<1)?1:(mPageCurr+dis);
if (nextPage>(int)mPages.count())
nextPage = mPages.count();
minDisPage = (CCLayer*)mPages.objectAtIndex(nextPage-1);
minx = minDisPage->getPositionX();
minPage = nextPage;
}
else//滑动速度慢 判断最后哪一页
{
for (;i<mPageTotal;i++)//获取离要到的页面
{
CCLayer* page = (CCLayer*)mPages.objectAtIndex(i);
int dis = abs(page->getPositionX());
if (dis<minDis)
{
minDisPage = page;
minDis = dis;
minx =page->getPositionX();
minPage = i+1;
}
}
}
mPageCurr = minPage;
setPageMarkerShow(mPageCurr);
//CCLOG("minPage %d",minPage);
int moveDis = -minx;
for (i=0;i<mPageTotal;i++)
{
CCLayer* page = (CCLayer*)mPages.objectAtIndex(i);
CCPoint topoint = ccp(moveDis,page->getPositionY());
CCActionInterval* moveto = CCMoveBy::create(0.6f,topoint);
CCEaseExponentialOut* moveAction = CCEaseExponentialOut::create(moveto);
moveAction->setTag(999);
page->runAction(moveAction);
}
mIsMove =false;
mMovex = 0;
mTimer = 0;
}
示例4: toServerList
void ThirdServerScene::toServerList() {
if (this->getChildByTag(loginLayerTag) != NULL) {
this->removeChildByTag(loginLayerTag,true);
}
CCLayer* loginLayer = CCLayer::create();
loginLayer->setTag(loginLayerTag);
loginLayer->setPosition(ccp(0,0));
CCLayer* displayLayer = CCLayer::create();
CCSprite* loginBack = CCSprite::createWithSpriteFrameName("serverShadow.png");
loginBack->setPosition(ccp(0,0));
loginBack->setAnchorPoint(ccp(1,0));
loginBack->setScale(2);
displayLayer->addChild(loginBack);
displayLayer->setTag(loginDisplayLayerTag);
loginLayer->addChild(displayLayer);
displayLayer->setPosition(ccp(winSize.width-645,960));
CCSprite* serverListLabel = CCSprite::createWithSpriteFrameName("serverlistTipLabel.png");
serverListLabel->setPosition(ccp(-285,325));
displayLayer->addChild(serverListLabel);
// CCSprite* upTip = CCSprite::createWithSpriteFrameName("serverlistTipCornor.png");
// upTip->setPosition(ccp(-300,65));
// upTip->setRotation(180);
// upTip->setScale(0.66);
// upTip->setColor(ccc3(200,200,200));
// upTip->setTag(upTipTag);
//
// displayLayer->addChild(upTip);
CCSprite* downTip = CCSprite::createWithSpriteFrameName("serverlistTipCornor.png");
downTip->setPosition(ccp(-300,50));
downTip->setScale(0.66);
downTip->setColor(ccc3(200,200,200));
downTip->setTag(downTipTag);
downTip->runAction(CCRepeatForever::create(static_cast<CCSequence*>(CCSequence::create( CCEaseIn::create(CCMoveBy::create(0.25,ccp(0,-10)),1.5),CCEaseOut::create(CCMoveBy::create(0.25,ccp(0,10)),1.5),NULL))));
displayLayer->addChild(downTip);
displayLayer->runAction(CCEaseElasticOut::create(CCMoveTo::create(0.35, ccp(winSize.width-394,280)), 1));
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sfx_popCreator.mp3");
CCObject* obj;
int i = 0;
ServerSelectScroll2* scroll = ServerSelectScroll2::create(-507);
scroll->setOriPosition(ccp(winSize.width-890,370));
scroll->setContentSize(CCSizeMake(450, 200));
scroll->setMapSize(CCSizeMake(450, 50*(beans->count()+3)));
scroll->setPosition(ccp(winSize.width-765+0.33*50*(beans->count()-1)-224,-scroll->getMapSize().height+scroll->getViewSize().height+scroll->getOriPosition().y+680));
scroll->runAction(CCEaseElasticOut::create(CCMoveBy::create(0.35, ccp(224,-680)), 1));
CCARRAY_FOREACH(beans,obj) {
SeverInfoBean* bean = (SeverInfoBean*)obj;
CCSprite* layer = CCSprite::create("transparent.png");
// CCSprite* transParent = CCSprite::create("transparent.png");
layer->setScaleX(270/layer->getContentSize().width);
layer->setScaleY(33/layer->getContentSize().height);
layer->setContentSize(CCSizeMake(225,33));
layer->setOpacity(100);
CCLabelTTF* label = CCLabelTTF::create(bean->getServerName()->getCString(),"Arial",33);
label->setPosition(ccp(90/layer->getScaleX(),16/layer->getScaleY()));
layer->addChild(label,2);
label->setTag(serverNameLabelTag);
label->setScaleX(1/layer->getScaleX());
label->setScaleY(1/layer->getScaleY());
if (bean->serverId == cacheServerId) {
label->setColor(ccc3(155,155,155));
}
CCLabelTTF* stateLabel =CCLabelTTF::create(bean->getServerStatus()->getCString(),"Arial",30);
stateLabel->setPosition(ccp(236/layer->getScaleX(),16/layer->getScaleY()));
if (bean->getServerStatus()->compare("正常") == 0 || bean->getServerStatus()->compare("推荐") == 0) {
stateLabel->setColor(ccc3(0,255,0));
} else if (bean->getServerStatus()->compare("繁忙") == 0) {
stateLabel->setColor(ccc3(255,255,0));
} else if (bean->getServerStatus()->compare("火爆") == 0) {
stateLabel->setColor(ccc3(167,87,168));
} else {
stateLabel->setColor(ccc3(166,166,166));
}
stateLabel->setScaleX(1/layer->getScaleX());
stateLabel->setScaleY(1/layer->getScaleY());
layer->addChild(stateLabel,2);
MyMenuItem* serverItem = MyMenuItem::create(layer,this,menu_selector(ThirdServerScene::toChangeServer));
serverItem->setPosition(ccp(-(i+3)*17+135,26+50*(i+3)));
// serverItem->setAnchorPoint(ccp(0,0));
serverItem->setUserObject(bean);
scroll->addChild(serverItem);
// dividingLength*i+33
i++;
}
示例5: initServerInfo
void ThirdServerScene::initServerInfo(SeverInfoBean* bean) {
this->removeChildByTag(serverInfoLayerTag,true);
selectBean = bean;
CCLayer* serverInfoLayer = CCLayer::create();
serverInfoLayer->setTag(serverInfoLayerTag);
serverInfoLayer->setPosition(ccp(0,0));
this->cacheServerId = bean->serverId;
char str[30] = {0};
sprintf(str,"s%d_ititaId",bean->serverId);
std::string ititaId = CCUserDefault::sharedUserDefault()->getStringForKey(str,"");
bool ititaIdFlag = false;
if (ititaId.compare("") != 0 && ititaId.compare(PulsarNative::getDeviceId()) != 0) {
ititaIdFlag = true;
}
MyMenuItem* leftButton = MyMenuItem::create(CCSprite::createWithSpriteFrameName("serverButton.png"),NULL,NULL);
leftButton->setAnchorPoint(ccp(1,0.5));
// leftButton->setPosition(ccp(winSize.width+100,240));
leftButton->setPosition(ccp(winSize.width+422,240));
leftButton->runAction(CCSequence::create(CCDelayTime::create(0.1),CCEaseElasticOut::create(CCMoveTo::create(0.3,ccp(winSize.width+100,240)),1),NULL));
CCSprite* registLabel;
if (ititaIdFlag) {
registLabel = CCSprite::createWithSpriteFrameName("serverSwitchLabel.png");
leftButton->setTarget(this,menu_selector(ThirdServerScene::toLogin));
} else {
registLabel = CCSprite::createWithSpriteFrameName("serverBindLabel.png");
leftButton->setTarget(this,menu_selector(ThirdServerScene::toRegister));
}
registLabel->setAnchorPoint(ccp(0,0.5));
registLabel->setPosition(ccp(30,leftButton->getContentSize().height/2));
leftButton->addChild(registLabel);
MyMenuItem* rightButton = MyMenuItem::create(CCSprite::createWithSpriteFrameName("serverButton.png"),this,menu_selector(ThirdServerScene::fastEnterGameWait));
rightButton->setAnchorPoint(ccp(1,0.5));
// rightButton->setPosition(ccp(winSize.width+20,330));
rightButton->setPosition(ccp(winSize.width+342,330));
rightButton->runAction(CCSequence::create(CCEaseElasticOut::create(CCMoveTo::create(0.3,ccp(winSize.width+20,330)),1),NULL));
CCSprite* newLabel;
if (ititaIdFlag) {
newLabel = CCSprite::createWithSpriteFrameName("serverEnterGame.png");
} else {
newLabel = CCSprite::createWithSpriteFrameName("serverFastStartLabel.png");
}
newLabel->setAnchorPoint(ccp(0,0.5));
newLabel->setPosition(ccp(30,rightButton->getContentSize().height/2));
rightButton->addChild(newLabel);
MyPriorityMenu* menu = MyPriorityMenu::create(-501,leftButton,rightButton,NULL);
menu->setPosition(ccp(0,0));
serverInfoLayer->addChild(menu);
// sprintf(str,"s%d_nickname",bean->serverId);
// std::string nickname = CCUserDefault::sharedUserDefault()->getStringForKey(str,"");
//
// if (nickname.compare("") != 0) {
// CCLabelTTF* id = CCLabelTTF::create("ID:","Arial",40);
// id->setColor(ccc3(255,222,0));
//
// CCLabelTTF* nicknameLabel = CCLabelTTF::create(nickname.c_str(),"Arial",40);
// float locx = id->getContentSize().width+nicknameLabel->getContentSize().width;
// id->setAnchorPoint(ccp(0,0.5));
// id->setPosition(ccp(winSize.width-locx/2-180,400));
// nicknameLabel->setAnchorPoint(ccp(0,0.5));
// nicknameLabel->setPosition(ccp(winSize.width-locx/2+id->getContentSize().width-190,400));
// serverInfoLayer->addChild(id);
// serverInfoLayer->addChild(nicknameLabel);
// }
CCLayer* layer = CCLayer::create();
CCLabelTTF* label = CCLabelTTF::create(bean->getServerName()->getCString(),"Arial",33);
label->setPosition(ccp(224,2));
layer->addChild(label);
label->setTag(serverNameLabelTag);
CCLabelTTF* stateLabel =CCLabelTTF::create(bean->getServerStatus()->getCString(),"Arial",30);
stateLabel->setPosition(ccp(340,0));
if (bean->getServerStatus()->compare("正常") == 0 || bean->getServerStatus()->compare("推荐") == 0) {
stateLabel->setColor(ccc3(0,255,0));
} else if (bean->getServerStatus()->compare("繁忙") == 0) {
stateLabel->setColor(ccc3(255,255,0));
} else if (bean->getServerStatus()->compare("火爆") == 0) {
stateLabel->setColor(ccc3(167,87,168));
} else {
stateLabel->setColor(ccc3(166,166,166));
}
layer->addChild(stateLabel);
CCSprite* serverBack = CCSprite::createWithSpriteFrameName("serverCurentServerBack.png");
// serverBack->setPosition(ccp(winSize.width+35,48));
serverBack->setPosition(ccp(winSize.width+357,48));
serverBack->runAction(CCSequence::create(CCDelayTime::create(0.3),CCEaseElasticOut::create(CCMoveTo::create(0.3,ccp(winSize.width+35,48)),1),NULL));
//.........这里部分代码省略.........