Transferred from: http://blog.csdn.net/zhy_cheng/article/details/8434598
Make the moving object have the effect of tail, can use Ccmotionstreak.
Here I use the "Cocos2d-x Game Engine Development Note (12)" Particle system to achieve the effects of user interaction with examples, making the effect more cool.
Add to the header file: [CPP] view plain copy print? Ccmotionstreak* strike;
Ccmotionstreak* strike;
Then add the following code to the INIT function: [CPP] view plain copy print? Strike=ccmotionstreak::streakwithfade (1.0f,//tail duration 16.0f,//tail size 16.0f,//picture size ccc3 (255,255,0),//Color "sprite.png"/ /images used); AddChild (strike,1); Strike->setposition (CCP (240,160));
Strike=ccmotionstreak::streakwithfade (1.0f,//tail duration
16.0f,//tail size
16.0f,//the size of the picture
ccc3 (255,255,0),// Color
"sprite.png"//pictures used
);
AddChild (strike,1);
Strike->setposition (CCP (240,160));
Then change position in the cctouchmoved function [CPP] view plain copy print? Strike->setposition (Ptouch->getlocation ());
Strike->setposition (Ptouch->getlocation ());
Set position [CPP] view plain copy print in the Cctouchbegan function Strike->setposition (Ptouch->getlocation ());
Strike->setposition (Ptouch->getlocation ());
Well, done, the following renderings are in my good domain G2 phone running effect
Source code Download: Click to download