Backgrounds

This section deals with the functions relating to background assets.

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".

Background Variables

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().

  1. background_index[0..7]
  2. background_visible[0..7]
  3. background_alpha[0..7]
  4. background_blend[0..7]
  5. background_x[0..7]
  6. background_y[0..7]
  7. background_colour
  8. background_showcolour
  9. background_foreground[0..7]
  10. background_hspeed[0..7]
  11. background_vspeed[0..7]
  12. background_htiled[0..7]
  13. background_vtiled[0..7]
  14. background_width[0..7]
  15. background_height[0..7]
  16. background_xscale[0..7]
  17. background_yscale[0..7]

Background Information

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.

  1. background_get_name
  2. background_get_width
  3. background_get_height
  4. background_get_texture
  5. background_get_uvs

Background Manipulation

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.

  1. background_exists
  2. background_add
  3. background_replace
  4. background_duplicate
  5. background_assign
  6. background_create_colour
  7. background_create_gradient
  8. background_create_from_surface
  9. background_set_alpha_from_background
  10. background_save
  11. background_delete
  12. background_flush
  13. background_flush_multi
  14. background_prefetch
  15. background_prefetch_multi

Background Tiles

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:

  1. Background Tiles


Back: Game Assets
© Copyright YoYo Games Ltd. 2018 All Rights Reserved