• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GM8: Having problems changing the background.

Hey guys!

I am kind of new to gml.
I know the basics and currently I'm practising a lot and experimenting with new things. I (still) use Game maker 8. But now to my problem:

I was creating a pause menu consisting of an extra room, which is displaying a screenshot of the current view as background. Everything so far works very well, but I want to restore the previous background.
My persistent controller object manages the pausing. When I press the esc button, it saves 4 variables.
1. obj_Player.x
2. obj_Player.y
3. Current background
4. Current room id

I have 4 buttons in that pause room.
1. Continue
2. Save
3. Settings
4. Back to main menu

What I did for the first button was simply:

Sending the player back to the previous room with his last coordinates and replacing the screenshot background with the old background I was storing in that variable. All of these variables are global and everything works just fine. Except for replacing the background. I didn't know how to either refresh or dispose the background before drawing a new one.
What I have now is, that when I draw the old background, it overlaps with itself and creates weird pixels...
I'm currently not able to show you my code, cause I'm on the phone, but I would really appreciate you recommending me different methods on how to avoid getting this problem.

I already tried deleting the current (screenshot) background and creating the old one. I read about using surfaces, but I don't quite understand how that works.

P.S.: I think this problem only appears, when I pause the game while jumping / falling. Might be something else tho.
 

Fabseven

Member
Woah i donot think go in another room and comeback is a good solution for a menu but i am still new to gm as well ...
In my project a created an object obj_system_heros.

create event : calculation of the xpos1,xpos2 of the button and ypos1, ypos2, definition of the sprite to use and text , boolean button_pressed
draw gui event : drawing the button at xpos1,ypos1 using draw_sprite + draw_text to get draw the text
step event : code to see if the position of the mouse is in xpos1,xpos2 and ypos1,ypos2 (do not remember the funtions i used but i can paste the code later this day)
and so setting button_pressed to true if mouse click on the button
draw gui event: if( button_pressed ) { your code to draw the menu, buttons, etc)

+you could add some code in step even to toggle button_pressed from true to false or false to true so the menu will dissapear
+need to stop the object who are moving (use instance desactivate of set a global variable to false, the objet should stop if this variable is at false)
+ add your buttons and actions...


DEMO : https://www.wetransfer.com/download...b220a077b6a5d21256a34c6620161024213456/a5ba5f

after game launched click on the button "HEROS" at top-right of the screen, the menu heros appear and dissapear if pressed again. <end of the demo i wanted to show to you>
<if you want to see more 'cause you are curious> : the game is still under dev so donot except greats things. But you can build , pass to next day, fight if your are lucky with random but the game will crash if the QG of altar is destroyed
 
Last edited:
Thanks for your help. But i didn't understand all of it. What's the gui event? Does it only exist in GM: Studio? Cause I still use GM8.
I liked the room variant, and it also worked well so far.. :/
Maybe I will have to use another method. Thanks for your reply!
 
Top