Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accidentaly Closing the game..pls its urgent

 
vishwas bhatt
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,
i am confused and unable to handle accidentaly close the applicatio.
I have a class which implements runnable and there i am doing every animation.
Example:
//========================================================
class my implements Runnable
{

void paint()
{

callserially(this);
}
void run()
{
repaint();
}
}
//========================================================
Now please tell me user abruptly close the application(Pressing Red Button)
What shoul i do whith this therad. Please help me out
 
Puneet Gupta
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
declare a boolean variable "done"
on start of thread name "done=false"
in run
while (!done)
{
repaint();
}
on key pressed of red button make done=true
 
vishwas bhatt
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi puneet,

thanx, keypress of REd Button? i don't understatnd this may be you are talking about destroyApp() pls tell me more about this.

The problem is that when we press Red Button Game will close..so is will this thread will still alive (suspended) when user will restasrt the game.

pls tell me more about this.
thanx
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you set done=true in destroyApp(), the thread's run() method will quit (get out of the loop) and the thread no longer lives.
 
Puneet Gupta
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trap the "KEP PRESSED OF RED BUTTON" then in that function :
either you can call destroyApp() and set flag= true as suggested by Michel or u call destroyapp() and in destroyapp() u do done = true..
both mean the same thing..
 
vishwas bhatt
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael and Puneet,

Got it now..suppose this is some running animation on thread and user Exit Accidentaly. now when ever user come again i want to start thread form the same point again...so in this case what to do...b'coz in destroyApp() we are making done = true so it will come out from run().
thanx
please help me.
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try saving your game state in a static variable in the MIDlet or an RMS store before the run() method quits.
 
vishwas bhatt
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,
Thanx for your such a prompt reply. i got RMS concept that i can store in RMS that last exit was Natural or not. But what about this static variable can you explore much on this pls..i know i am asking very basic question but
i am good things thanx pls help me.

thanx
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic