game pause

Forum for J2ME mobile games related topics including programming doubts, books and other resources for J2ME game development

game pause

Postby rahul7star » Mon Oct 29, 2007 3:50 pm

Hi
well m facing a problem , how one can pause d game in between , and how resume button will work

i m having a game in which you r in glider and flying in space and u have to protect urself 4m enemy ok
but when user press pause button , how will the current scene will stop in its postion and after pressing d resume button how will it start again 4m same position
rahul7star
Regular User
 
Posts: 84
Joined: Fri Aug 17, 2007 11:22 am

Re: game pause

Postby DevelopmentTeam » Tue Oct 30, 2007 3:03 am

Ok, This is a good answer for a beginner. Now When the user presses a button you need to set a boolean variable to true. The same variable has to be used to temporarily disable the thread running.

Code: Select all
while (isPlay == true) {
   if(!paused) {
      input();
      drawScreen(g);
      try { Thread.sleep(delay); }
      catch (InterruptedException ie) {}
   } else {
      // check keys to resume game
   }
}
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: game pause

Postby rahul7star » Tue Oct 30, 2007 4:40 am

HI
ok 1 mor thing

in flash game , while in the menu we use to selct d option 4m menu and when button is pressesd it move to corresponding page

but in j2me

how in splash of j2me i can implement d same thing , i mean do i need diffrent screen shot of diffrent menu scene
suppose , foucs is on play optin so do i need seperate screen shot of play foucus . or one can do direct at runtime , ie whenevr user press up key so foucs shift to the corresponding optoin , or i need to call dat screen shot each time .



and i nedd dat splash is ther 4 20sec and dan it will automaticaaly move to game page , how dis can be done ,
in flash lite its very easy , but m feeling truble in j2me
rahul7star
Regular User
 
Posts: 84
Joined: Fri Aug 17, 2007 11:22 am

Re: game pause

Postby DevelopmentTeam » Tue Oct 30, 2007 5:32 am

in flash game , while in the menu we use to selct d option 4m menu and when button is pressesd it move to corresponding page

but in j2me

how in splash of j2me i can implement d same thing , i mean do i need diffrent screen shot of diffrent menu scene
suppose , foucs is on play optin so do i need seperate screen shot of play foucus . or one can do direct at runtime , ie whenevr user press up key so foucs shift to the corresponding optoin , or i need to call dat screen shot each time .


I think you are speaking about submenu options. You need to construct submenu in the same canvas. You need to keep track of which menu you are in. And you need to show an array of string with fonts which represents the corresponding menu.

and i nedd dat splash is ther 4 20sec and dan it will automaticaaly move to game page , how dis can be done ,
in flash lite its very easy , but m feeling truble in j2me


In J2me you need to get the time when the game starts using System.currentmilliseconds() function and then keep looking if the different of current time and started time is greater than 2000 milliseconds and change the splash screen. 2000 milliseconds represent 2 second.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India


Return to J2ME Games

Who is online

Users browsing this forum: No registered users and 2 guests

cron