PhoneGap: Need to 'pause' game when phone calls

Discussion and feedback on Construct 2

Post » Fri Mar 30, 2012 9:29 am

Hi,

I wonder if I could post a suggestion for a new feature (or fix) for CS2 please? (Or if it already handles this, then this is simply a question about how it's done....!)

Basically, CS2's support of mobile gaming is improving every day, and the recent fixes to the PhoneGap audio support are very welcome. However, there's another side to mobile gaming which is somewhat crucial.... the need to pause the game (and particularly the audio) when an 'interrupting event' occurs on the phone - for example an incoming phone-call, or the user simply 'backing out' of the running game to access some other app.

As far as I can see, currently CS2 games, exported to PG, and run on Android (for example), have their audio and gameplay continuing whenever the user 'pauses' the app or a phone-call comes in. This is problematic enough for various App stores to reject such a game (as it is crucial to deal with phone-call interruptions).

Using PhoneGap it is quite easy to handle these incoming events, but it needs some code in the JS to listen to the events and respond to them, and whilst I could dive into the exported index.html and JS files generated by CS2 and add in some code to manage this.... ideally CS2 would simply handle the events and apply some code to silence the sound effects, and pause the game, whenever one of these events occurs (and restart it all when the user returns).

The PhoneGap docs describe the events here:
http://docs.phonegap.com/en/1.5.0/phonegap_events_events.md.html#Events

So... (Ashley in particular)... could this be something to add to a new CS build please? (Preferably ASAP... as it's a blocking issue with releasing mobile versions of CS2 games on iPhone/Android etc.)

OR... if I've completely missed an existing feature within CS2 that handles such events, perhaps someone could simply point this numbskull in the right direction? :-)

Thanks! (And my apologies if I've posted this in the wrong section... I'm happy to move it or repost)

Ian
B
6
S
2
G
3
Posts: 17
Reputation: 2,383

Post » Fri Mar 30, 2012 12:26 pm

Write @Ashley to attract his attention, he gets an alert when you write that. In fact, you can do that to everyone.
@Go2Holidays <-- see how that makes you get a notification?
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Post » Fri Mar 30, 2012 12:57 pm

Wow.... so it does! Thanks for the tip. Here goes then...

@Ashley Hi, what do you think of my PhoneGap suggestion? :-)
B
6
S
2
G
3
Posts: 17
Reputation: 2,383

Post » Fri Mar 30, 2012 2:33 pm

Firstly I thought mobile browsers were clever enough to pause the game when something else comes to the foreground. So I guess they are not very clever.

Secondly I had no idea this could get you rejected from the app store! So I'll try and fix this ASAP.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Fri Mar 30, 2012 4:12 pm

Hi Ashley,

Thanks for the reply. Yes... I think I probably thought that at first too! But apparently not....

And yes, you can get rejected... I'm pretty sure Apple identify such behaviour as meriting a rejection, and Amazon's US App store for Android apps reviews each app and require this area to work correctly. On phones the ability to be able to manage incoming calls without any interruption is treated pretty seriously. That even means that apps which can in any way cause the phone to actually hang could cause a rejection.

But... I think a fix should be straightforward. The PhoneGap docs provide the details of the event handlers and it is simply a matter of using them, pausing all action and muting all the sound.

Thanks! :-)
B
6
S
2
G
3
Posts: 17
Reputation: 2,383

Post » Fri Mar 30, 2012 4:14 pm

P.S. Not sure if you'll need to look into something similar for AppMobi export too......?
B
6
S
2
G
3
Posts: 17
Reputation: 2,383

Post » Fri Mar 30, 2012 6:00 pm

@Go2Holidays yep will fix this for appMobi too.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sat Mar 31, 2012 3:35 am

Windows Phone have a tombstoning process where all state is saved to disk. Then it would be restored with the game paused. Like a load/save game.
Not sure if this is possible to support generically?
B
7
S
1
Posts: 74
Reputation: 1,232

Post » Tue Apr 03, 2012 11:02 am

@Ashley

Hey Ashley, thanks for getting r85 out so quickly and for dealing with these issues.... :-)

However.... can I confirm whether the audio is being properly suspended on Android when you switch out of the game to another application (or phone call, or home screen)....? I did a test on the Android Simulator using a PhoneGap built game exported from r85 and when I click the home button (to display phone's main home page) the action does indeed seem to pause (as it appears to be at the same place when I return to the game), but the audio just carried on playing....?

The game has a main music track playing, with various sound effects being played as things happen. Obviously the sound effects stop as the action has stopped to keep generating them.... but the music kept playing.

:-(

Any ideas?

Thanks!
B
6
S
2
G
3
Posts: 17
Reputation: 2,383

Post » Tue Apr 03, 2012 3:07 pm

@Go2Holidays, are you using appMobi or PhoneGap?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests