GMS 2 camera_set_view_size changes view position

ricardo1996

Member
Im trying to implement a zoom effect but having issues with my gui also being zoomed in on. i thought using 2 viewports would solve the issue but to avail. any help please.
 

Rob

Member
Bear in mind that views are drawn from the top left, not the center.

You need to get half of the old / new view height and half of the old / new view width.

Work out where the center point of the view is with the old half view width/height then set the new view coordinates to the new half view width/height and change the view size.

I would just change the size of the view rather than using different viewports.

One thing I usually do with zooming is have a zoomLevel variable, set to 1 initially, and multiply that value by half of the initial view width/height whenever zooming out so when zoomLevel = 2, the view will show double the area, and when zoomLevel = 3, the view will show triple the area, etc etc.
 
Last edited:

ricardo1996

Member
Bear in mind that views are drawn from the top left, not the center.

You need to get half of the old / new view height and half of the old / new view width.

Work out where the center point of the view is with the old half view width/height then set the new view coordinates to the new half view width/height and change the view size.

I would just change the size of the view rather than using different viewports.

One thing I usually do with zooming is have a zoomLevel variable, set to 1 initially, and multiply that value by half of the initial view width/height whenever zooming out so when zoomLevel = 2, the view will show double the area, and when zoomLevel = 3, the view will show triple the area, etc etc.
im aware of the x,y positioning.

il be abit more clear. I manually created button objects and drew sprites in the Draw Event that moves in correlation with view[0] with offsets (my gui layer).
im zooming in by: camera_set_view_size(view_camera[1], og_xsize*zoom, og_ysize*zoom); , but view[0] is being effected aswell by distorting the images.

im thinking its a camera issue im using 1camera 2ports.

edit: Its a mobile game so im using objects instead of virtual keys for multiple inputs.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Moderator
Why use two views when you have the GUI layer? The whole point of the GUI layer is to prevent issues like this happening as it gives a fixed layer of drawing that isn't affected by cameras or view ports. So, just use the Draw GUI events for the buttons. :)
 

ricardo1996

Member
Why use two views when you have the GUI layer? The whole point of the GUI layer is to prevent issues like this happening as it gives a fixed layer of drawing that isn't affected by cameras or view ports. So, just use the Draw GUI events for the buttons. :)
Edit: its not the drawing of the buttons thats the major issue. its the button object x/y co ordinance.
it checks for device_mouse x/y meeting
 

ricardo1996

Member
abit late but i decided to redue my gui draw events etc ,and went ahead and use this method.
Why use two views when you have the GUI layer? The whole point of the GUI layer is to prevent issues like this happening as it gives a fixed layer of drawing that isn't affected by cameras or view ports. So, just use the Draw GUI events for the buttons. :)
Thanks again il mark as solved.
 
Top