TAGS :Viewed: 4 - Published at: a few seconds ago

[ How can I make a static path after sprite in cocos2d-iphone? ]

There is a sprite (paper plane) that "flows in the air". I'd like make a path that follows after (look below) but it should be static(not moving together with paper plane, just appearing after it). I supposed just to make a long sprite with the path, but in this way it would move too, and it's not so nice. Also, it should dissapear at the same time as sprite. (cocos2d-iphone 3.0)

How can I implement it?

enter image description here

Answer 1

What you could do is schedule an update method that runs every second (or faster) that checks the plane's center and adds a small line underneath the plane's center position.

You also store the new sprite in an array and when the plane disappears from the screen you loop through the array and remove each sprite from the screen.

Hope that helps

Answer 2

You can give this kind of effect by using CCMotionStreak

CCTexture2D *mytexture=CCTextureCache::sharedTextureCache()->addImage("plane_path.png");
CCMotionStreak *motion_plane =CCMotionStreak::create(5,1,20,ccc3(255,0,0),mytexture);

Now u only need to set position of motion streak according to plane and it will show path with fading effect. it will look great . hope you understand.

Answer 3

I use Cocos2DX 2.2.X Version. I used CCMotionStreak for this kind of effect. I think that version also has it whatever you are using. Just have a look on that class you will get to know how to use it.