码迷,mamicode.com
首页 > 其他好文 > 详细

cocos2d-x之action初试

时间:2016-02-29 15:58:55      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

bool HelloWorld::init()

{

    if ( !Layer::init() )

    {

        return false;

    }

    

    Size visibleSize = Director::getInstance()->getVisibleSize();

    Vec2 origin = Director::getInstance()->getVisibleOrigin();

 

    auto role=Sprite::create("fen.png");

    addChild(role);

    role->setPosition(visibleSize/2);

    role->setScale(0.5);

    

    role->setPositionX(100);

    //role->runAction(MoveTo::create(2,Vec2(visibleSize.width-100,visibleSize.height/2)));

    

    /*auto mov1=MoveTo::create(2,Vec2(visibleSize.width-100,visibleSize.height/2));

    auto mov2=MoveBy::create(2,Vec2(-1000,0));

    role->runAction(Sequence::create(mov1,mov2, NULL));*/

    

    /*auto mov1=MoveBy::create(2,Vec2(1000,0));

    auto mov2=mov1->reverse();

    role->runAction(Sequence::create(mov1,mov2,NULL));*/

    

    auto move=MoveBy::create(2,Vec2(1000,0));

    auto scale=ScaleTo::create(2,1);

    //role->runAction(Spawn::create(move,scale,NULL));

    

    role->runAction(Sequence::create(Spawn::create(move,scale,NULL),CallFunc::create([](){

        CCLOG("PLAY COMPLETED");

    }),NULL));

    

    return true;

}

 

cocos2d-x之action初试

标签:

原文地址:http://www.cnblogs.com/daochong/p/5227316.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!