• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Changing camera size

J

Joe Banko

Guest
I have 2 scripts:
zoom_in.gml

var cam = view_get_camera(0);
var xx = camera_get_view_width(cam);
if xx == 1024 {
camera_set_view_size(view_camera[0],512,256);
}
if xx == 2048 {
camera_set_view_size(view_camera[0],1024,512)
}

and zoom_out.gml

var cam = view_get_camera(0);
var xx = camera_get_view_width(cam);
if xx == 1024 {
camera_set_view_size(view_camera[0],2048,1024);
}
if xx == 512 {
camera_set_view_size(view_camera[0],1024,512);
}

zoom_in is called when I press pagedown and zoom_out is called when I press pageup. But the code never executes anything but the xx == 1024 branch. I am baffled by this and have tried using an else if between the two statements as well as changing the ordering i.e. in zoom_in checking xx == 2048 before xx == 1024, I was still getting the same result. Going into the debugger I found that xx always equalled 1024 even though on the screen I could see the changes going between 2048 and 512.

Any ideas/suggestions?

Thanks, Joe B
 

Psycho_666

Member
Last time I tried changing view size on the fly it didn't work.
Setting view size only works at room start. I have absolutely no idea how you can zoom in and out in real time, but I resized my views using a transitional room. I go to the new room and when I come back - I set the new view size.
 

HayManMarc

Member
There's nothing in your example showing how the xx variable is being changed and manipulated. You will need to show the code that changes the xx value.

Wait... i see it. Its your view width. You need to track down why your camera_get_view_width is not changing.
 
J

Joe Banko

Guest
Thank you gentlemen!
@Psycho_666 I can get it to zoom in and out but what I think is happening is the value I get from camera_get_view_width is always the original value setup in the room editor, 1024. In the docs it says "Note that this function is only valid for cameras created using camera_create_view() or for those added in the room editor." So I don't think there is a way to get the CURRENT view width which is a bummer. But I'm just on my first real foray into DMS2 from "scratch" using stuff I picked up in a tutorial and examples I've gotten from docs and this forum. Thanks again, appreciated!

Joe B
 
Top