Camera zooming and touch points
reddotinc
Member Posts: 653
Hey guys,
I'm playing around with some zooming techniques at the moment (FMG's Camera Tricks - great work!) and come across a little issue where when I zoom my view out (to double the size to reveal the whole scene) the touch points for the actors (buttons etc) are scaled with the camera, but not the original actors.
So to explain better, If i have a button in the top right of my screen (normal view) then zoom out, the button remains in the centre of the screen (smaller) but the touch point is scaled to the top right of the screen (zoomed out).
Obviously this is because the touch is registered on the screen level, but the graphics aren't portrayed that way.
Does anyone know of a way to keep the touches relative to the actors (the images of said actors?) as the screen is zoomed?
Thanks for any help!
// red.
I'm playing around with some zooming techniques at the moment (FMG's Camera Tricks - great work!) and come across a little issue where when I zoom my view out (to double the size to reveal the whole scene) the touch points for the actors (buttons etc) are scaled with the camera, but not the original actors.
So to explain better, If i have a button in the top right of my screen (normal view) then zoom out, the button remains in the centre of the screen (smaller) but the touch point is scaled to the top right of the screen (zoomed out).
Obviously this is because the touch is registered on the screen level, but the graphics aren't portrayed that way.
Does anyone know of a way to keep the touches relative to the actors (the images of said actors?) as the screen is zoomed?
Thanks for any help!
// red.
Comments
Obviously the touch sensor is off when the screen is zoomed. So, you have to figure out the offset, based on the zoom, and then constrain an invisible actor to the offset. Then, change all your actors to respond to collisions to the invisible offset actor, rather than just a touch.
// red.
CameraOrigin.x + Touch.x * (CamSizeWidth / DisplayWidth)
http://gamesalad.com/game/play/79899
// red.