本文整理汇总了C++中runAction函数的典型用法代码示例。如果您正苦于以下问题:C++ runAction函数的具体用法?C++ runAction怎么用?C++ runAction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了runAction函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: stopAllActions
void PumpkinEyes::doAction(float time)
{
stopAllActions();
runAction(blink);
}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:5,代码来源:BackgroundLayer_Forest.cpp
示例2: ccdbut
void ControllerPlayer::cdImg(float time, std::string name1, std::string name2, Button* but, float scale, MyEnum type)
{
CallFunc* cding;
CallFunc* cded;
ccdbut();
switch (type)
{
case attackcd:
{
cding = CallFunc::create([&](){attackisCD = true; });
cded = CallFunc::create([&](){attackisCD = false; });
this->scheduleOnce(schedule_selector(ControllerPlayer::oscdbut), 1.0f);
PlayerAction(StringUtils::toString(attackType));
this->scheduleOnce(schedule_selector(ControllerPlayer::Cdskill), 0.8f);
break;
}
case skillcd:
{
cding = CallFunc::create([&](){skillisCD = true; });
cded = CallFunc::create([&](){skillisCD = false; });
this->scheduleOnce(schedule_selector(ControllerPlayer::oacdbut), 1.2f);
PlayerAction(StringUtils::toString(skillType));
this->scheduleOnce(schedule_selector(ControllerPlayer::Cdskill), 1.2f);
break;
}
case bigskillcd:
{
cding = CallFunc::create([&](){ bigisCD = true; });
cded = CallFunc::create([&](){ bigisCD = false; });
this->scheduleOnce(schedule_selector(ControllerPlayer::obscdbut), 2.0f);
PlayerAction(StringUtils::toString(skillType));
this->scheduleOnce(schedule_selector(ControllerPlayer::Cdskill), 1.2f);
break;
}
case shangxiancd:
{
cding = CallFunc::create([&](){ sxisCD = true; });
cded = CallFunc::create([&](){ sxisCD = false; });
this->scheduleOnce(schedule_selector(ControllerPlayer::osxcdbut), 0.6f);
m_player->sxskill();
this->scheduleOnce(schedule_selector(ControllerPlayer::Cdskill), 0.6f);
break;
}
}
SpriteFrameCache* frameCache = SpriteFrameCache::getInstance();
frameCache->addSpriteFramesWithFile("fight0.plist", "fight0.png");
Point thepoint = but->getPosition();
auto cds = Sprite::createWithSpriteFrameName(name2);
cds->setPosition(thepoint);
cds->setScale(scale, scale);
addChild(cds, 3);
auto funk = [cds, but]()
{
cds->setVisible(false);
but->setEnabled(true);
};
CallFunc* func = CallFunc::create(funk);
auto cd = ProgressTimer::create(Sprite::createWithSpriteFrameName(name1));
cd->setType(ProgressTimer::Type::RADIAL);
cd->setPosition(thepoint);
cd->setScale(0.74, 0.74);
auto to1 = Sequence::create(cding, ProgressTo::create(time, 100), ProgressTo::create(0, 0), func, cded, nullptr);
cd->runAction(to1);
addChild(cd, 4);
}
开发者ID:LuowenVirus,项目名称:MyFirstGame,代码行数:76,代码来源:Controllplayer.cpp
示例3: Size
Layout * Mx::createDialog(Node* child, Node * parent, Size innerSize, DialogBtn buttonStyle, string background){
auto layout = Layout::create();
auto size = parent->getContentSize();
auto dialogSize = Size(innerSize.width + 30, innerSize.height + 30);
parent->addChild(layout, 999);
layout->setContentSize(size);
layout->setBackGroundColorType(cocos2d::ui::Layout::BackGroundColorType::SOLID);
layout->setBackGroundColor(Color3B::BLACK);
layout->setBackGroundColorOpacity(150);
layout->setTouchEnabled(true);
auto diaLayout = Layout::create();
layout->addChild(diaLayout);
diaLayout->setContentSize(innerSize);
diaLayout->setClippingEnabled(false);
diaLayout->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
diaLayout->setPosition(Vec2(dialogSize.width/2, dialogSize.height/2));
diaLayout->setScale(0);
diaLayout->setBackGroundImageScale9Enabled(true);
if (background == "") {
diaLayout->setBackGroundImage("sys_toast_b.png");
}else{
diaLayout->setBackGroundImage(background);
}
diaLayout->setPosition(size/2);
if (child != nullptr) {
diaLayout->addChild(child);
}
// set button;
{
if (buttonStyle.buttonNum != 0) {
if (buttonStyle.closeText == "") {
buttonStyle.closeText = this->getStrValue("close");
}
auto buttonConfirm = this->createDialogButton(buttonStyle, buttonStyle.confirmText);
auto buttonClose = this->createDialogButton(buttonStyle, buttonStyle.closeText);
if (buttonStyle.buttonNum == 1) {
buttonConfirm->setPosition(Vec2((dialogSize/2).width, 0));
diaLayout->addChild(buttonConfirm);
}else{
Size size = buttonConfirm->getContentSize()/2;
Size center = dialogSize/2;
buttonConfirm->setPosition(Vec2(center.width - size.width, 0));
buttonClose->setPosition(Vec2(center.width + size.width, 0));
diaLayout->addChild(buttonConfirm);
diaLayout->addChild(buttonClose);
}
}
if (buttonStyle.isVisibleClose) {
auto buttonClose = this->createDialogCloseButton(buttonStyle, buttonStyle.closeText, layout, diaLayout);
diaLayout->addChild(buttonClose);
buttonClose->setPosition(diaLayout->getContentSize() - buttonClose->getContentSize()/2 + Size(25, 25));
}
}
auto action = EaseBackOut::create(ScaleTo::create(.3, 1));
diaLayout->runAction(action);
return layout;
}
开发者ID:mx2014,项目名称:mx_game,代码行数:64,代码来源:Mx.cpp
示例4: getDelwithint
void Rolelayer::drawLeftlayer(){
float x_width= getDelwithint(200,0);
layertag=Rolelayertag::left;
if(this->getChildByTag(layer_left_tag)==nullptr){
left_layer=Layer::create();
left_layer->setContentSize(Size(Actual_x,Actual_y));
left_layer->setTag(layer_left_tag);
left_layer->setPosition(Vec2(0,0));
addChild(left_layer);
auto herobutton=MenuItemImage::create(hero_img,hero_img,CC_CALLBACK_1(Rolelayer::allCallbackm,this));
herobutton->setPosition(Vec2(herobutton->getContentSize().width/2,getContentSize().height*0.8));
herobutton->setTag(Buton::hero_b);
fillOuty(herobutton,hero_img);
if(getUimove()==Isteachmove::teacher){
/*
auto p_s=GuideLayer::createWithPrama(GuideLayer::MaskType::MaskType_Rectangle,herobutton->getPosition());
p_s->setSize(herobutton->getContentSize());
addChild(p_s);
*/
auto p=Sprite::create(teacher_shozhi);
p->setAnchorPoint(Vec2(0.5,0.5));
p->setRotation(-90);
p->setPosition(Vec2(herobutton->getContentSize().width,herobutton->getPositionY()+herobutton->getContentSize().height/2));
addChild(p);
p->setGlobalZOrder(1000);
p->runAction(RepeatForever::create(Sequence::create( FadeOut::create(0.5f),FadeIn::create(0.5f),nullptr)));
}
auto petbutton=MenuItemImage::create(pet_img,pet_img,CC_CALLBACK_1(Rolelayer::allCallbackm,this));
petbutton->setPosition(Vec2(petbutton->getContentSize().width/2,getContentSize().height*0.60));
petbutton->setTag(Buton::pet_b);
fillOuty(petbutton,pet_img);
auto magicbutton=MenuItemImage::create(magic_img,magic_img,CC_CALLBACK_1(Rolelayer::allCallbackm,this));
magicbutton->setPosition(Vec2(magicbutton->getContentSize().width/2,getContentSize().height*0.4));
magicbutton->setTag(Buton::magic_b);
fillOuty(magicbutton,magic_img);
auto menu=Menu::create(
herobutton,petbutton,magicbutton,
nullptr);
menu->setPosition(Vec2::ZERO);
menu->setTag(menu_zb1);
left_layer->addChild(menu, 1000);
tollgate_zb_menu=MenuItemImage::create(tollgatezbItem_img,tollgatezbItem_img,CC_CALLBACK_1(Rolelayer::allCallbackm,this));
tollgate_zb_menu->setTag(Buton::tollgateItem_tag);
tollgate_zb_menu->setPosition(Vec2(getContentSize().width*0.8,tollgate_zb_menu->getContentSize().height*0.5));
fillOuty(tollgate_zb_menu,tollgatezbItem_img);
if(getUimove()!=Isteachmove::teacher)
{
auto armature =Armature::create("Run_UI_zhuye_anniu_xiaoguo");
armature->getAnimation()->play("chuxian",-1,1);
armature->setPosition(Vec2(tollgate_zb_menu->getContentSize().width/2,tollgate_zb_menu->getContentSize().height/2));
tollgate_zb_menu->addChild(armature);
}
zb_menu=MenuItemImage::create(zb_img,zb_img,CC_CALLBACK_1(Rolelayer::allCallbackm,this));
zb_menu->setTag(Buton::zb_b);
zb_menu->setPosition(Vec2(tollgate_zb_menu->getPositionX(),tollgate_zb_menu->getPositionY()+zb_menu->getContentSize().height*1.2));
fillOuty(zb_menu,zb_img);
auto menutag=Menu::create(tollgate_zb_menu,zb_menu,nullptr);
menutag->setPosition(Vec2::ZERO);
left_layer->addChild(menutag);
auto back_img2=Sprite::create(tiao_img);
back_img2->setTag(tiao_sp);
back_img2->setAnchorPoint(Vec2(0,0));
back_img2->setPosition(Vec2(70,10));//zb_menu->getPositionY()-50));
left_layer->addChild(back_img2);
auto hy_bt=MenuItemImage::create(hy_img,hy_img,CC_CALLBACK_1(Rolelayer::allCallbackm,this));
hy_bt->setTag(hy_b);
hy_bt->setPosition(Vec2(back_img2->getContentSize().width*0.23,back_img2->getContentSize().height*0.65));
fillOuty(hy_bt,hy_img);
auto text_hy=Label::createWithSystemFont(FX::StringsMap::getValue("active"),"minijiankatong.ttf", 24);
text_hy->setColor(yellow_c);
text_hy->setPosition(Vec2(hy_bt->getPositionX(),back_img2->getContentSize().height*0.25));
back_img2->addChild(text_hy);
auto xiaoxi_bt=MenuItemImage::create(xiaoxi_img,xiaoxi_img,CC_CALLBACK_1(Rolelayer::allCallbackm,this));
xiaoxi_bt->setTag(msg_b);
xiaoxi_bt->setPosition(Vec2(back_img2->getContentSize().width*0.4,back_img2->getContentSize().height*0.65));
fillOuty(xiaoxi_bt,xiaoxi_img);
auto text_xx=Label::createWithSystemFont(FX::StringsMap::getValue("msg"),"minijiankatong.ttf", 24);
text_xx->setColor(yellow_c);
text_xx->setPosition(Vec2(xiaoxi_bt->getPositionX(),back_img2->getContentSize().height*0.25));
//.........这里部分代码省略.........
开发者ID:SongCF,项目名称:game-CoolRun,代码行数:101,代码来源:Rolelayer.cpp
示例5: an0
bool WelcomeScene::init()
{
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
const float SCALE_TO_DEVICE = Director::getInstance()->getVisibleSize().width / DES_RES_X;
auto welcomePic=Sprite::create("Starter_bg.png");
welcomePic->setPosition(Point(visibleSize.width/2+origin.x, visibleSize.height/2+origin.y));
welcomePic->setScaleX(visibleSize.width/welcomePic->getContentSize().width);
welcomePic->setScaleY(visibleSize.height/welcomePic->getContentSize().height);
this->addChild(welcomePic);
auto gameTitleLabel= Label::createWithTTF("Halloween\n Candy Rush", "FEASFBRG.TTF", visibleSize.width * SCORE_FONT);
gameTitleLabel->setColor(Color3B::YELLOW);
gameTitleLabel->setPosition(Point(visibleSize.width/2+origin.x, visibleSize.height*0.75+origin.y));
this->addChild(gameTitleLabel,10);
float scale_x=0.375;
auto pp1=Sprite::create();
pp1->setScale(SCALE_TO_DEVICE);
pp1->setPosition(Point(visibleSize.width*0.2+origin.x, visibleSize.height*scale_x+origin.y));
this->addChild(pp1,5);
auto pp2=Sprite::create();
pp2->setScale(SCALE_TO_DEVICE);
pp2->setPosition(Point(visibleSize.width*0.4+origin.x, visibleSize.height*scale_x+origin.y));
this->addChild(pp2,5);
auto pp3=Sprite::create();
pp3->setScale(SCALE_TO_DEVICE);
pp3->setPosition(Point(visibleSize.width*0.6+origin.x, visibleSize.height*scale_x+origin.y));
this->addChild(pp3,5);
auto pp4=Sprite::create();
pp4->setScale(SCALE_TO_DEVICE);
pp4->setPosition(Point(visibleSize.width*0.8+origin.x, visibleSize.height*scale_x+origin.y));
this->addChild(pp4,5);
auto coin=Sprite::create("Candy (1).png");
coin->setScale(SCALE_TO_DEVICE);
coin->setPosition(visibleSize.width*0.5+origin.x, visibleSize.height*0.5+origin.y);
Vector<SpriteFrame*> an0(3);
an0.pushBack(SpriteFrame::create("Candy (1).png", Rect(0,0,64,43)));
an0.pushBack(SpriteFrame::create("Candy (2) 2.png", Rect(0,0,96,63)));
an0.pushBack(SpriteFrame::create("Candy (3) 2.png", Rect(0,0,128,84)));
auto ani0=Animation::createWithSpriteFrames(an0,0.2f);
auto anim_00=Animate::create(ani0);
auto anim_0=RepeatForever::create(anim_00);
coin->runAction(anim_0);
this->addChild(coin,4);
for (float x=0;x<1.1;x=x+0.25)
{
for (float y=0;y<1.1;y=y+0.25)
{
if (y==0.25||y==0.5)
{
float pos_x=visibleSize.width*x+origin.x;
float pos_y=visibleSize.height*y+origin.y;
candy_matrix(pos_x, pos_y);
}
}
}
Vector<SpriteFrame*> an1(4);
an1.pushBack(SpriteFrame::create("Idle (1).png", Rect(0,0,140,145)));
an1.pushBack(SpriteFrame::create("Idle (2).png", Rect(0,0,140,145)));
an1.pushBack(SpriteFrame::create("Idle (3).png", Rect(0,0,140,145)));
an1.pushBack(SpriteFrame::create("Idle (4).png", Rect(0,0,140,145)));
auto ani1=Animation::createWithSpriteFrames(an1,0.1f);
auto anim_11=Animate::create(ani1);
auto anim_1=RepeatForever::create(anim_11);
pp1->runAction(anim_1);
Vector<SpriteFrame*> an2(4);
an2.pushBack(SpriteFrame::create("Launch Idle (1).png", Rect(0,0,111,139)));
an2.pushBack(SpriteFrame::create("Launch Idle (2).png", Rect(0,0,101,139)));
an2.pushBack(SpriteFrame::create("Launch Idle (3).png", Rect(0,0,101,139)));
an2.pushBack(SpriteFrame::create("Launch Idle (4).png", Rect(0,0,101,139)));
auto ani2=Animation::createWithSpriteFrames(an2,0.1f);
auto anim_22=Animate::create(ani2);
auto anim_2=RepeatForever::create(anim_22);
pp2->runAction(anim_2);
Vector<SpriteFrame*> an3(4);
an3.pushBack(SpriteFrame::create("Launch Idle (1) 2.png", Rect(0,0,140,146)));
an3.pushBack(SpriteFrame::create("Launch Idle (2) 2.png", Rect(0,0,140,146)));
an3.pushBack(SpriteFrame::create("Launch Idle (3) 2.png", Rect(0,0,140,146)));
an3.pushBack(SpriteFrame::create("Launch Idle (4) 2.png", Rect(0,0,140,146)));
auto ani3=Animation::createWithSpriteFrames(an3,0.1f);
auto anim_33=Animate::create(ani3);
auto anim_3=RepeatForever::create(anim_33);
pp3->runAction(anim_3);
Vector<SpriteFrame*> an4(4);
an4.pushBack(SpriteFrame::create("Launch Idle (1) 3.png", Rect(0,0,133,148)));
an4.pushBack(SpriteFrame::create("Launch Idle (2) 3.png", Rect(0,0,133,148)));
an4.pushBack(SpriteFrame::create("Launch Idle (3) 3.png", Rect(0,0,133,148)));
an4.pushBack(SpriteFrame::create("Launch Idle (4) 3.png", Rect(0,0,133,148)));
//.........这里部分代码省略.........
开发者ID:Noctiz-Jin,项目名称:Halloween-Candy-Rush-Night,代码行数:101,代码来源:WelcomeScene.cpp
示例6: CC_CALLBACK_1
// on "init" you need to initialize your instance
bool SceneMain::init()
{
/** you can create scene with following comment code instead of using csb file.
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////
// 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
auto closeItem = MenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
CC_CALLBACK_1(SceneMain::menuCloseCallback, this));
closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
origin.y + closeItem->getContentSize().height/2));
// create menu, it's an autorelease object
auto menu = Menu::create(closeItem, NULL);
menu->setPosition(Vec2::ZERO);
this->addChild(menu, 1);
/////////////////////////////
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 24);
// position the label on the center of the screen
label->setPosition(Vec2(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - label->getContentSize().height));
// add the label as a child to this layer
this->addChild(label, 1);
// add "SceneMain" splash screen"
auto sprite = Sprite::create("SceneMain.png");
// position the sprite on the center of the screen
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer
this->addChild(sprite, 0);
**/
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
// загрука ресурсов
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Plist.plist");
cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("Chudik/chudik.ExportJson");
cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("Battery/battery.ExportJson");
// создание сцены
auto rootNode = CSLoader::createNode("SceneMain.csb");
// нажатие на button и label
static_cast<TextBMFont *>(rootNode->getChildByName("BitmapFontSpd"))->addTouchEventListener(CC_CALLBACK_2(SceneMain::_buttonTouch, this));
static_cast<ImageView *>(rootNode->getChildByName("ImageButton"))->addTouchEventListener(CC_CALLBACK_2(SceneMain::_buttonTouch, this));
this->addChild(rootNode);
ActionTimeline *action = CSLoader::createTimeline("SceneMain.csb");
rootNode->runAction(action);
return true;
}
开发者ID:devuseful,项目名称:PuzzleGame,代码行数:82,代码来源:SceneMain.cpp
示例7: sprintf
bool GallaryList::init()
{
if (!Layer::init()) {
return false;
}
visibleSize = Director::getInstance()->getVisibleSize();
thumbWidth = visibleSize.width/4;
thumbSpace = visibleSize.width/3.5;
currentThumb = 0;
isClick = false;
GallaryLayer::setGallaryState(0, true);
GallaryLayer::setGallaryState(1, true);
GallaryLayer::setGallaryState(3, true);
GallaryLayer::setGallaryState(4, true);
GallaryLayer::setGallaryState(5, true);
GallaryLayer::setGallaryState(9, true);
for (int i = 0; i != picCount; ++i) {
char name[30];
sprintf(name, "gallary/gallary%d.png", i);
auto listItem = Sprite::create(name);
this->addChild(listItem);
thumbs.push_back(listItem);
listItem->setScale(thumbWidth/listItem->getContentSize().width, visibleSize.height/listItem->getContentSize().height/4);
listItem->setPosition(Vec2(visibleSize.width/2+thumbSpace*i, 0));
if (!GallaryLayer::getGallaryState(i)) {
listItem->setOpacity(100);
}
auto itemFrame = Sprite::create("frame/Data-Pic.png"); // TODO: need to be change
this->addChild(itemFrame, -1);
itemFrame->setPosition(Vec2(visibleSize.width/2+thumbSpace*i, 0));
itemFrame->setAnchorPoint(Point(0.5, 0.5));
itemFrame->setScale(thumbWidth/itemFrame->getContentSize().width*1.03, visibleSize.height/itemFrame->getContentSize().height/4*1.05);
touchListener = EventListenerTouchOneByOne::create();
touchListener->setSwallowTouches(true);
touchListener->onTouchBegan = [&, listItem](Touch *touch, Event *event) {
isClick = true;
event->getCurrentTarget()->stopActionByTag(tag_loadPic);
startPoint = touch->getLocation();
movePoint = startPoint;
// touch on list
auto locationInNode = listItem->convertToNodeSpace(touch->getLocation());
auto rect = cocos2d::Rect(0, 0, listItem->getContentSize().width, listItem->getContentSize().height);
if (rect.containsPoint(locationInNode)) {
touchListener->setSwallowTouches(true);
return true;
}
// touch on pic
auto displayPic = static_cast<GallaryContent*>(this->getParent())->getDisplayPic();
auto locationInNode2 = displayPic->convertToNodeSpace(touch->getLocation());
auto rect2 = cocos2d::Rect(0, 0, displayPic->getContentSize().width*displayPic->getScaleX(), displayPic->getContentSize().height*displayPic->getScaleY());
if (rect2.containsPoint(locationInNode2)) {
touchListener->setSwallowTouches(true);
return true;
}
return false;
};
touchListener ->onTouchMoved = [&](Touch *touch, Event *event) {
auto currentPoint = touch->getLocation();
this->setPositionX(this->getPositionX() + currentPoint.x - movePoint.x);
if (currentPoint.x - movePoint.x > 50 || currentPoint.x - movePoint.x < 100) {
isClick = false;
}
movePoint = currentPoint;
return true;
};
touchListener->onTouchEnded = [&](Touch *touch, Event *event) {
touchListener->setSwallowTouches(false);
auto target = static_cast<GallaryList*>(event->getCurrentTarget());
currentThumb = static_cast<int>((event->getCurrentTarget()->getPositionX()-thumbSpace/2)/thumbSpace);
// log("posx: %d", currentThumb);
if (-currentThumb >= picCount) {
currentThumb = -picCount + 1;
}
if (isClick) {
auto displayPic = static_cast<GallaryContent*>(this->getParent())->getDisplayPic();
auto locationInNode = displayPic->convertToNodeSpace(touch->getLocation());
auto rect = cocos2d::Rect(0, 0, displayPic->getContentSize().width*displayPic->getScaleX(), displayPic->getContentSize().height*displayPic->getScaleY());
// open display mode
if (rect.containsPoint(locationInNode) && GallaryLayer::getGallaryState(-currentThumb)) {
// target->onPicClick(-currentThumb);
this->onPicClick(-currentThumb);
}
} else {
if (currentThumb >= 0) {
target->runAction(MoveTo::create(0.2, Vec2(0, target->getPositionY())));
} else if (currentThumb < -picCount+1) {
target->runAction(MoveTo::create(0.2, Vec2(thumbSpace*(-picCount+1), target->getPositionY())));
} else {
target->runAction(MoveTo::create(0.2, Vec2(thumbSpace*currentThumb, target->getPositionY())));
}
// target->thumbs.at(-currentThumb)->runAction();
// change pic
target->onPicChange(-currentThumb);
}
return true;
//.........这里部分代码省略.........
开发者ID:KJTang,项目名称:GalGame,代码行数:101,代码来源:GallaryLayer.cpp
示例8: Point
bool GameGuide::init()
{
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
const float SCALE_TO_DEVICE = Director::getInstance()->getVisibleSize().width / DES_RES_X;
auto bk1 = Sprite::create("BG1.png");
float scaleRatio = visibleSize.width / bk1->getContentSize().width;
bk1->setScale(scaleRatio, scaleRatio);
bk1->setAnchorPoint(Point(0,0));
bk1->setPosition(Point(0, 0));
auto bk2 = Sprite::create("BG2.png");
bk2->setAnchorPoint( Point(0,0) );
bk2->setPosition( Point(0, bk1->getPositionY() + bk1->boundingBox().size.height -1) );
bk2->setScale(scaleRatio, scaleRatio);
auto bk3 = Sprite::create("BG3.png");
bk3->setAnchorPoint( Point(0,0) );
bk3->setPosition( Point(0, bk2->getPositionY() + bk2->boundingBox().size.height -1) );
bk3->setScale(scaleRatio, scaleRatio);
auto bk4 = Sprite::create("BG4.png");
bk4->setAnchorPoint( Point(0,0) );
bk4->setPosition( Point(0, bk3->getPositionY() + bk3->boundingBox().size.height -1) );
bk4->setScale(scaleRatio, scaleRatio);
auto bk5 = Sprite::create("BG5.png");
bk5->setAnchorPoint( Point(0,0) );
bk5->setPosition( Point(0, bk4->getPositionY() + bk4->boundingBox().size.height -1) );
bk5->setScale(scaleRatio, scaleRatio);
this->addChild(bk1, 0);
this->addChild(bk2, 0);
this->addChild(bk3, 0);
this->addChild(bk4, 0);
this->addChild(bk5, 0);
auto MM=Sprite::create("Launch (1).png");
MM->setScale(SCALE_TO_DEVICE);
MM->setPosition(Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height*0.2));
this->addChild(MM,10);
Vector<SpriteFrame*> trix_ani(4);
trix_ani.pushBack(SpriteFrame::create("Launch (1).png", Rect(0,0,280,289)));
trix_ani.pushBack(SpriteFrame::create("Launch (2).png", Rect(0,0,280,289)));
trix_ani.pushBack(SpriteFrame::create("Launch (3).png", Rect(0,0,280,289)));
trix_ani.pushBack(SpriteFrame::create("Launch (4).png", Rect(0,0,280,289)));
auto ani=Animation::createWithSpriteFrames(trix_ani,0.2f);
auto anim_rr=Animate::create(ani);
auto anim_r=RepeatForever::create(anim_rr);
MM->runAction(anim_r);
auto playItem = MenuItemImage::create("Blank.png", "Blank.png", CC_CALLBACK_1(GameGuide::GoToGameScene, this));
playItem->setScale(SCALE_TO_DEVICE);
playItem->setPosition(Point(visibleSize.width / 2 + origin.x, visibleSize.height*0.5 + origin.y));
playItem->runAction(RotateBy::create(60, 3600));
auto menu = Menu::create(playItem,NULL);
menu->setPosition(Point::ZERO);
this->addChild(menu,11);
auto game_title=Sprite::create("Launch.png");
game_title->setPosition(Point(visibleSize.width/2+origin.x, visibleSize.height*0.68 + origin.y));
game_title->setScale(SCALE_TO_DEVICE);
this->addChild(game_title,10);
/*
auto gameTitleLabel= Label::createWithTTF("Tap/Drag to fly", "FEASFBRG.TTF", visibleSize.height * SCORE_FONT*0.7);
gameTitleLabel->setColor(Color3B::YELLOW);
gameTitleLabel->setPosition(Point(visibleSize.width/2+origin.x, visibleSize.height*0.6+origin.y));
this->addChild(gameTitleLabel,10);
*/
/*
auto gameTitle= Label::createWithTTF("-> <-", "FEASFBRG.TTF", visibleSize.height * SCORE_FONT*0.5);
gameTitle->setColor(Color3B::YELLOW);
gameTitle->setPosition(Point(visibleSize.width/2+origin.x, visibleSize.height*0.5+origin.y));
this->addChild(gameTitle,10);
*/
return true;
}
开发者ID:Noctiz-Jin,项目名称:Halloween-Candy-Rush-Night,代码行数:83,代码来源:GameGuide.cpp
示例9: Vec2
void FuelTank::supply(float delay)
{
FiniteTimeAction* move=MoveBy::create(0.2, Vec2(0, -150));
CallFunc* call=CallFunc::create(CC_CALLBACK_0(FuelTank::removeNode, this));
runAction(Sequence::create(move,call, NULL));
}
开发者ID:zhyl19920810,项目名称:JLU_collection,代码行数:6,代码来源:SupplyFuelEntity.cpp
示例10: showGameOverUI
void BattleFieldUI::showGameOverUI()
{//show the gameover UI when loss
//diable AI
//color layer
auto layer = LayerColor::create(Color4B(255, 10, 10, 150));
layer->ignoreAnchorPointForPosition(false);
layer->setPosition3D(Vec3(VisibleSize.width*0.5, VisibleSize.height*0.5, 0));
//add gameover
auto gameOver = Sprite::create("battlefieldUI/gameover.png");
gameOver->setPosition3D(Vec3(VisibleSize.width*0.5, VisibleSize.height*0.5, 3));
gameOver->setScale(0.001);
layer->addChild(gameOver, 1);
layer->setGlobalZOrder(100);
gameOver->setGlobalZOrder(100);
auto listener = EventListenerTouchOneByOne::create();
//touch event
listener->onTouchBegan = [](Touch*, Event*)
{
return true;
};
listener->onTouchEnded = [this](Touch*, Event*)
{
//clear GlobalVaribals
HeroPool.clear();
DragonPool.clear();
SlimePool.clear();
RatPool.clear();
BossPool.clear();
PigletPool.clear();
HeroManager.clear();
MonsterManager.clear();
GameMaster::reset();
//stop schedule
currentLayer->unscheduleUpdate();
Director::getInstance()->getScheduler()->unschedule("gameController", currentLayer);
//stop sound
experimental::AudioEngine::stop(AUDIO_ID.BATTLEFIELDBGM);
//replace scene
Director::getInstance()->replaceScene(ChooseRoleScene::createScene());
};
gameOver->setCameraMask(2);
auto eventDispatcher = layer->getEventDispatcher();
eventDispatcher->addEventListenerWithSceneGraphPriority(listener, layer);
listener->setEnabled(false);
auto enableListener = [=]()
{
listener->setEnabled(true);
experimental::AudioEngine::stopAll();
experimental::AudioEngine::play2d("audios/effects/gameover.mp3");
};
//runaction
auto action = Sequence::create(DelayTime::create(3), EaseElasticOut::create(ScaleTo::create(1.5, 1)), CallFunc::create(enableListener),NULL);
gameOver->runAction(action);
addChild(layer);
}
开发者ID:WhatTeam,项目名称:FantasyLand,代码行数:63,代码来源:BattleFieldUI.cpp
示例11: runAction
void HelpLayer::onEnter(){
CCLayer::onEnter();
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 1, true);
runAction(CCMoveBy::create(0.3f, ccp(0, getContentSize().height - 80) / 2));
}
开发者ID:SeedAsh,项目名称:CoolStars,代码行数:5,代码来源:HelpLayer.cpp
示例12: Vec2
void Level13::restart(){
BaseLevel::restart();
#define MOVE_BY_X 192
auto r1 = Ring::create();
r1->setPosition(E::originX, E::originY + 128);
r1->setScale(0.2);
r1->initBody();
this->addChild(r1);
r1->runAction(RepeatForever::create(Sequence::create(MoveBy::create(0.5f, Vec2(MOVE_BY_X, 0)), DelayTime::create(1.0f), MoveBy::create(0.5f, Vec2(-MOVE_BY_X, 0)), nullptr)));
auto r2 = Ring::create();
r2->setPosition(E::originX + DESIGNED_WIDTH, E::originY + 128);
r2->setScale(0.2);
r2->initBody();
this->addChild(r2);
r2->runAction(RepeatForever::create(Sequence::create(MoveBy::create(0.5f, Vec2(-MOVE_BY_X, 0)), DelayTime::create(1.0f),MoveBy::create(0.5f, Vec2(MOVE_BY_X, 0)), nullptr)));
auto t1 = Target::create();
t1->setPosition(E::originX + DESIGNED_WIDTH / 2, E::originY + 400);
t1->initBody();
t1->playAnim(1);
this->addChild(t1);
t1->initProtector();
/*
auto b_l = Brick::create(E::originX + 96, 32);
b_l->setPosition(0, E::originY + 32);
b_l->setRotation(30);
b_l->initBody();
this->addChild(b_l);
auto b_r = Brick::create(E::originX + 96, 32);
b_r->setPosition(E::originX + DESIGNED_WIDTH - 96, E::originY + 32);
b_r->setRotation(-30);
b_r->initBody();
this->addChild(b_r);
*/
ring1 = Ring::create();
ring1->setPosition(E::originX + DESIGNED_WIDTH / 2 - 80, E::originY + 400);
ring1->setScale(0.1);
ring1->initBody();
this->addChild(ring1);
ring2 = Ring::create();
ring2->setPosition(E::originX + DESIGNED_WIDTH / 2 + 80, E::originY + 400);
ring2->setScale(0.1);
ring2->initBody();
this->addChild(ring2);
auto diamond1 = Diamond::create();
diamond1->setScale(0.9f);
diamond1->setRotation(30);
diamond1->setPosition(E::originX - 128, E::originY + 256 + 64);
diamond1->initBody();
this->addChild(diamond1);
auto diamond2 = Diamond::create();
diamond2->setScale(0.9f);
diamond2->setRotation(-30);
diamond2->setPosition(E::originX + DESIGNED_WIDTH + 128, E::originY + 256 + 64);
diamond2->initBody();
this->addChild(diamond2);
angle = 0;
}
开发者ID:Ratel13,项目名称:arkaflow,代码行数:70,代码来源:Level13.cpp
示例13: startColorVar
void FloatingEffectManager::toast_help_tail(const cocos2d::Vec2& srcPos, const cocos2d::Vec2& desPos, const cocos2d::Color4F& color)
{
const float time = 0.2;
float len = (desPos-srcPos).length();
if (len == 0) {
return;
}
const float speed = len/time;
auto _emitter = ParticleSystemQuad::createWithTotalParticles(500);
_emitter->setAutoRemoveOnFinish(true);
_layer->addChild(_emitter, 10);
_emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("images/test_lizi.png"));
_emitter->setDuration(time*5);
// gravity
_emitter->setGravity(Vec2::ZERO);
// angle
_emitter->setAngle(vector2angel(srcPos-desPos));
_emitter->setAngleVar(3);
// speed of particles
_emitter->setSpeed(speed/5);
_emitter->setSpeedVar(0);
// radial
_emitter->setRadialAccel(0);
_emitter->setRadialAccelVar(0);
// tagential
_emitter->setTangentialAccel(0);
_emitter->setTangentialAccelVar(0);
// emitter position
// _emitter->setPosition( Vec2(160,240) );
_emitter->setPosVar({0,0});
// life of particles
_emitter->setLife(0.2);
_emitter->setLifeVar(0);
// spin of particles
_emitter->setStartSpin(720);
_emitter->setStartSizeVar(360);
_emitter->setEndSpin(0);
_emitter->setEndSpinVar(360);
// color of particles
_emitter->setStartColor(color);
Color4F startColorVar(0.f, 0.1f, 0.f, 0.1f);
_emitter->setStartColorVar(startColorVar);
_emitter->setEndColor(color);
Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.1f);
_emitter->setEndColorVar(endColorVar);
// size, in pixels
_emitter->setStartSize(2.0f);
_emitter->setStartSizeVar(1.0f);
_emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
// emits per second
_emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());
// additive
_emitter->setBlendAdditive(true);
_emitter->setPosition(srcPos);
_emitter->runAction(MoveTo::create(0.1, desPos));
}
开发者ID:dgkae,项目名称:triplequest,代码行数:74,代码来源:BattleField-floating-effects.cpp
示例14: addParticalToHead
Head_ParticalEffect
void addParticalToHead(Node* node)
{
Vec2 pos[4];
pos[0] = Vec2(5, 75);
pos[1] = Vec2(75, 75);
pos[2] = Vec2(75, 5);
pos[3] = Vec2(5, 5);
for (int i = 0; i < 2; i++)
{
auto partNode = ParticleSystemQuad::createWithTotalParticles(60);
partNode->setTexture(TextureCache::getInstance()->addImage("GameUI/CommonUI/fire.png"));//设置粒子图
partNode->setDuration(-1);//发射时长
// life of particles
partNode->setLife(0.5f);//粒子生命
partNode->setLifeVar(0.1f);
partNode->setEmissionRate(partNode->getTotalParticles() / partNode->getLife());//发射器发射频率
partNode->setPositionType(ParticleSystem::PositionType::FREE);//设置发射器的跟随模式
// color of particles
partNode->setStartColor(ccc4f(0.76f, 0.25f, 0.12f, 1.0f));//起始颜色
partNode->setStartColorVar(ccc4f(0.1f, 0.1f, 0.1f, 0.0f));
partNode->setEndColor(ccc4f(1.0f, 1.0f, 1.0f, 1.0f));//结束颜色
partNode->setEndColorVar(ccc4f(0.1f, 0.1f, 0.1f, 0.1f));
// size, in pixels
partNode->setStartSize(15);//粒子大小
partNode->setStartSizeVar(3);
partNode->setEndSize(0);
partNode->setEndSizeVar(3);
// angle
partNode->setAngle(0);//发射器角度
partNode->setAngleVar(0);
// speed of particles
partNode->setSpeed(0);//粒子速度
partNode->setSpeedVar(0);
// emitter position
partNode->setPosVar(ccp(0, 0));//发射器位置变化
partNode->setBlendAdditive(true);
node->addChild(partNode);
partNode->setTag(PARTICALTAG);
auto move0 = MoveTo::create(1.f, pos[0]);
auto move1 = MoveTo::create(1.f, pos[1]);
auto move2 = MoveTo::create(1.f, pos[2]);
auto move3 = MoveTo::create(1.f, pos[3]);
if (i == 0)
{
partNode->setPosition(pos[0]);
partNode->runAction(RepeatForever::create(Sequence::create(move1, move2, move3, move0, nullptr)));
}
else
{
partNode->setPosition(pos[2]);
partNode->runAction(RepeatForever::create(Sequence::create(move3, move0, move1, move2, nullptr)));
}
}
}
开发者ID:YuYing-yy,项目名称:Tools-Code,代码行数:69,代码来源:Head_ParticalEffect.cpp
示例15: scheduleUpdate
IntervalLayer::IntervalLayer()
{
_time0 = _time1 = _time2 = _time3 = _time4 = 0.0f;
auto s = Director::getInstance()->getWinSize();
// sun
auto sun = ParticleSun::create();
sun->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png"));
sun->setPosition(VisibleRect::rightTop().x-32,VisibleRect::rightTop().y-32);
sun->setTotalParticles(130);
sun->setLife(0.6f);
this->addChild(sun);
// timers
_label0 = Label::createWithBMFont("fonts/bitmapFontTest4.fnt", "0");
_label1 = Label::createWithBMFont("fonts/bitmapFontTest4.fnt", "0");
_label2 = Label::createWithBMFont("fonts/bitmapFontTest4.fnt", "0");
_label3 = Label::createWithBMFont("fonts/bitmapFontTest4.fnt", "0");
_label4 = Label::createWithBMFont("fonts/bitmapFontTest4.fnt", "0");
scheduleUpdate();
schedule([&](float dt){
_time1 +=dt;
char str[10] = {0};
sprintf(str, "%2.1f", _time1);
_label1->setString( str );
}, "step_1");
schedule([&](float dt){
_time2 +=dt;
char str[10] = {0};
sprintf(str, "%2.1f", _time2);
_label2->setString( str );
}, 0.5, "step_2");
schedule([&](float dt){
_time3 +=dt;
char str[10] = {0};
sprintf(str, "%2.1f", _time3);
_label3->setString( str );
}, 1, "step_3");
schedule([&](float dt){
_time4 +=dt;
char str[10] = {0};
sprintf(str, "%2.1f", _time4);
_label4->setString( str );
}, 2, "step_4");
_label0->setPosition(s.width*1/6, s.height/2);
_label1->setPosition(s.width*2/6, s.height/2);
_label2->setPosition(s.width*3/6, s.height/2);
_label3->setPosition(s.width*4/6, s.height/2);
_label4->setPosition(s.width*5/6, s.height/2);
addChild(_label0);
addChild(_label1);
addChild(_label2);
addChild(_label3);
addChild(_label4);
// Sprite
auto sprite = Sprite::create(s_pathGrossini);
sprite->setPosition(VisibleRect::left().x + 40, VisibleRect::bottom().y + 50);
auto jump = JumpBy::create(3, Vec2(s.width-80,0), 50, 4);
addChild(sprite);
sprite->runAction( RepeatForever::create(Sequence::create(jump, jump->reverse(), nullptr) ));
// pause button
auto item1 = MenuItemFont::create("Pause", [&](Ref* sender) {
if(Director::getInstance()->isPaused())
Director::getInstance()->resume();
else
Director::getInstance()->pause();
});
auto menu = Menu::create(item1, nullptr);
menu->setPosition(s.width/2, s.height-50);
addChild( menu );
}
开发者ID:AnySDK,项目名称:Sample_Lua,代码行数:86,代码来源:IntervalTest.cpp
示例16: createFlames
void LevelTwo::createFlames(float dt)
{
for (int i = 0; i < 9; i++)
{
auto spritecache = SpriteFrameCache::getInstance();
spritecache->addSpriteFramesWithFile("GameScreen/fireList.plist");
cocos2d::SpriteFrame* spriteFrame = spritecache->getSpriteFrameByName("fire1.png");
cocos2d::Vector<cocos2d::Sprite *> m_aiSprites;
cocos2d::Vector<cocos2d::SpriteFrame*> m_animFrames;
for (int j = 1; j < 27; j++)
{
// Get a SpriteFrame using a name from the spritesheet .plist file.
m_animFrames.pushBack(spritecache->getSpriteFrameByName("fire" + std::to_string(j) + ".png"));
}
// Create the animation out of the frames.
Animation* animation = Animation::createWithSpriteFrames(m_animFrames, 0.065);
Animate* animate = Animate::create(animation);
// Create a sprite using any one of the SpriteFrames
// This is so we get a sprite of the correct dimensions.
auto sprite = Sprite::createWithSpriteFrame(m_animFrames.at(0));
// Run and repeat the animation.
sprite->setScale(2.0f);
sprite->runAction(animate);
auto fireBody = PhysicsBody::createBox(sprite->getContentSize(), PhysicsMaterial(0, 0, 0));
if (i == 0)
{
sprite->setPosition(Vec2(600, 420));
sprite->setTag(21);
//fireBody->setCollisionBitmask(0x000101);
//sprite->setPhysicsBody(fireBody);
}
else if (i == 1)
{
sprite->setPosition(Vec2(770, 420));
sprite->setTag(22);
//fireBody->setCollisionBitmask(0x000201);
//sprite->setPhysicsBody(fireBody);
}
else if (i == 2)
{
sprite->setPosition(Vec2(940, 420));
sprite->setTag(23);
//fireBody->setCollisionBitmask(0x000301);
//sprite->setPhysicsBody(fireBody);
}
else if (i == 3)
{
sprite->setPosition(Vec2(600, -20));
sprite->setTag(23);
//fireBody->setCollisionBitmask(0x000301);
//sprite->setPhysicsBody(fireBody);
}
else if (i == 4)
{
sprite->setPosition(Vec2(940, -20));
sprite->setTag(23);
//fireBody->setCollisionBitmask(0x000301);
//sprite->setPhysicsBody(fireBody);
}
else if (i == 5)
{
sprite->setPosition(Vec2(100, 260));
sprite->setTag(23);
//fireBody->setCollisionBitmask(0x000301);
//sprite->setPhysicsBody(fireBody);
}
else if (i == 6)
{
sprite->setPosition(Vec2(130, 130));
sprite->setTag(23);
//fireB
|
请发表评论