Backgrounds are another form of image asset that you can use in
GameMaker: Studio, and are split into two general
categories: background images and tilesets. Background images are
generally the large, static images that are used to form the back
of a room, with all other things being drawn over them, although
they can have other uses, while tilesets are background images that
are "cut up" into smaller pieces and used to add low cost graphical
images to a level. For example, in a platform game you may have
only one single floor object and then use a series of background
tiles to hide them and give each an individual "look".
The following global variables are built in to GameMaker: Studio and can be used to get information about a background asset as it is currently used within a room. Most of these variables can be set as well as read and so can be used to change the way backgrounds are displayed within the room, but any changes that they make to the background are not permanent and will be reset if the player leaves and enters the room again, or the game is restarted (unless the room is persistent). Please note that these all affect the current room only, but if you should need to set any of these values for another room you should be using the function room_set_background().
The following functions can be used to get information about a background asset. Please note that these functions get the information from the base background (ie. the background asset) and not from the background as it is being used in a room. For information on backgrounds that are being used in a specific room, see the section on "Background Variables" above.
The functions below are all related to changing the sprite asset (resource) itself. This means that the majority of these functions will affect all instances that reference the sprite being changed, it also means that you must take great care to ensure that a sprite exists before referencing it, or to make sure it is not being referenced before changing it.
The following section has all the different functions and variables that are related to background images when they are used to create tiles in a room:
- Background Tiles