SOLVED Screen draw issue after deactivating object for pausing

Hi all! I'm working on a game that uses the Box2D physics. So, for pausing, I'm using the functions physics_pause_enable and then instance_deactivate_all and I then create a pause controller object which works fine for controlling the pause menu - functionally everything is good, this issue is purely graphical.

The issue is that the active objects within the pause menu don't stop drawing if they are destroyed/aren't visible etc. I assume this is because they're overlaid on deactivated objects, but I'm not sure what the remedy is redraw the screen beneath these active objects properly. Is there a technique to ensure objects are drawn properly above deactivated ones?

Thanks for reading,
 

Damderiam

Member
When you say they "don't stop drawing", do you mean they leave trails/duplicates when they move?

Have you tried setting visible to false before deactivating the physics objects? I have no idea if that would work, but it's a thought.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I'll be honest and say that your post confuses me and I can't begin to visualise what you're talking about! Could you give more info please? Like a screenshot or a GIF as well as an idea of how you're drawing the menu.
 

Slyddar

Member
Does the room with the pause have a background layer, or are you using an object with a large sprite to draw the background. If you have no background, add one with a black colour and that should help.
 
Sorry for not explaining this better! Here's a gif that demonstrates the issue

pause_menu.gif

Note how the quit menu is drawn on top of the other menu buttons and visa-versa. These objects are being destroyed, so they shouldn't be displayed, yet, somehow, they are.

I tried creating a separate layer dedicated to just these pause menu objects but to no avail. I assume it has something to do with the deactivated objects, but honestly I'm not sure.

Thanks for reading!
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I assume you're drawing a surface for the background after you've deactivated stuff? Could it be that the button objects and things are also being drawn to this surface so that when they are destroyed they are still visible?
 
Hmmm nope no surfaces are involved here, that's what so odd! Does GM2 have like a build-in surface or shader or something its using that I'm not aware of?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Hmmm nope no surfaces are involved here, that's what so odd! Does GM2 have like a build-in surface or shader or something its using that I'm not aware of?
Nothing that would cause this issue, no. I mean, EVERYTHING you draw goes through a default shader, but that's internal to GMS and is definitely not the issue here. Have you run the game in the debugger and made 100% sure the instances you think should be there ARE actually there? And in the correct amounts? Also, add liberal show_debug_message calls into the game code so you can track when things are created, updated and destroyed to ensure it's all working as planned.
 

8BitWarrior

Member
This is staying the in the same room? You're not going to a paused room or anything?
Are you drawing to the GUI layer?
 
Ok a believe I see what's going on here - this is a result of camera_set_view_pos. I'm having the camera gently sway up and down during gameplay. I forgot to activate it for the pause menu, here's what it looks like now that the camera controller object is active while paused

screen_sway.gif

Note how the white of the buttons bleed on the top and bottom as a result of the camera moving up and down. I'm guessing that GM2 creates some type of surface for the camera position that I'm neglecting here?
 

8BitWarrior

Member
Does the camera have "Clear Viewport Background" enabled in the room editor.
Otherwise, I'm wondering if calling draw_clear_alpha(c_white, 0) before drawing menu stuff would help out.
 
Top