Michelle Moonknight
Michelle Moonknight

Reputation: 21

The global.game_width not set before reading it

global variable name 'game_width' index (100009) not set before reading it.
at gml_Object_objTextbox_Create_0 (line 16) port_x = (global.game_width  
- box_width - port_width) * 0.5

The error Picture

I created in Game global.game_height and width, but it doesn't work. What am I supposed to do?

The error picture 2

Upvotes: 1

Views: 768

Answers (1)

Steven
Steven

Reputation: 2122

Looks like the objtextbox object is created earlier than the game object.
And because the game object creates the variable, it cannot find the global.game_width before it's initialised.

Inside the Text Layer Properties on the left sidebar, you'll see all the objects that are loading inside the room. The game object is not shown there, so you've to place the game object inside the room (and change the order they're loaded first) to let it work.

I'm not sure if this still applies as you've already rewrote your code, but that's something to remember for the next time.

Upvotes: 1

Related Questions