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?
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.