I want to convert the camera coordinate to screen coordinate. I have asked this question because my camera is 48m wide and 32m high but my screen is 480x320 pixels. So whatever collision point I get those are based on camera. Also I like to mention that my camera set at center of the screen. So I get (0,0) coordinate at middle of the screen. At collision time I put some particle effect but now that particle effect not at correct place in the screen. So someone from community please help.
Tell me more
×
Game Development Stack Exchange is a question and answer site for
professional and independent game developers. It's 100% free, no registration required.
|
How about using the project-method in the camera class.
That projects the vector cameraPoint from world/camera coordinates into screen/window coordinates. The reverse method is camera.unproject(Vector3 screenPoint). Have a look at the libgdx camera class. |
|||
|
|
|
What you need to do is to translate the camera coordinates into viewspace. In this particular case your Camera coordinates go from [-24,-16] to [24,16] and you want that to translate to [0,0] to [480,320]. Pseudo code:
|
|||
|
|
|
Taken from http://www.badlogicgames.com/wordpress/?p=2032 I'm only assuming that this will help based on your question...
|
|||
|
|
