cocos2d-x之action初试

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cocos2d-x之action初试相关的知识,希望对你有一定的参考价值。

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初试的主要内容,如果未能解决你的问题,请参考以下文章

cocos2d-x之物理按键初试

cocos2d-x之多点触碰初试

cocos2d-x之使用plist文件初试

cocos2d-x之json文件读取初试

cocos2d-x之加速度传感器初试

cocos2d-x之xml文件读取初试