×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    24

    Unhappy pausing and resuming games

    i'm using the GameCanvas.hideNotify and GameCanvas.showNotify methods on my game canvas to control the behaviour of the game during an incoming call. there is no code in the MainMidlet.pauseApp{} method and the MainMidlet.startApp simply sets the displayable to the main menu screen.
    the above approach is working perfectly in the S40 SDK and its corresponding Emulator (using it in netbeans).
    however when i try it out on my nokia-6300 and receive an incoming call while playing the game, i get the following problems:

    1) sometimes the game "hangs" immediately after the call is rejected / terminated. no key events are read.
    2) sometimes the game resumes, but "hangs" after a few moves.
    3) sometimes the game goes on to completion, but the moment it completes, then no further key events are read (thus not allowing me to use the exit option built into the game).

    could someone throw some light onto this? i expected that different platforms will behave differently as far as the GameCanvas.hideNotify and MainMidlet.pauseApp{} are called ... but if its working ok on the S40 emulator, then what could be the reason for it failing on the actual device?
    Last edited by ayushv2005; 2008-05-13 at 14:11.

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: pausing and resuming games

    Hi,

    When there is an incoming call..what you are doing..just pause the game/application.store all the states and values that you would need.Then resume the game and assign the all stores values and states to the original vars.

    Hope it helps.

    enjoyee.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    24

    Re: pausing and resuming games

    Thats exactly what i'm doing. all the states are stored in the GameCanvas.hideNotify and restored in the showNotify method. as i said earlier - when i run the game in the S40 emulator and generate an incoming call, the whole system works fine. but on the actual nokia 6300 (S40 platform) the results are varying from time to time.
    the basic structure of the game is somewhat like this -
    1) MainMidlet - contains methods to display different game screens / menu screens as desired
    2) MenuCanvas - Allows user to select options such as "new game", "instructions", "high scores" etc
    3) GameCanvas - the actual game screen

    i've run the code on different emulators and this is what i'm getting when i generate an incoming call:

    1) On S40 Emulator - Call to the GameCanvas.hideNotify and then when the call is over then call to the GameCanvas.showNotify
    (this is the result that i was wanting also)

    2) On the Default WTK 2.5.2 Emulator - Call to the MainMidlet.pauseApp and then call to the MainMidlet.startApp method. Does not seem to go to the showNotify and hideNotify methods of the GameCanvas

    3) On the Sony Ericsson Emulator - same result as WTK 2.5.2 emulator

    4) On the actual nokia 6300 - refer to my original post.

    some further insights would be greatly appreciated. thanks in advance.
    Quote Originally Posted by raj_J2ME View Post
    Hi,

    When there is an incoming call..what you are doing..just pause the game/application.store all the states and values that you would need.Then resume the game and assign the all stores values and states to the original vars.

    Hope it helps.

    enjoyee.

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: pausing and resuming games

    Hi,
    What you are saying that on WTK you are not getting the control in hide and showNotify ()....its must not be like that.Whether the emulators you use the control will be in hide and showNotify ().

    Now what you have to do:--
    1.Just implements the hideNotify() and showNotify ()--both are protected method.

    2.do not do anything with these just..go and put the call..
    check the control flow..when there is incoming call the control must be in hideNotify().and in showNotify ()..respectively.

    if it is happening then its perfect.Then in hideNotify ()..just persists the all states of game/app.

    Hope it will be clear to you.
    For the further query write...
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  5. #5
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    192

    Re: pausing and resuming games

    If your code takes too long in hideNotify it will cause problems.
    Also, you should check if that hideNotify isn't called twice in a row (can happen), or showNotify is called without hideNotify

  6. #6
    Registered User
    Join Date
    May 2008
    Posts
    24

    Re: pausing and resuming games

    thanks for the tips guys ... sorry for the late reply -
    basically the problem was with the audio ... the wav files were too large and causing a problem when the system takes over the player for playing the ringtone.
    i simply used a smaller audio file, and set all players to the realised state in the hideNotify method and then bring them back to prefetched state in showNotify (i.e. when the call is over).
    that seems to have solved the problem. btw, i've observed something similar on the Nokia 6265 - here one of the pre-installed games (3D Golf) hangs each time there is an incoming call ... in fact u gotta restart the phone. however if u disable the audio in the game, then there is no problem.

    thanks anyways for the suggestions. am facing some other problems in S40 (refer my other posts) ... if any of u could help out with that then i'd really appreciate it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •