• 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!

GameMaker SOLVED How do I assign display width to a variable?

M

Mobie

Guest
I have an idea for code that might center my game in any browser, but I need to assign the display width to a variable to do it. When I try use display_get_width to do it, I get this error message:

Object: obj_main_menu_text Event: Step at line 2 : cannot use function/script name for a variable, using "display_get_width"

I know GMS2 has built in settings to center and size your window, but they don't work in HTML5. (at least, I can't get them to work)
Code:
w = display_get_width
 

Simon Gust

Member
since this is a function instead of a variable (you can see from the "get" in the name) you have to add brackets to the end like you would do for your own scripts.
Look at the color coding of these and they tell you wheter they are a function or a variable
Code:
// functions
width = display_get_width();
time = get_timer();
red = color_get_red(color);

// variables
vis = visible;
spr = sprite_index;
spd = speed;
It is confusing because some functions don't take arguments for you to input.
 
M

Mobie

Guest
since this is a function instead of a variable (you can see from the "get" in the name) you have to add brackets to the end like you would do for your own scripts.
Look at the color coding of these and they tell you wheter they are a function or a variable
Code:
// functions
width = display_get_width();
time = get_timer();
red = color_get_red(color);

// variables
vis = visible;
spr = sprite_index;
spd = speed;
It is confusing because some functions don't take arguments for you to input.
Oh my gosh, I feel dumb. (not the first time for that) Thanks so much.
 
Top