#1 By: RishabhShah, January 3rd, 2012 05:24
Hello guys. I am new to cocos2d and i am making game in it. In game i have one laser light i want this laser light reflect when it touches any surface. Suppose we take a mirror as surface so when laser light touch mirror then it change the direction or reflect according to that surface. So is there any code or logic same like this game . Guys please help me. and i don't know chipmunk and box2d so is this possible to make this game without box2d or chipmunk?
#2 By: Scryb, January 3rd, 2012 06:07
I actually don't think those two physics engines can handle light, so you have to do it on your own. But I'm not sure you're really looking to actually simulate reflection. Maybe a simple approximation using angles would work just as well? Then you would do some kind of collision detection and then just calculate the angle by which it hits and reflect in the opposite direction. If your surfaces are rounded this might be a bit tricky, but only from a mathematical point of view – the programming should be fairly straight forward.
I've never done light rays myself so I have no example code, but this is what I would use as a starting point.
#3 By: RishabhShah, January 3rd, 2012 06:26
If any body will know about this then please help me.
@scryb - Thanks for your answer. i will try and if i will get the code then i will post.
#4 By: jyoung, January 4th, 2012 02:25
Angle of incidence = angle of reflection. No physics engine needed until you are traveling through nonlinear media.