コード例 #1
0
ファイル: GameRoot.java プロジェクト: Takonan/gdx-ui-app
 /** used because actors usually need to run the full constructor before adding things to them */
 public GameRoot init() {
   /**
    * gameroot is 16 units wide and whatever units high, keeping aspect ratio. not too important..
    */
   this.setSize(16, (screenH / screenW) * 16);
   cam.setToOrtho(false, getWidth(), getHeight());
   cam.update();
   this.addListener(
       new EventListener() {
         @Override
         public boolean handle(Event event) {
           if (event instanceof MobRemoveEvent) {
             ((MobRemoveEvent) event).removeMob();
             if (event instanceof MobTouchedEvent) {
               stats.pointUp();
               screen.pointsChanged(stats.getPoints());
             } else if (event instanceof MobExplodeEvent) {
               screen.mobExploded(stats.mobExploded());
               if (stats.getStrikes() >= 5 && !gameOver) gameOver();
             }
           }
           return false;
         }
       });
   stats.reset();
   gameOver = false;
   return this;
 }