Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 26th Mar 2011 15:42 Edited at: 26th Mar 2011 16:18
Hello, I'm making a 2d game with a camera that can zoom in and out. I use the following function to get the screen coordinates of a position based on the camera's position and level of zoom.



But I can't figure out a way to find the actual world position based on given screen coordinates, I assumed I would just reverse the function, but it didn't have the expected results.

Is anybody good with maths that could help? :p

Also, the zoom function doesn't zoom towards the centre of the screen, it zooms towards the corner, can anybody tell me how to make it zoom in the centre?
Thanks
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 26th Mar 2011 23:53
I made a 2d camera system and posted it in code snippets. It's nice, because it handles movement and zoom for you. I also had one that handled rotation.
http://forum.thegamecreators.com/?m=forum_view&t=172082&b=6

(I started to write up a bit about what I was doing, but I can't really express it in a smallish post, so I think I'll write up a tutorial on it and post the link here)

Login to post a reply

Server time is: 2026-07-16 23:19:22
Your offset time is: 2026-07-16 23:19:22