コード例 #1
0
  public void commandAction(Command c, Displayable d) {
    if (c == startCmd) {
      form.deleteAll();
      form.removeCommand(startCmd);
      form.addCommand(byeCmd);

      Thread t =
          new Thread() {

            public void run() {
              startSession();
            }
          };
      t.start();

      //	    startSession();
      return;
    } else if (c == exitCmd) {
      destroyApp(true);
      return;
    } else if (c == byeCmd) {
      form.removeCommand(byeCmd);
      form.addCommand(restartCmd);
      sendBYE();
      return;
    } else if (c == restartCmd) {
      stopListener();
      form.removeCommand(restartCmd);
      form.addCommand(startCmd);
      form.deleteAll();
      form.append(address);
      return;
    }
  }
コード例 #2
0
ファイル: SplashScreen.java プロジェクト: CASPED/hipoqih
 public SplashScreen(MIDletExiter me) {
   m = me;
   try {
     img = Image.createImage("/hipoqihSplash.PNG");
   } catch (Exception e) {
   }
   Thread th = new Thread(this);
   th.start();
 }
コード例 #3
0
ファイル: MainCanvas.java プロジェクト: kubaodias/bluectrl
  /** Metoda uruchamiana przez watek, odpowiedzialna za przerysowywanie ekranu */
  public void run() {
    int loopCount = 0;

    displayLogo();

    Runtime.getRuntime().gc();
    // setFullScreenMode(false);

    while (true) {
      updateState(); // sprawdzenie stanu przyciskow
      updateScreen(); // wyswietlenie nowej zawartosci ekranu

      loopCount++;

      if (loopCount > 200) {
        Runtime.getRuntime().gc();
        loopCount = 0;
      }

      try {
        Thread.sleep(50);
      } catch (InterruptedException e) {
        soundPlayer.play(SoundPlayer.ERROR_SOUND);
        System.out.println("Praca watku przerysowujacego zawartosc ekranu zostala przerwana!");
      }
    }
  }
コード例 #4
0
ファイル: GameMenu.java プロジェクト: zyz913614263/fishman
  public void run() {
    try {
      if (init) {
        Thread.sleep(500);
        disWidth = (getWidth() - 176) / 2; // 抓取螢幕的中心點
        disHeight = (getHeight() - 208) / 2; // 抓取螢幕的中心點
        drawDisplay();

        systemShowInf("建立資料庫...");
        new DataBaseWrite();
        systemShowInf("設定音樂...");
        GameMain.music = new BackupMusic();
        music = GameMain.music;
        systemShowInf("設定遊戲環境...");
        GameMain.roleData = new RoleDataValue();
        roleData = GameMain.roleData;
        GameMain.gaminf = new GameInfString();
        GameMain.music.musicStart("1");
        spInterface.setFrame(1);
        drawDisplay();
        changeMeun();
        init = false;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #5
0
ファイル: GameMidlet.java プロジェクト: hackstedt/Cheese
 public void startApp() {
   this.gameCanvas = new MobileBoard();
   this.t = new Thread(gameCanvas);
   t.start();
   d = Display.getDisplay(this);
   d.setCurrent(gameCanvas);
 }
コード例 #6
0
ファイル: PlanetMap.java プロジェクト: bernadetaanjani/jgeek
  public PlanetMap(String s, ChildForm parent, GameProxy gameProxy) {
    // super(false);
    this.parent = parent;
    this.gameProxy = gameProxy;
    // System.out.println("my p " + myPlanet);
    this.addCommand(cmdBack);
    // this.addCommand(cmdBuild);
    this.setCommandListener(this);
    setFullScreenMode(true);
    System.out.println("11111");
    en = Ground.getEnvironment(gameProxy.getMap(), gameProxy.getSaveName());
    System.out.println("21111");
    System.out.println(en);
    ENV = en;
    cm = new CurserManager(en, getHeight(), getWidth(), gameProxy);
    um = new UnitManager(en, getHeight(), getWidth());
    System.out.println("##1");
    cm.setUm(um);
    exec = true;
    myThread = new Thread(this);
    System.out.println("##2");

    try {
      JCageConfigurator.scoreTable = new Hashtable();
      System.out.println("Starting...");
      myThread.start();
      System.out.println("started...");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #7
0
ファイル: GetVersion.java プロジェクト: fin-nick/fj
 public void get() {
   try {
     new Thread(this).start();
     Thread.sleep(10);
   } catch (Exception e) {
   }
 }
コード例 #8
0
ファイル: Start.java プロジェクト: vohoaiviet/placecomm
  /**
   * Called by a system to indicated that a command has been invoked on a particular displayable.
   *
   * @param command the Command that was invoked
   * @param displayable the Displayable where the command was invoked
   */
  public void commandAction(
      Command command, Displayable displayable) { // GEN-END:|7-commandAction|0|7-preCommandAction
    // write pre-action user code here
    if (displayable == LoginForm) { // GEN-BEGIN:|7-commandAction|1|65-preAction
      if (command == CreateAgentandJoin) { // GEN-END:|7-commandAction|1|65-preAction
        // write pre-action user code here
        String name = UserAgentNameTF.getString();
        String strAgentClassName = "au.edu.latrobe.placecomm.agents.MobileUserAgent";
        try {
          MicroRuntime.startAgent(name, strAgentClassName, null);
          // write post-action user code here
        } catch (Exception ex) {
          ex.printStackTrace();
        }
        // GEN-LINE:|7-commandAction|2|65-postAction
        // write post-action user code here
      } else if (command == CreateContainer) { // GEN-LINE:|7-commandAction|3|63-preAction
        // write pre-action user code here

        Thread t =
            new Thread() {
              public void run() {
                myStartGoOnline();
              }
            };
        t.start();

        // GEN-LINE:|7-commandAction|4|63-postAction
        // write post-action user code here
      } else if (command == OfflineMode) { // GEN-LINE:|7-commandAction|5|28-preAction
        // write pre-action user code here
        // GEN-LINE:|7-commandAction|6|28-postAction
        // write post-action user code here
      } else if (command == exitCommand) { // GEN-LINE:|7-commandAction|7|17-preAction
        // write pre-action user code here
        exitMIDlet(); // GEN-LINE:|7-commandAction|8|17-postAction
        // write post-action user code here
      } else if (command == okCommand) { // GEN-LINE:|7-commandAction|9|20-preAction
        // write pre-action user code here
        // GEN-LINE:|7-commandAction|10|20-postAction
        // write post-action user code here
      } // GEN-BEGIN:|7-commandAction|11|7-postCommandAction
    } // GEN-END:|7-commandAction|11|7-postCommandAction
    // write post-action user code here
  } // GEN-BEGIN:|7-commandAction|12|
コード例 #9
0
ファイル: GameMenu.java プロジェクト: zyz913614263/fishman
 // 關閉程式
 public void exit() {
   drawDisplay();
   try {
     Thread.sleep(2000);
   } catch (Exception e) {
   }
   // backupmusic.stop();
   // backupmusic = null;
   midlet.exit();
 }
コード例 #10
0
ファイル: SplashScreen.java プロジェクト: CASPED/hipoqih
  public void run() {
    while (firstExec) {
      firstExec = false;

      try {
        Thread.sleep(3000);
      } catch (Exception e) {
      }
    }
    m.nextDisplay();
  }
コード例 #11
0
ファイル: MainCanvas.java プロジェクト: kubaodias/bluectrl
  /**
   * Konstruktor obiektu klasy MainCanvas
   *
   * @throws IOException
   */
  public MainCanvas() throws IOException {
    super(true);

    soundPlayer = new SoundPlayer(); // uruchomienie watku odpowiedzialnego za odtwarzanie dzwiekow
    new Thread(soundPlayer).start();

    screenWidth = getWidth();
    screenHeight = getHeight();
    fontHeight = Font.getDefaultFont().getHeight();

    mediaLibrarySelectedItemOnScreen = 0;
    mediaLibraryItemsNumberOnScreen = (screenHeight - 16) / (fontHeight + 5);

    buttonsLocation = 70;

    loadResources(); // utworzenie obiektow warstwy tla i tekstur

    bluetoothPlayer = new BluetoothPlayer();
    Thread appThread =
        new Thread(this); // uruchomienie watku odpowiedzialnego za wyswietlanie grafiki
    appThread.start();
  }
コード例 #12
0
 public void run() {
   if (playSnd) {
     try {
       for (int i = 0; i < tone.length(); ) {
         int note = (tone.charAt(i++) - 'A') + 12 * (tone.charAt(i++) - '0');
         int duration = 150;
         Manager.playTone(note, duration, 100);
         Thread.sleep(duration);
       }
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
コード例 #13
0
ファイル: PlanetMap.java プロジェクト: bernadetaanjani/jgeek
  public void commandAction(Command command, Displayable displayable) {
    if (command == cmdBack) {
      exec = false;
      try {
        BaseUnitService.getInstance().insertOrUpdate(en.units);
        BaseBuildingService.getInstance().insertOrUpdate(en.buildings);
        Thread.sleep(1000);
      } catch (Exception e) {
        e.printStackTrace(); // To change body of catch statement use File | Settings | File
        // Templates.
      }
      while (finished) {}

      ENV = null;
      MainMid.getClientConfigurator().displayParent();
    }
  }
コード例 #14
0
ファイル: PlanetMap.java プロジェクト: bernadetaanjani/jgeek
  public void run() {
    long k = 0;
    long paintTimer = 0;
    boolean setTime = true;
    boolean setTimePaint = true;
    finished = false;

    while (exec) {
      try {
        timer++;
        if (timer >= 20000) {
          timer = 0;
        }
        //                if ((timer) % ucTimer == 0) {
        //                    boolean created = false;
        //                    int ir = Math.abs(Ground.rand.nextInt()) % 2 + 1;
        //                    for (int i = 0; i < ir; i++) {
        //                        created = created || handleInhabitantUnitCreation(timer);
        //                    }
        //                    if (!created) {
        //                        System.out.println("No units created");
        //                        timer = ucTimer - 100;
        //                    }
        //                }

        handleBuildingCreation();
        handleUnitCreation();
        um.moveAndFireUnits(timer);
        repaint();
        setTime = true;
        // }

        Thread.sleep(refreshPeriod);
      } catch (InterruptedException ex1) {
        ex1.printStackTrace(); // To change body of catch statement use File | Settings | File
        // Templates.
      } catch (Exception ex2) {
        ex2.printStackTrace(); // To change body of catch statement use File | Settings | File
        // Templates.
      }
    }
    finished = true;
  }
コード例 #15
0
ファイル: DiscoveryApp.java プロジェクト: schoeberl/yari
  /**
   * Install a suite.
   *
   * @param selectedSuite index into the installList
   */
  private void installSuite(int selectedSuite) {
    MIDletStateHandler midletStateHandler = MIDletStateHandler.getMidletStateHandler();
    MIDletSuite midletSuite = midletStateHandler.getMIDletSuite();
    SuiteDownloadInfo suite;
    String displayName;

    suite = (SuiteDownloadInfo) installList.elementAt(selectedSuite);

    midletSuite.setTempProperty(null, "arg-0", "I");
    midletSuite.setTempProperty(null, "arg-1", suite.url);
    midletSuite.setTempProperty(null, "arg-2", suite.label);

    displayName = Resource.getString(ResourceConstants.INSTALL_APPLICATION);
    try {
      midletStateHandler.startMIDlet("com.sun.midp.installer.GraphicalInstaller", displayName);
      /*
       * Give the create MIDlet notification 1 second to get to
       * AMS.
       */
      Thread.sleep(1000);
      notifyDestroyed();
    } catch (Exception ex) {
      StringBuffer sb = new StringBuffer();

      sb.append(displayName);
      sb.append("\n");
      sb.append(Resource.getString(ResourceConstants.ERROR));
      sb.append(": ");
      sb.append(ex.toString());

      Alert a =
          new Alert(
              Resource.getString(ResourceConstants.AMS_CANNOT_START),
              sb.toString(),
              null,
              AlertType.ERROR);
      a.setTimeout(Alert.FOREVER);
      display.setCurrent(a, urlTextBox);
    }
  }
コード例 #16
0
  public void startApp() {
    if (svgCanvas == null) {
      // If there is a splash screen defined, show it immediately.
      boolean hasSplash = ((splashImageName != null) && !"".equals(splashImageName));

      if (hasSplash) {
        InputStream splashStream = getClass().getResourceAsStream(splashImageName);

        try {
          Image splashImage = Image.createImage(splashStream);
          splashCanvas = new SplashCanvas(splashImage);
        } catch (IOException ioe) {
          ioe.printStackTrace();
          hasSplash = false;
        }

        if (splashCanvas != null) {
          Display.getDisplay(this).setCurrent(splashCanvas);
        }
      }

      long start = System.currentTimeMillis();

      // Get input stream to the SVG image stored in the MIDlet's jar.
      InputStream svgDemoStream = getClass().getResourceAsStream(svgImageName);

      // Build an SVGImage instance from the stream
      svgImage = null;

      if (svgDemoStream != null) {
        try {
          svgImage = (SVGImage) SVGImage.createImage(svgDemoStream, null);
        } catch (IOException io) {
          io.printStackTrace();
        }
      }

      if (svgImage == null) {
        throw new Error(ERROR_COULD_NOT_LOAD_SVG + svgImageName);
      }

      // Build an SVGAnimator from the SVGImage. The SVGAnimator will handle
      // all the animation details and run the SVG animation in a
      // Canvas instance.
      svgAnimator = SVGAnimator.createAnimator(svgImage);

      // Set to 10 fps (frames per second)
      svgAnimator.setTimeIncrement(0.01f);

      // Get the Canvas managed by the SVGAnimator and set the
      // svgImage's size to the canvas display area.
      svgCanvas = (Canvas) svgAnimator.getTargetComponent();
      svgImage.setViewportWidth(svgCanvas.getWidth());
      svgImage.setViewportHeight(svgCanvas.getHeight());

      // Hook the exit command so that we can exit the animation demo.
      svgCanvas.addCommand(exitCommand);
      svgCanvas.setCommandListener(this);

      // The SVG root element is used to reset the time on a stop operation.
      doc = svgImage.getDocument();
      svg = (SVGSVGElement) doc.getDocumentElement();

      // Hook-in key listeners to play, pause and stop the animation.
      svgAnimator.setSVGEventListener(this);

      long end = System.currentTimeMillis();

      if (hasSplash) {
        long waitMore = SPLASH_MIN_LENGTH - (end - start);

        if (waitMore > 0) {
          try {
            Thread.currentThread().sleep(waitMore);
          } catch (InterruptedException ie) {
            // Do nothing.
          }
        }
      }

      if (autoStart) {
        svgAnimator.play();
        state = STATE_PLAYING;
        System.err.println("PLAYING...");
      }
    }

    Display.getDisplay(this).setCurrent(svgCanvas);
    resumeAnimation();
  }
コード例 #17
0
ファイル: MainCanvas.java プロジェクト: kubaodias/bluectrl
  /** Metoda odpowiedzialna za wyswietlenie i animacje trojwymiarowego logo */
  public void displayLogo() {
    try {
      int keys;
      int frames = 0;
      float angle = 10.0f; // kat o jaki obraca sie logo w animacji

      Graphics3D g3d = Graphics3D.getInstance();
      Graphics g = getGraphics();

      // setFullScreenMode(true);

      Thread.sleep(100);

      // zaladowanie obiektu zapisanego w pliku m3g
      Object3D[] objects = Loader.load("/res/blue_logo.m3g");

      scene = (World) objects[0];

      Camera camera = new Camera();
      camera.setPerspective(30.0f, (float) getWidth() / (float) getHeight(), 1.0f, 1000.0f);
      camera.setTranslation(0.0f, 0.0f, 24.0f);
      scene.addChild(camera);
      scene.setActiveCamera(camera);

      scene.getChild(0).preRotate(180.0f, 1.0f, 0.0f, 0.0f);

      keys = getKeyStates();

      while (((keys & FIRE_PRESSED) == 0) && (frames < 36)) { // oczekiwanie na nacisniecie klawisza
        g3d.bindTarget(g);

        scene.getChild(0).preRotate(angle, 0.0f, 0.7f, 1.0f);
        // wyrenderowanie sceny
        g3d.render(scene);
        // zwolnienie kontekstu graficznego
        g3d.releaseTarget();

        flushGraphics();

        Thread.sleep(30); // uspienie watku na 30ms

        keys = getKeyStates();

        frames++;
      }

      while (((getKeyStates() & FIRE_PRESSED) != 0)
          && (frames < 36)) {} // oczekiwanie na zwolnienie przycisku fire

      if ((keys & FIRE_PRESSED)
          == 0) // jesli przycisk nie zostal wcisniety, tylko animacja dobiegla konca
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      soundPlayer.play(SoundPlayer.ERROR_SOUND);
      System.out.println("Praca watku przerysowujacego zawartosc ekranu zostala przerwana!");
      e.printStackTrace();
    } catch (IOException e) {
      soundPlayer.play(SoundPlayer.ERROR_SOUND);
      System.out.println("Blad podczas wczytywania pliku z zasobow!");
      e.printStackTrace();
    } catch (Exception e) {
      soundPlayer.play(SoundPlayer.ERROR_SOUND);
      System.out.println("Nieznany wyjatek");
      e.printStackTrace();
    }
  }
コード例 #18
0
ファイル: GameMenu.java プロジェクト: zyz913614263/fishman
 // 判斷選取的選單選項
 public void changeMeunStart() {
   try {
     if (page == -1) {
       switch (menustate) {
         case 0:
           page = 0;
           spName.setVisible(true);
           changePage();
           break;
         case 1:
           page = 0;
           spName.setVisible(true);
           changePage();
           break;
         case 2:
           // spWelcome.setVisible(false);
           spName.setVisible(false);
           spInterface.setFrame(4);
           drawDisplay();
           GameMain.music.stop();
           exit();
           break;
       }
     } else {
       switch (menustate) {
         case 0:
           try {
             new InputText(nowString[0]);
           } catch (Exception e) {
             e.printStackTrace();
           }
           break;
         case 1:
           new InputText(nowString[1]);
           break;
         case 2: // 登入
           if (page == 0) { // 當在輸入帳號畫面時
             // 未輸入帳號
             if (username.equals("") || pass.equals("")) {
               g.drawString("「請 輸入帳號密碼」", disWidth + 75, disHeight + 140, 0);
               flushGraphics();
             } else if (username.equals("xlinx") && pass.equals("x")) {
               runGame();
               g.drawString("進入遊戲...", disWidth + 15, disHeight + 129, 0);
               flushGraphics();
             } else { // 連到Server
               try {
                 GameMain.conn.setLoginAccess(username, pass); // 送出帳號密碼
               } catch (Exception e) {
                 e.printStackTrace();
               }
               g.setColor(255, 255, 255);
               g.drawString("「登入中」", disWidth + 95, disHeight + 140, 0);
               flushGraphics();
               while (!ConnectionServer.connFin) ; // Server是否回傳完資訊
               page = 0;
               drawDisplay();
               g.setColor(255, 255, 255);
               gameUserInfCount = 0;
               // 成功登入將繼續到下一頁面(第一次進入遊戲)
               if (GameMain.conn.getConnSucess() == 1) {
                 g.drawString("「登入成功」", disWidth + 95, disHeight + 140, 0);
                 flushGraphics();
                 RoleDataValue.userpass = pass;
                 page = 1;
                 changePage();
               } else if (GameMain.conn.getConnSucess() == 0) { // 登入,不是第一次遊戲
                 try {
                   page = -2;
                   g.drawString("「登入成功」", disWidth + 95, disHeight + 140, 0);
                   flushGraphics();
                   RoleDataValue.userpass = pass;
                   g.drawString("讀取使用者資料....", disWidth + 15, disHeight + 69, 0);
                   flushGraphics();
                   GameMain.conn.setGameName("");
                   while (!ConnectionServer.connFin) ; // Server是否回傳完資訊
                   g.drawString("人物狀態初始化.....", disWidth + 15, disHeight + 89, 0);
                   flushGraphics();
                   roleData.getFirstRoleStateForInternet(GameMain.conn.getRequestState());
                   roleData.loginSuccessStart();
                   g.drawString("地圖初始化..........", disWidth + 15, disHeight + 109, 0);
                   flushGraphics();
                 } catch (Exception e) {
                   e.printStackTrace();
                 }
                 runGame();
                 g.drawString("進入遊戲...", disWidth + 15, disHeight + 129, 0);
                 flushGraphics();
               } else {
                 g.drawString("「登入失敗」", disWidth + 95, disHeight + 140, 0);
                 flushGraphics();
               }
             }
           } else if (page == 1) { // 當畫面在遊戲說明時
             if (gameUserInfCount < gameUserInf.length) // 如果遊戲說明未結速時
             changePage();
             else { // 遊戲說明完成,畫面改變為輸入遊戲名稱
               page = 2;
               gameUserInfCount = 20;
               changePage();
             }
           } else if (page == 2) { // 輸入名稱完成,畫面改變為角色建立完成
             if (nickname.equals("")) g.drawString("「請輸入名稱」", disWidth + 90, disHeight + 140, 0);
             else {
               page = 3;
               changePage();
             }
           } else if (page == 3) { // 第一進入遊戲,完成輸入名稱
             page = -2;
             GameMain.conn.setGameName(nickname);
             while (!ConnectionServer.connFin) ; // Server是否回傳完資訊
             try {
               roleData.getFirstRoleStateForInternet(GameMain.conn.getRequestState());
               roleData.loginSuccessStart();
             } catch (Exception e) {
               e.printStackTrace();
             }
             runGame();
           }
           break;
         case 3: // 回主選單,上一頁
           if (page == 0) {
             page = -1;
             menustate = 0;
             menuNum = 3;
           }
           // 判斷當為GameInformation時,要回輸入帳號密碼
           if (page == 1 && gameUserInfCount == 5) page--;
           else if (page == 2 || page == 3) // 判斷當不是GameInformation時
           page--;
           // 切換GameInformaion的頁面
           if (page == 1) {
             gameUserInfCount -= 5 * gameUserInfPage;
             gameUserInfPage++;
             if (gameUserInfPage >= 3) gameUserInfPage = 2;
             changePage();
           } // 回到輸入姓名部份
           else if (page == 2) {
             // rolesprite=true;
             Thread.sleep(300);
             gameUserInfPage = 2;
             changePage();
           } else changePage();
           break;
       }
       showBufferString();
     }
   } catch (Exception e) {
   }
 }
コード例 #19
0
ファイル: GameMenu.java プロジェクト: zyz913614263/fishman
 // 程式執行
 public void start() {
   thread = new Thread(this);
   thread.start();
 }