Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Restart game button?

 
Harry Rollins
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I am a beginner Java programmer and I have made a very simple applet with the wonderful help of some great YouTube tutorials and I was wondering if you guys knew of anyway of making a button that restarted the game without having to exit and reload the game manually. Here is my main class:



Any suggestions or code alterations would be so gratefully received also any other comments on the code would be nice as well.

Thanks

PlumApps
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
create a method, separate to init() or start(), named reset()? and put your current start-up code there.
ensure you set any variables to their starting state (except for games won/lost etc).

call reset() when the applet first opens, then for a new game call reset() again,
and the screen should appear exactly as when the applet first opened.
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please BeForthrightWhenCrossPostingToOtherSites
http://www.java-forums.org/new-java/59241-restart-reset-button.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic