• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code [SOLVED] Pause menu with background sprite from application_surface

MartinK12

Member
Hi guys,
I'm playing with the tutorial for GMS2 and I added to the game obj_pausemenu with this code:
1. In the CREATE event:
Code:
pause = 0;
2. In the DRAW event:
Code:
var camx = camera_get_view_x(view_camera[0]);
var camy = camera_get_view_y(view_camera[0]);
var camw = camera_get_view_width(view_camera[0])
var camh = camera_get_view_height(view_camera[0])

if ((keyboard_check_pressed(ord("P")))) and pause=0
{
    pausebackground = sprite_create_from_surface(application_surface,camx,camy,camw,camh,false,false,0,0);
    pause = 1;
    instance_deactivate_all(true);
}
else if ((keyboard_check_pressed(ord("P")))) and pause=1
{
    sprite_delete(pausebackground);
    pause = 0;
    instance_activate_all();
}

if (pause=1)
{
var cam2x = camera_get_view_x(view_camera[0])
var cam2y = camera_get_view_y(view_camera[0])
draw_sprite(pausebackground,1,cam2x,cam2y);
draw_text(camx,camy,"PAUSE MENU");
}
That is the only code in this object and it does what is suppose to do except draw_sprite. When I don’t move the camera view it is drawn perfectly, but when I move camera to the right it looks like it's still at 0,0 coordinates of the room. But this code works fine with:
draw_text
or even with every sprite from game ie.:
draw_sprite(spr_player

They are drawn regardless of the camera view exactly in the view where I want them. What am I doing wrong with this pausebackground sprite?

I think I’ve tried everything: different codes from net, step event, draw GUI events etc. And every time the same - I can draw text and normal game sprites wherever I want them but I can’t draw this pausebackground sprite in the wanted location.

I appreciate any help bcs after few hours of tries I’m really tired with this code :(

EDIT:
I managed to do this another way.
 
Last edited:
Top