room_width

Note: This function is read-only, you cannot use this function to change the size of the room.

 

This function holds the width of the entire room (you need to use view_wview to get the size of the view inside the room). You can use this in a variety of ways:

 

Example #1

widthofroom = room_width;

 

This will return the width of the room in pixels (640 if it's the default room width)

 

Example #2

// Create an object at the right hand side of the room

instance_create(room_width,100,obj_player);

 

In the example above, as you're using room_width, no matter what size the room is, the object will always be placed at the right-hand side. You can also use room_width to center objects on screen. First, make sure the origins of the object is in the center then you divide room_width by 2:

 

Example #3

// Create and center the object horizontally in the room

instance_create(room_width/2,100,obj_player);

 

Revision #2