Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

track the trajectory path in cocos2d

how to track the path of ball flowing motion in cocos 2d

For example in angry bird game video the bird flowing motion. they display the path. likewise i want

like image 264
Sri Avatar asked Nov 05 '10 17:11

Sri


2 Answers

You could accomplish this by using an NSTimer or CADisplayLink to repeatedly use the coordinates of the thing in its path of movement (e.g. 6 times a second) and display a small dot at that coordinate. The timer would begin, for example in angry birds, when the bird is first launched, and then stopped when the bird hits something.

  1. bird is launched (timer is created and method is called 6 times a second)
  2. Every 1/6 of second a dot is draw at the bird coordinate at that moment
  3. The timer is stopped when the bird hits something so no more dots are drawn
like image 94
Jeff w.. Avatar answered Oct 02 '22 13:10

Jeff w..


You could use the CCMotionStreak Cocos2d class which utilizes CCRibbon. Check out Riq's MotionStreak test on github (onEnter:)

like image 32
jbg Avatar answered Oct 02 '22 12:10

jbg