Cocos2d-x学习笔记4:移动、重复动作、组合动作

//移动
ccBezierConfig bezier;
    bezier.controlPoint_1 = Point(100, 0);
    bezier.controlPoint_2 = Point(200, 250);
    bezier.endPosition = Point(300, 50);
    BezierBy *bezierTo = BezierBy::create(4.0f, bezier);//BezierTo是坐标点,BezierBy是向x,y移动多少距离。
    sprite -> runAction(bezierTo);
//重复动作
//创建一个jumpBy动作对象
    JumpBy *jump = JumpBy::create(3.0f, Vec2(50, 1), 100, 1);
    //以jump为参数,创建一个永久性的重复动作
    RepeatForever *repeatForeverActiong = RepeatForever::create(jump);
    //以jump为参数,创建一个指定重复次数的动作
//    Repeat *repeatActiong = Repeat::create(jump, 3);
    sprite -> runAction(repeatForeverActiong);
//组合动作,动作一起播放。只需要把Spawn改成Sequence,动作就是一个接一个播放了。
//创建一个jumpBy动作对象
    JumpBy *jump = JumpBy::create(3.0f, Vec2(50, 1), 100, 1);
    //以jump为参数,创建一个永久性的重复动作
    RepeatForever *repeatForeverActiong = RepeatForever::create(jump);
    //以jump为参数,创建一个指定重复次数的动作
//    Repeat *repeatActiong = Repeat::create(jump, 3);
//    sprite -> runAction(repeatForeverActiong);
    // add the sprite as a child to this layer
    //创建一个移动动作对象
    MoveBy *moveBy = MoveBy::create(2.2f, Vec2(40, 20));
    //创建一个旋转动作对象
    RotateBy *rotateBy = RotateBy::create(2.5f, 20, 10);
    //创建组合动作对象,将所有动作连起来
    Action *actions = Spawn::create(repeatForeverActiong, moveBy, rotateBy, jump, NULL);
    sprite -> runAction(actions);
//
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容