|         个人认为游戏最难控制的就是这些线程了。如果游戏复杂的话。为了避免资源冲突,死锁等。这方面对程序要求是很高的。还好。我那个游戏很简单,所以就不用考虑到这些。
 只要一个最重要的东西就行了。
 
 
 java 代码 
 
  
 //无非是要程序不停的运行,直到游戏结束为之
 while (true) {  
             game.run();  
             try {  
                 Thread.sleep(80);   
             } catch (InterruptedException ie) {  
             }  
 }  
 
 
 
 java 代码 
 
  
  
  
  
  
   
 package org.wuhua.battleplan;  
   
 import javax.microedition.lcdui.Display;  
   
  
  
  
  
  
  
  
  
  
   
 public class GameThread implements Runnable {  
   
     private Game game;  
     GameThread(){  
         game = new Game();  
     }  
     public void run() {  
         gameRun();  
   
     }  
       
     public void init(){  
         game.init();  
     }  
     public void open(Display d){  
         d.setCurrent(game);  
     }  
   
     private void gameRun() {  
         while (true) {  
             game.run();  
             try {  
                 Thread.sleep(80);   
             } catch (InterruptedException ie) {  
             }  
         }  
   
     }  
   
 }  
 |