毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 论文 >> 正文

J2ME基于手机平台的智能客户端游戏设计 第8页

更新时间:2007-11-14:  来源:毕业论文

 

一、麻将类:

public class majiang {

         int num = 0;

         int type = 0;

         boolean side;

         play_majiang pm;

         Image mahimage;

         public majiang(int n, int t, boolean s, play_majiang pm) {

                   this.pm = pm;

                   num = n;

                   type = t;

                   side = s;

                   if (n == pm.magic1 && t == pm.magic2) {

                            num = 7;

                            type = 3;

                   }

                   if (n == -1) {

                            num = pm.magic1;

                            type = pm.magic2;

                   }

         }

}

二、J2ME初始化程序:

/** Main method */

         public void startApp() {

                   Display.getDisplay(this).setCurrent(form);        

                   conn = new Connection(this); // 初始化网络

         }

         /** Handle pausing the MIDlet */

         public void pauseApp() {

         }

         /** Handle destroying the MIDlet */

         public void destroyApp(boolean unconditional) {

         }

         /** Quit the MIDlet */

         public static void quitApp() {

                   instance.destroyApp(true);

                   instance.notifyDestroyed();

                   instance = null;

         }

         public void startgame() {

                   pm = new play_majiang(this, winner, wei);

                   Display.getDisplay(this).setCurrent(pm);

         }

 

三、高级用户界面按键响应:

       // 进入帮助说明后的按键响应

         public void commandAction(Command c, Displayable d) {

                   if (c == exit) {

                            Display.getDisplay(midlet).setCurrent(this);

                   }

         }

public void keyPressed(int key) {

                   switch (getGameAction(key)) {

                  case Canvas.UP: {

                            if (choose > 1)

                                     choose--;

                            else

                                     choose = 3;

                   }

                            break;

                   case Canvas.DOWN: {

                            if (choose < 3)

                                     choose++;

                            else

                                     choose = 1;

                   }

                            break;

                   case Canvas.FIRE: {

                            if (choose == 1) {

                                     if (first) {

                                               midlet.startgame();

                                               first = false;

                                     } else {

                                               //ff设成true

                                               midlet.pm.changeff();

                                               Display.getDisplay(midlet).setCurrent(midlet.pm);

                                     }

                            }

                            if (choose == 2) {

                                     Display.getDisplay(midlet).setCurrent(form);

                            }

                            if (choose == 3) {

                                      midlet.quitApp();

                            }

                   }

                            break;

                   case 0: {

                            switch (key) {

                            case Canvas.KEY_NUM2: {

                                     if (choose > 1)

                                               choose--;

                                     else

                                               choose = 3;

                            }

                                     break;

                            case Canvas.KEY_NUM8: {

                                     if (choose < 3)

                                               choose++;

                                     else

                                               choose = 1;

                            }

                                     break;

                            case Canvas.KEY_NUM5: {

                                     if (choose == 1) {

                                               if (first) {

                                                        midlet.startgame();

                                                        first = false;

                                               } else {

                                                        midlet.pm.changeff();

                                                        Display.getDisplay(midlet).setCurrent(midlet.pm);

                                               }

                                     }

                                     if (choose == 2) {

                                               Display.getDisplay(midlet).setCurrent(form);

                                     }

                                     if (choose == 3) {

                                               midlet.quitApp();

                                     }

                            }

                                     break;

                            }

                   }

                            break;

                   }

                   repaint();

         }}

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] 下一页

J2ME基于手机平台的智能客户端游戏设计 第8页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©751com.cn 辣文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。