加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

cocos2d-x3.x的拖尾效果

发布时间:2020-12-14 19:28:15 所属栏目:百科 来源:网络整理
导读:作为一个实习,也就是传说中的码农,自身的代码基础也不够,所以暂时就不扒开底层对每个参数一一研究了,不过其实知道了api,完全可以通过自己查看一步步理解,每个函数底层代码里边都有注释。 MotionStreak类继承自node,所以,基本上可以当做node来使用;基
作为一个实习,也就是传说中的码农,自身的代码基础也不够,所以暂时就不扒开底层对每个参数一一研究了,不过其实知道了api,完全可以通过自己查看一步步理解,每个函数底层代码里边都有注释。

MotionStreak类继承自node,所以,基本上可以当做node来使用;基本上也比较简单,直接复制自己项目的代码了先

创建一个拖尾的节点,执行moveto,在move过程产生拖尾效果,最后到目的点时调用回调消除这个节点:

    auto streak=MotionStreak::create(10,5,20,Color3B(0,0),"bossdian.png");
    streak->setPosition(Point(800,900));
       auto moveto =MoveTo::create(0.3,Point(0,0));
       auto fun=[this](Node*psender)
        {
           auto streak=static_cast<MotionStreak*>(psender);
            streak->removeFromParent();
        };
       auto call=CallFuncN::create(fun);
        streak->runAction(Sequence::create(moveto,call,NULL));
       addChild(streak,200);

值得一提的时拖尾节点创建时的几个参数:

 /** creates and initializes a motion streak with fade in seconds,minimum segments,stroke's width,color,texture filename */
   staticMotionStreak* create(float fade,float minSeg,float stroke,constColor3B& color,conststd::string& path);

通过注释也不难理解:fade是这个拖尾效果消失的时间,也就是当节点走过某一个点时创建的这个尾巴在fade后消失;minseg表示拖尾和该节点的最小距离;stroke表示每条拖尾带的粗细;后面两个分别是rgb颜色和文件名。

基本的拖尾效果可以通过这些实现,但是一个可以拿来当做完整的技能拖尾,还是需要很多改变。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读