Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Light Stream in cocos2d

I want to make light stream that move from starting point to ending point in my game. so how to make light stream in cocos2d? and also want to do reflection on that light stream when it touches any surface. so what is the logic to make light stream and doing reflection? any Idea?

help me..

like image 365
Rishabh Shah Avatar asked Nov 05 '22 05:11

Rishabh Shah


1 Answers

You could do something simple like draw a line with ccdrawLine. I've made lasers that simply draw a red line in this way. The other way is to use a particle system/emitter. I use Particle Designer by 71squared but there are others out there. Your options are endless in the ways you could make your beam look. You just have to experiment with the settings to get your desired effect.

As to the reflection, I use box2d and a ray cast. Have the ray cast start where the beam starts and then create a new beam on the first object it hits.

Here's a good tutorial on ray casts: http://www.raywenderlich.com/4653/intermediate-box2d-physics-forces-ray-casts-and-sensors

like image 62
tassinari Avatar answered Nov 09 '22 14:11

tassinari