[Cocos2d-x game engine development notes (17)] Achieve the tail effect of Sports

Source: Internet
Author: User

Original article, reproduced please indicate the source: http://blog.csdn.net/zhy_cheng/article/details/8434598

To make the moving object have a tail effect, you can use ccmotionstreak.

Here I use [Cocos2d-x game engine development Note (12)] particle system to achieve user interaction with the example of special effects, making the effect more cool.

Add the following to the header file:

Ccmotionstreak * strike;

Then add the following code to the init function:

Strike = ccmotionstreak: streakwithfade (1.0f, // The duration of the tail: 16366f, // the size of the tail: 16366f, // the size of the image: ccc3 (255,255, 0 ), // color "sprite.png" // used image); addchild (Strike, 1); strike-> setposition (CCP (240,160 ));

Then change the position in the cctouchmoved function.

Strike-> setposition (ptouch-> getlocation ());

Set the position in the cctouchbegan Function

Strike-> setposition (ptouch-> getlocation ());

Okay, I'm done. The following figure shows the running effect on the G2 mobile phone of my Jiayu.

Source code download: Click to download


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.