Author Topic: How to load a changed background inside the room?  (Read 1157 times)

l3agu32

  • Wannabe
  • Posts: 22
  • OS:
  • Windows 8.1/Server 2012 Windows 8.1/Server 2012
  • Browser:
  • Chrome 48.0.2564.109 Chrome 48.0.2564.109
    • View Profile
  • Playstyle: Keyboard
How to load a changed background inside the room?
« on: February 19, 2016, 10:44:43 AM »
I'm using game maker studio. In my game I put the option to change the background_index when you're inside the room, but when I load the game pressing R, the original background appears again. I want to know how to save the background changed when saving the game, so that when loading, the background_index changed is what appears instead of the original background.
« Last Edit: February 19, 2016, 10:49:54 AM by l3agu32 »

Smartkin

  • Wannabe
  • Posts: 11
  • Your average nerd
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 48.0.2564.109 Chrome 48.0.2564.109
    • View Profile
  • Playstyle: Keyboard
Re: How to load a changed background inside the room?
« Reply #1 on: February 19, 2016, 03:20:58 PM »
I suggest creating some sort of flag for example "global.BCGchanged". Then change it to 1 when you change background index. After that in the save game script add "global.BCGchanged":

file_bin_write_byte(f,global.BCGchanged)

In load game scrypt(Usually presented as saveExe) assign the previously saved value to the global.BCGchanged:

global.BCGchanged = file_bin_read_byte(f);

Remember to have them at the same position if you save it after global.item[X] then load it at the same position. Idk if it is necessary in Studio since I work in 8.1 but test both in any case.

Then in room Creation Code:

If global.BCGchanged
background_index[0] = (your background index);

If you want to have multiple changes can have it into array.
Hope it worked and good luck making fangames  :atkHappy:
Yuno Gasai is my waifu :^)

(click to show/hide)