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颜色和文件名。
基本的拖尾效果可以通过这些实现,但是一个可以拿来当做完整的技能拖尾,还是需要很多改变。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。