Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphical effects like elastic tentacles in Contre Jour

I am wondering how beautiful is "Contre jour" game for IOS. Especially i like elastic "tentacles",shown in this video on 2 min 20 seconds: http://www.youtube.com/watch?v=ptdTdJarWLw

How can I implement such effects?

I know that there is technic called "Verlet integration" and even implementation of "verlet rope" for drawing ropes in cocos2d, but how to make such nice elastic effects to "tentacle" sprite?

I have experience of box2D usage, and may try to implement physics for this effect, but cann't find a solution how to draw sprite with such elastic morphing.

Can anybody help me or give some hints?

Just even explanation of technics, that can help me?

I have a little of experience in opengl, great cocos2d experience, so I plan to use cocos2d.

Sorry for bad english, I hope, you will understand my problem:)

like image 340
Alexander Tkachenko Avatar asked Apr 24 '12 11:04

Alexander Tkachenko


1 Answers

If you use Box2D, you could try a distance joint with the frequencyHz and dampingRatio options set to non-default values. Perhaps a low frequency of around 4-6, and a damping of around 0.5-0.7 could be a good point to start from. You could think of frequency as how many times per second the joint tries to correct the distance, and damping as how well the distance is corrected each time. Setting the damping to a value lower than 1 will means the joint will be slower to correct the distance, and it will have a springy/rubbery behavior.

As for rendering, you could indeed use verlet integration for this. Take the two anchor points of the distance joint as the endpoints of the 'rope', and put a handful of points (doesn't look like too many would be necessary) in between them in an evenly spaced line. Every timestep, the points in between will simply move towards the average of the two points on either side of themselves. You could make the rope look tighter or looser by adjusting how far the inbetween points move to the target position each time step.

The final texture/sprite rendering would then take its position from the current location of the verlet points.

like image 69
iforce2d Avatar answered Nov 01 '22 13:11

iforce2d