GameMaker [SOLVED] x and y of the currently visible part of the room

A

Ark

Guest
I'm working on a platformer. I have a big room - 2x3 screens in size. The camera (or the view) (or them both) is following the character. (this camera/view thing is super confusing... I read and read again, but I don't understand it... To me it's either views or cameras... I don't know why they exist at the same time...).

I want this: when you press a certain button an object appears on the screen on the x and y of the currently visible part of the room.
I'm trying view_xport[0], but it always gives me the starting point of the view, which is zero.
I'm trying camera_get_view_x(view_camera[0]) and the result is the same.

How can I get the x and y of the currently visible part of the room (I mean the top left point)? Any way of doing this would work for me.
 

Tornado

Member
If your view is view 0 then this is the point in the top left corner of the view:
view_xview[0], view_yview[0]

So to say that is the 0,0 coordinate of the visible area of your room.

Bottom-right
view_xview[0]+view_wview[0], view_yview[0]+view_hview[0]

Bottom left
view_xview[0], view_yview[0]+view_hview[0]

Top right
view_xview[0]+view_wview[0], view_yview[0]
 
Last edited:
A

Ark

Guest
So... view_xport and view_xview are not one and the same! I'm even more confused now :D But huge thanks, Tornado! I'll try it now.
 
A

Ark

Guest
Ohh... That's why I couldn't find it. There is no "view_xview" in GMS2. Only "view_xport". :(
 

Tornado

Member
Ah sorry, I didnt see its GMS2, I'm still on GMS 1.4.
But anyway i guess it is more or less the same logic. A View is inside of the viewport. If you make a viewport bigger than view then view will be upscaled to the size of the viewport. If smaller the view will be downsized. If they are the same then no scaling happens.
 
A

Ark

Guest
Yeah, I too think the logic should be the same, but somehow it doesn't work the old way. It always gives me the starting point of the view (or viewport) (or camera) (or all of them at once...). :confused:
 

Tornado

Member
I checked gms2 docu, all those variables for view still exist, but I don't know how to set it up in GMS2 :(
 
A

Ark

Guest
That's probably an old manual for ver. 2.0.2.44. It's different for ver. 2.0.3.56. view_xview doesn't exist anymore :(

I'm still trying various things - nothing works and I can't see the reason. Tried to create another camera - the result was the same + it crushed on camera_destroy() multiple times in a row. I don't like the cameras so far :D
 
A

Ark

Guest
Yeah! I solved it. That's how I think... "Viewports" are more like windows - they don't move (or at least I haven't found a way to move them like views), there are no views anymore - instead I move cameras. The only way to get the current x of the visible part of the room I found is "camera_get_view_x(view_camera[0]);". I tried to do that several hours ago saving it as a global variable and using it for every object and every room (would be super convenient I thought), but no... It must be local each time I use it.
 
Top