GameMaker view_xview and view_yview

B

Blakkid489

Guest
So umm how do I use this in GMS2? I mean I'm glad there's a better control on the camera in GMS2 but those old functions were functions I was used to using since game maker 6.

How do I draw stuff related to the current view in the room?
 
B

Blakkid489

Guest
I haven't been a fan or even tried to understand the use of var but, I guess it's time to start learning
 
A

Ampersand

Guest
var is for all those variables that you use within one code block. If something does not get accessed anywhere else you initialise it locally so the memory will only be used within that section. It's a good technique to get in the habit of, not necessarily crucial though.
 

gnysek

Member
Lets treat a "var" as a variable which is created when you define it, and removed from memory at end of current event, so it cannot be accessed by other objects/events. In other way, you can call "var" as "temporary".

(In previous GM versions, it was more narrow, but since GMS 1.x is merging all D'n'D actions, and GMS2 does same, I'm not bringing it here).
 
B

Blakkid489

Guest
Thank you! I did some studying on this and got what I wanted (for the most part), but now it has me questioning. . .
If I were to transfer my previous GMS 1.4 game to GMS2, how would that conversion work? Would I have to change the code myself to the new camera functions?
 

FrostyCat

Redemption Seeker
var is for all those variables that you use within one code block. If something does not get accessed anywhere else you initialise it locally so the memory will only be used within that section. It's a good technique to get in the habit of, not necessarily crucial though.
Given how often I witness the consequences of using var poorly on the Q&A sections, I hate it when people downplay the importance of its proper use.

People who fail to use var properly tend to have trouble with these:
  • Losing variables across events (by using var where it shouldn't be)
  • Carrying variable values into with blocks
  • Recursive script calls cross-interacting with each other
  • Loop variables cross-interacting with script calls inside
  • Filthy instance scopes that waste memory and look like a pig sty in debug
I suggest that you do novices a favour and retract the "not necessarily crucial" part of your statement. It's never OK to be ignorant about scope.
 
A

Ampersand

Guest
I think if your only goal is to learn Game Maker, don't worry about it, but if you're looking to actually learn to program there are no languages as forgiving as GML syntax-wise and this is one of many very bad habits Game Maker lets you get away with.
 
A

Ampersand

Guest
If I were to transfer my previous GMS 1.4 game to GMS2, how would that conversion work? Would I have to change the code myself to the new camera functions?
This is my understanding, given the changes from the view system to the new camera system, yes you will need to modify it. But GM:S2 does have a script converter, and given the core support of the camera and view systems respectively, I'm sure 2 will give you conversion scripts when you import it.
 
Top