Jump to content


Photo

Pause during a phone call?


  • Please log in to reply
14 replies to this topic

#1 WWAZman

WWAZman

    GMC Member

  • GMC Member
  • 709 posts
  • Version:GM:Studio

Posted 07 June 2012 - 05:30 PM

Was curious how to implement this, my game doesn't seem to pause correctly when I take a phone call (it keeps going) .. I have an old old pause script from GM7 but that of course doesn't take into account for phone calls.
  • 0

#2 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16795 posts
  • Version:GM:Studio

Posted 07 June 2012 - 05:37 PM

You need to check the value of os_is_paused... That will tell you, I believe.
  • 0

#3 WWAZman

WWAZman

    GMC Member

  • GMC Member
  • 709 posts
  • Version:GM:Studio

Posted 07 June 2012 - 06:13 PM

You need to check the value of os_is_paused... That will tell you, I believe.



ok... where do I check that at? Noobie here for droid stuff remember! ;)
  • 0

#4 PWL

PWL

    The non-pixel-artist

  • GMC Member
  • 686 posts
  • Version:GM:Studio

Posted 07 June 2012 - 10:59 PM

I guess that would be in the step event of something. Anything :P The player object or something.
  • 0

#5 filulilus

filulilus

    GMC Member

  • GMC Member
  • 928 posts
  • Version:GM:Studio

Posted 08 June 2012 - 10:54 AM

Haven't tried this but it should work (if Nocturnes instructions are correct :tongue:).
Just make a new object called obj_pause or something and use the following codes:
//Create event
pause = false

//Step event
if os_is_paused && !pause {
pause = true
instance_deactivate_all(true)
}

if !os_is_paused && pause
{
pause = false
instance_activate_all()
}

Edited by filulilus, 08 June 2012 - 10:55 AM.

  • 1

#6 rwkay

rwkay

    YoYo Games CTO

  • YoYo Games Staff
  • 1407 posts
  • Version:Unknown

Posted 08 June 2012 - 11:48 AM

You don't really need to do anything - while you are not the foreground app we pause for you (i.e. you do not get processed)... BUT Google reccomend that you put the game into a Paused mode (or state) so that when the player returns to your game they are not immediately thrown back into the game, but can unpause and then play.

So all you should do in the os_is_paused detection is place your game into its paused mode... no need to deactivate instances.

Russell
  • 0

#7 PWL

PWL

    The non-pixel-artist

  • GMC Member
  • 686 posts
  • Version:GM:Studio

Posted 08 June 2012 - 12:17 PM

So all you should do in the os_is_paused detection is place your game into its paused mode... no need to deactivate instances.

Wouldn't pausing your game BE deactivating instances and place a pause-screen on top of everything? :mellow:
  • 0

#8 rwkay

rwkay

    YoYo Games CTO

  • YoYo Games Staff
  • 1407 posts
  • Version:Unknown

Posted 08 June 2012 - 12:41 PM

@PWL - Only if that is how you have written your pause mode....
  • 0

#9 filulilus

filulilus

    GMC Member

  • GMC Member
  • 928 posts
  • Version:GM:Studio

Posted 08 June 2012 - 12:44 PM

... something like this?

//Create event 
pause = false 
 
//Step event 
if os_is_paused && !pause
{ 
pause = true 
instance_deactivate_all(true) 
} 
 
if pause
{
draw_set_halign(fa_center)
draw_set_valign(fa_center)
draw_text(view_wview[0] / 2, view_hview[0] / 2, 'Game is paused!#Press anywhere to continue')
draw_set_halign(fa_left)
draw_set_valign(fa_top)
if mouse_check_button_pressed(mb_left)
{
pause = false 
instance_activate_all() 
}
}

Edited by filulilus, 08 June 2012 - 12:46 PM.

  • 0

#10 rwkay

rwkay

    YoYo Games CTO

  • YoYo Games Staff
  • 1407 posts
  • Version:Unknown

Posted 08 June 2012 - 12:51 PM

Something like that yes...

Russell
  • 0

#11 WWAZman

WWAZman

    GMC Member

  • GMC Member
  • 709 posts
  • Version:GM:Studio

Posted 08 June 2012 - 04:11 PM

Haven't tried this but it should work (if Nocturnes instructions are correct :tongue:).
Just make a new object called obj_pause or something and use the following codes:

//Create event
pause = false

//Step event
if os_is_paused && !pause {
pause = true
instance_deactivate_all(true)
}

if !os_is_paused && pause
{
pause = false
instance_activate_all()
}



I don't think at this point in the game I am going to worry too much about it if GMS if supposed to pause it.. but I tried the code and in Windows at least it errored out with

############################################################################################
VMError!! Occurred - Push :: Execution Error - Variable Get os_is_paused
at gml_Object_os_pause_Step_0 (line 2) - if os_is_paused && !pause {
############################################################################################
Self Variables :
100001( pause ) = 0.000000


and on the phone itself it actually froze it up :P .. so .. for me anyways, that didn't work.
  • 1

#12 rwkay

rwkay

    YoYo Games CTO

  • YoYo Games Staff
  • 1407 posts
  • Version:Unknown

Posted 08 June 2012 - 04:14 PM

os_is_paused is a function not a variable... so os_is_paused()

Russell
  • 0

#13 kburkhart84

kburkhart84

    GMC Member

  • GMC Member
  • 1617 posts
  • Version:GM:Studio

Posted 08 June 2012 - 04:21 PM

Just making sure of this, when the os "pauses" our app by pushing it into the background, the runner stops execution? So, how is the code that we put for our "pause" mode executed in the first place?

I believe you that it works, I'm just trying to figure out how. Do we get one step worth of code? Or is the code actually executed upon return? I'm just curious how it works.
  • 0

#14 rwkay

rwkay

    YoYo Games CTO

  • YoYo Games Staff
  • 1407 posts
  • Version:Unknown

Posted 08 June 2012 - 04:25 PM

This flag is set on return...

When the call comes in then when we switch as fast as possible to it... Well not just calls but any request from OS to switch away...

Russell
  • 0

#15 kburkhart84

kburkhart84

    GMC Member

  • GMC Member
  • 1617 posts
  • Version:GM:Studio

Posted 08 June 2012 - 04:30 PM

OK, so you switch away, the game knows nothing at the moment, but doesn't need to because you pause everything. Then, on return, we have at minimum one step to detect the flag set, and we pause the game however we want to(unless maybe it is turn based and doesn't need to). So basically we still have to do our pause method one way or another, because that isn't handled by GM after the system begins execution of the game again. That's what I figured.

Thanks for clarification!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users