Reflect laser light using cocos2d

Forums Programming cocos2d support (graphics engine) Reflect laser light using cocos2d

This topic contains 3 replies, has 3 voices, and was last updated by  jyoung 2 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
Author Posts
Author Posts
January 3, 2012 at 5:24 am #238121

RishabhShah
@rishabhshah

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?

January 3, 2012 at 6:07 am #360848

Scryb
Participant
@scryb

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.

January 3, 2012 at 6:26 am #360849

RishabhShah
@rishabhshah

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.

January 4, 2012 at 2:25 am #360850

jyoung
Participant
@jyoung

Angle of incidence = angle of reflection. No physics engine needed until you are traveling through nonlinear media.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.