S
SlightlyAngryGMLUser
Guest
Hello,
I'm my past free time I have been making a game using Gamemaker Studio 1 and I would like to add an pause function. Because of the fact that I have a lot of different objects which are all inherently different I have searched for an easy solution where I do not have to add a lot of code to each object but where I could 'carpetbomb' them all with one function.
The function I came up with is the instance_deactivate_all() function and to unpause the instance_activate_all() function, which both work perfect. While everything is paused I would like to have a screenshot of the game in the background with the words paused on it. The word paused was easy enough to do, and the screenshot too, or so I thought.
Using the function Create_sprite_from_surface I made a sprite which i wanted to draw on the screen. However, it would always snap to the top left of the room, no matter if I used draw_sprite or draw_sprite_ext. Then I thought I would use an object and give it the screenshot as a sprite. That didn't work, because it still snapped to the top left of the room. When I give this object an arbitrary sprite, a yellow square for example, it however does appear in the middle of the screen, which it should. (This is because using the create_sprite function, i give the screenshot I create it's origin in the middle) Is there something dumb which I missed or is there something buggy with the Create_Sprite_From_Surface function?
The key_pressed(p) where the pause function is started
(It will always be in the room Town)
My views are 960x540 and the room is 1024x928
View[0] is following the obj_player
View[1] is following the obj_dash (a mechanic in my game where you can dash)
View[2] is following the obj_pause
As I earlier said, when I comment out the line "sprite_index = spr_screenShot" then the object does appear correctly in the middle of the screen.
Any help would be appreciated. If you have another, better way of pausing the game, I would like to hear them!
I'm my past free time I have been making a game using Gamemaker Studio 1 and I would like to add an pause function. Because of the fact that I have a lot of different objects which are all inherently different I have searched for an easy solution where I do not have to add a lot of code to each object but where I could 'carpetbomb' them all with one function.
The function I came up with is the instance_deactivate_all() function and to unpause the instance_activate_all() function, which both work perfect. While everything is paused I would like to have a screenshot of the game in the background with the words paused on it. The word paused was easy enough to do, and the screenshot too, or so I thought.
Using the function Create_sprite_from_surface I made a sprite which i wanted to draw on the screen. However, it would always snap to the top left of the room, no matter if I used draw_sprite or draw_sprite_ext. Then I thought I would use an object and give it the screenshot as a sprite. That didn't work, because it still snapped to the top left of the room. When I give this object an arbitrary sprite, a yellow square for example, it however does appear in the middle of the screen, which it should. (This is because using the create_sprite function, i give the screenshot I create it's origin in the middle) Is there something dumb which I missed or is there something buggy with the Create_Sprite_From_Surface function?
The key_pressed(p) where the pause function is started
Code:
if instance_exists(obj_pause)
{
with (obj_pause)
{
sprite_delete(spr_screenShot)
instance_destroy()
}
instance_activate_all();
view_visible[2] = false
if instance_exists(obj_dash)
{
view_visible[1] = true
}
else
{
view_visible[0] = true
}
}
else
{
if room = Town
{
if instance_exists(obj_dash)
{
global.xx = obj_dash.x
global.yy = obj_dash.y
view_visible[1] = false
}
else
{
global.xx = obj_player.x
global.yy = obj_player.y
view_visible[0] = false
}
instance_create(clamp(global.xx,480,544),clamp(global.yy,270,658),obj_pause);
with (obj_pause)
{
spr_screenShot = sprite_create_from_surface(application_surface,clamp(global.xx-480,0,1024-960),clamp(global.yy-270,0,928-540),960,540,0,0,480,270);
sprite_index = spr_screenShot
}
instance_deactivate_all(1)
instance_activate_object(obj_pause)
view_visible[2]= true
}
}
My views are 960x540 and the room is 1024x928
View[0] is following the obj_player
View[1] is following the obj_dash (a mechanic in my game where you can dash)
View[2] is following the obj_pause
As I earlier said, when I comment out the line "sprite_index = spr_screenShot" then the object does appear correctly in the middle of the screen.
Any help would be appreciated. If you have another, better way of pausing the game, I would like to hear them!