示例#1
0
 @Override
 protected void onProgressUpdate(Integer... Score) {
   // TODO Auto-generated method stub
   super.onProgressUpdate(Score);
   gameActivity = GameActivity.getTheGameActivity();
   gameActivity.setTheScore(Score[0]);
 }
示例#2
0
  private void setScene(ScreenState sIn) {

    if (((GameActivity) activity).screenState != GameActivity.ScreenState.MAIN)
      ((GameActivity) activity).setScreenState(GameActivity.ScreenState.MAIN);

    screenState = sIn;
    List<AbstractElement> l = listMainScreen;

    if (sIn == ScreenState.MAIN) {
      // l = listMainScreen;
    } else if (sIn == ScreenState.CLUE) {
      l = listClueScreen;
    } else if (sIn == ScreenState.MISSION) {
      l = listMissionScreen;
      ((GameActivity) activity).getLayout().get().getBackground().setAlpha(120);
    }

    transitionOut(l);

    if (sIn == ScreenState.MENU) {
      transitionOut(listMenuScreen);
    }

    if (sIn == ScreenState.MISSION && allMissionsCompleted) {
      missionCrosshair.setVisibility(View.GONE);
      crosshairIndicator.setVisibility(View.GONE);
      missionButtonNext.setVisibility(View.VISIBLE);
    }
  }
        @Override
        public void onClick(View v) {
          SoundManager.getInstance(activity).playButtonSound();
          Game game = activity.getGame();
          switch (v.getId()) {
            case R.id.pauseBtn:
              activity.pauseGame();
              break;
            case R.id.hintBtn:
              if (game.isHinting()) return;

              if (game.isFreeHint()) game.useHint();
              else activity.showHintMenu();
              break;
            case R.id.nextBtn:
              game.nextLevel();
              game.setStage(Game.Stages.MainStage);
              break;
            case R.id.restartBtn:
              game.restartLevel();
              game.setStage(Game.Stages.MainStage);
              break;
            case R.id.menuBtn:
              activity.finish();
              break;
            case R.id.helpBtn:
              activity.showHelp();
              break;
          }
        }
示例#4
0
 private void callInvalidate(int move) {
   try {
     GameActivity a = (GameActivity) getContext();
     a.updateEx(move);
   } catch (Exception e) {
   }
 }
示例#5
0
 private int callDropOnRose(int move) {
   try {
     GameActivity a = (GameActivity) getContext();
     return a.dropOnRose();
   } catch (Exception e) {
   }
   return 1;
 }
示例#6
0
 @Override
 public void disposeScene() {
   m_camera.setHUD(null);
   m_camera.setCenter(GameActivity.getCameraWidth() / 2, GameActivity.getCameraHeight() / 2);
   removeMap();
   removeList.clear();
   m_progress_bar.stop();
   this.detachSelf();
   this.dispose();
 }
示例#7
0
 private void createProgressBar() {
   // TODO Auto-generated method stub
   m_progress_bar =
       new ProgressBar(
           GameActivity.getCameraWidth() / 2,
           (int) (0.95 * GameActivity.getCameraHeight()),
           m_resource_manager.m_progress_region,
           m_vbom,
           square_size * grid_size);
   m_progress_bar.setTotalTime(Constant.TOTAL_TIME);
   m_progress_bar.start();
 }
示例#8
0
  private void initSize() {
    game_zone_height = (int) (0.9 * GameActivity.getCameraHeight());
    square_size = game_zone_height / grid_size;
    shift_col = (GameActivity.getCameraWidth() - grid_size * square_size) / 2 + square_size / 2;
    shift_row = square_size / 2;
    // Matrix class init
    Matrix2D._item_size = square_size;

    Matrix2D._shift_row = shift_row;
    Matrix2D._shift_col = shift_col;
    NumSprite._size = square_size;
  }
  public TopButtonController(RelativeLayout rootLayour, GameActivity activity) {
    this.activity = activity;
    prefs = UserPreferences.getInstance(activity);

    layout =
        (RelativeLayout) activity.getLayoutInflater().inflate(R.layout.partial_topbuttons, null);
    pauseBtn = (ImageView) layout.findViewById(R.id.pauseBtn);
    hintBtn = (OutlinedTextView) layout.findViewById(R.id.hintBtn);
    nextBtn = (ImageView) layout.findViewById(R.id.nextBtn);
    restartBtn = (ImageView) layout.findViewById(R.id.restartBtn);
    menuBtn = (ImageView) layout.findViewById(R.id.menuBtn);
    helpBtn = (ImageView) layout.findViewById(R.id.helpBtn);

    pauseBtn.setOnClickListener(mainListener);
    hintBtn.setOnClickListener(mainListener);
    nextBtn.setOnClickListener(mainListener);
    restartBtn.setOnClickListener(mainListener);
    menuBtn.setOnClickListener(mainListener);
    helpBtn.setOnClickListener(mainListener);

    rlpTop =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT,
            Math.round(Metrics.squareButtonSize * Metrics.squareButtonScale));
    rlpTop.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    rlpTop.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    rlpTop.setMargins(Metrics.screenMargin, Metrics.screenMargin, Metrics.screenMargin, 0);

    RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) hintBtn.getLayoutParams();
    int bgWidth = hintBtn.getBackground().getIntrinsicWidth();
    int bgHeight = hintBtn.getBackground().getIntrinsicHeight();
    float scale = ((float) rlpTop.height / bgHeight);
    lp.width = Math.round(bgWidth * scale);
    lp.height = rlpTop.height;
    int[] iPaddings = {27, 23, 94, 23};
    hintBtn.setPadding(
        (int) (iPaddings[0] * scale),
        (int) (iPaddings[1] * scale),
        (int) (iPaddings[2] * scale),
        (int) (iPaddings[3] * scale));
    hintBtn.setLayoutParams(lp);
    hintBtn.setTypeface(Resources.getFont(activity.getApplicationContext()));
    hintBtn.setMaxLines2(1);
    updateHints();

    addScoreCounter();
    rootLayour.addView(layout, rlpTop);

    lp = (RelativeLayout.LayoutParams) pauseBtn.getLayoutParams();
    lp.width = lp.height = rlpTop.height;
  }
示例#10
0
  public void addNewBall(float x, float y, float radius) {

    SharedPreferences prefs =
        PreferenceManager.getDefaultSharedPreferences(m_gameActivity.getApplicationContext());
    String colorName = prefs.getString("Color", "Red");

    int resource =
        m_gameActivity
            .getResources()
            .getIdentifier("face_" + colorName.toLowerCase(), "drawable", "pt.isec.tp.am");
    Ball b = new Ball(this, x, y, radius, true, Color.parseColor(colorName));
    b.resource = resource;
    m_view.addResourceAndBitmap(resource);
    m_balls.add(b);
  }
示例#11
0
  void renderFrame(float fDeltaTime) {
    GLES20.glUseProgram(m_DefaultProgram);

    int posHandle = GLES20.glGetAttribLocation(m_DefaultProgram, "vPosition");
    int uvHandle = GLES20.glGetAttribLocation(m_DefaultProgram, "vUV");
    int textureHandle = GLES20.glGetUniformLocation(m_DefaultProgram, "texture");
    int laserColorHandle = GLES20.glGetUniformLocation(m_DefaultProgram, "colLaser");

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glUniform1i(textureHandle, 0);

    for (GameObject go : gameActivity.gameObjects) {
      go.render(fDeltaTime, posHandle, uvHandle, laserColorHandle);
    }

    GLES20.glDisableVertexAttribArray(posHandle);
    GLES20.glDisableVertexAttribArray(uvHandle);

    ArrayList<PointF> laserSegments = new ArrayList<PointF>();
    ArrayList<Float> laserLengths = new ArrayList<>();
    ArrayList<ColorF> laserColors = new ArrayList<ColorF>();

    gameActivity.computeLasers(laserSegments, laserLengths, laserColors);

    laserRenderer.setLasers(laserSegments, laserLengths, laserColors);
    laserRenderer.render(fDeltaTime);
  }
示例#12
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {

    int x = (int) event.getX();
    int y = (int) event.getY();

    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        break;

      case MotionEvent.ACTION_MOVE:
        break;

      case MotionEvent.ACTION_UP:
        if (isAvailable(x, y)
            && background != DEFAULT_BACKGROUND
            && !game.isOk()
            && !game.isOver()
            && !game.isOnPause()) {
          // selected shape
          Rect selected = getSelectedShape(x, y);

          if (selected != null) {
            // save the map shape -> color
            mg.putShape(selected, background);
            // add color in the set
            chosenColors.add(background);
            // compute the painted area
            surface_painted += selected.width() * selected.height();
            // true is the game is over
            boolean isOver = isAdjacentShapesWithSameColor(selected, background);

            if (isOver) {
              adjacent = getAdjacentShapesWithSameColor(selected, background);
              adjacent.add(selected);
              game.gameOver();

            } else if (surface_painted < getWidth() * getHeight()) {

              game.updateScore(computeScore());
            }
            // the entire surface is painted
            else if (surface_painted == getWidth() * getHeight()) {

              game.increaseGridNumber();
              game.updateScore(computeScore());
              game.gameSuccess();
            }
          }
        }

        break;
    }

    return true;
  }
示例#13
0
 private void createHUD() {
   gameHUD = new HUD();
   t_score_text =
       new Text(
           shift_row / 2,
           6 * GameActivity.getCameraHeight() / 7,
           m_resource_manager.font,
           "Score: 0123456789",
           new TextOptions(org.andengine.util.adt.align.HorizontalAlign.CENTER),
           m_vbom);
   t_score_text.setSkewCenter(0, 0);
   t_score_text.setText("Score: \n 0");
   t_score_text.setPosition(t_score_text.getWidth(), 6 * GameActivity.getCameraHeight() / 7);
   gameHUD.attachChild(t_score_text);
   m_camera.setHUD(gameHUD);
   _score = new Score(_level);
   _score.setTextScore(t_score_text);
 }
示例#14
0
  public Model(GameActivity gameActivity, Surface view) {
    m_view = view;
    m_gameActivity = gameActivity;
    m_view.addModel(this);
    m_barriers = Collections.synchronizedList(new ArrayList<Barrier>());
    m_balls = Collections.synchronizedList(new ArrayList<Ball>());
    m_bonusBalls = Collections.synchronizedList(new ArrayList<BonusBall>());
    m_newScorePoints = Collections.synchronizedList(new ArrayList<ScorePoint>());
    m_run = true;
    m_speed = m_defaultSpeed = 1;
    m_spaceBetweenRectangles = 0;
    m_score = 0;
    m_sleep = m_defaultSleep = 10;
    m_points = 2;
    m_nameToMediaPlayer = Collections.synchronizedMap(new HashMap<String, MediaPlayer>());
    mStartScore = 0;

    SharedPreferences prefs =
        PreferenceManager.getDefaultSharedPreferences(m_gameActivity.getApplicationContext());
    m_playSounds = !prefs.getBoolean("MuteSound", true);

    if (m_playSounds) {
      m_nameToMediaPlayer.put(
          "bomb", MediaPlayer.create(m_gameActivity.getBaseContext(), R.raw.bomb_bonus));
      m_nameToMediaPlayer.put(
          "color", MediaPlayer.create(m_gameActivity.getBaseContext(), R.raw.color_bonus));
      m_nameToMediaPlayer.put(
          "gameover", MediaPlayer.create(m_gameActivity.getBaseContext(), R.raw.gameover));
      m_nameToMediaPlayer.put(
          "points", MediaPlayer.create(m_gameActivity.getBaseContext(), R.raw.new_point));
      m_nameToMediaPlayer.put(
          "time", MediaPlayer.create(m_gameActivity.getBaseContext(), R.raw.time_bonus));
      m_nameToMediaPlayer.put(
          "win", MediaPlayer.create(m_gameActivity.getBaseContext(), R.raw.win));
    }

    prefs = PreferenceManager.getDefaultSharedPreferences(gameActivity.getApplicationContext());
    m_dificulty = prefs.getString("Dificulty", "Easy");

    if (m_dificulty.equalsIgnoreCase("Normal")) {
      m_points = 2;
      mStartScore = 701;
    } else if (m_dificulty.equalsIgnoreCase("Hard")) {
      m_points = 3;
      mStartScore = 1401;
    }

    m_defBallSpeed = m_ballSpeed = prefs.getInt("BallSpeed", 3);
  }
示例#15
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    if (ge == null) ge = new GameEngine(getContext());
    if (Settings.IS_IN_PREFERENCES_PAGE) {
      Settings.IS_IN_PREFERENCES_PAGE = false;
      Settings.isGameRunning = true;
      invalidate();
      ((GameActivity) context).startGame();

    } else {
      ge.touchEventHandler(event);
    }
    return gdc.onTouchEvent(event);
  }
示例#16
0
 @Override
 public void actionPerformed(String actionCommand) {
   if ("fight".equals(actionCommand)) {
     go("roll " + (canRetreat ? noda : nodd));
   } else if ("kill".equals(actionCommand)) {
     if (kill.isSelected()) {
       go("roll " + (canRetreat ? noda : nodd));
     }
   } else if ("retreat".equals(actionCommand)) {
     if (canRetreat) {
       go("retreat");
     } else {
       GameActivity.showClosePrompt(myrisk);
     }
   }
 }
示例#17
0
 public SoundResource(GameActivity game) {
   _game = game;
   SoundFactory.setAssetBasePath("mfx/");
   SoundManager sm = _game.getEngine().getSoundManager();
   try {
     MOVE = SoundFactory.createSoundFromAsset(sm, _game, "click_move.ogg");
     DROP = SoundFactory.createSoundFromAsset(sm, _game, "group.ogg");
     DROP6 = SoundFactory.createSoundFromAsset(sm, _game, "group6.ogg");
     TIME = SoundFactory.createSoundFromAsset(sm, _game, "time.ogg");
     TACK = SoundFactory.createSoundFromAsset(sm, _game, "tack.ogg");
     SLIDE = SoundFactory.createSoundFromAsset(sm, _game, "slide.ogg");
     LOST = SoundFactory.createSoundFromAsset(sm, _game, "lost.ogg");
     WOOSH = SoundFactory.createSoundFromAsset(sm, _game, "woosh.ogg");
   } catch (final IOException e) {
     throw new RuntimeException(e);
   }
 }
示例#18
0
 @Override
 public void run() {
   long ticksPS = 1000;
   long startTime;
   long sleepTime;
   while (_running) {
     startTime = System.currentTimeMillis();
     --_currentValue;
     _timeBar.setProgress(_currentValue);
     if (_currentValue == 0) {
       _running = false;
       _main.onTimeOut();
     }
     sleepTime = ticksPS - (System.currentTimeMillis() - startTime);
     try {
       if (sleepTime > 0) sleep(sleepTime);
       else sleep(10);
     } catch (Exception e) {
     }
   }
 }
示例#19
0
  /** Drag and drop */
  @Override
  public boolean onDragEvent(DragEvent event) {
    boolean result = false;
    switch (event.getAction()) {
      case DragEvent.ACTION_DRAG_STARTED:
        {
          // cache whether we accept the drag to return for LOCATION events
          mDragInProgress = true;
          mAcceptsDrag = result = true;

          // Redraw in the new visual state if we are a potential drop target
          if (this == Constants.currentBlank) {
            invalidate();
          }
        }
        break;
      case DragEvent.ACTION_DRAG_ENDED:
        {
          if (Constants.droppedOnBlank) {
            if (this == Constants.currentDragged) {
              invalidate();
              this.setOnLongClickListener(null);
              this.setTile(
                  new Tile(
                      this.tile.posOnBoard,
                      "tile_blank",
                      Constants.currentBlank.tile.id,
                      MoveDirection.NONE,
                      Constants.BLANK,
                      Constants.Blank_Bmp));
              Constants.currentBlank = this;
              System.out.println("set new blank****");
              Constants.currentDragged = null;
            } else {
              invalidate();
            }
            game.handleDragEnded();
          } else {
            invalidate();
          }

          mDragInProgress = false;
          mHovering = false;
        }
        break;
      case DragEvent.ACTION_DRAG_LOCATION:
        {
          // we returned true to DRAG_STARTED, so return true here
          result = mAcceptsDrag;
        }
        break;

      case DragEvent.ACTION_DROP:
        {
          processDrop(event);
          result = true;
        }
        break;

      case DragEvent.ACTION_DRAG_ENTERED:
        {
          mHovering = true;
          invalidate();
        }
        break;

      case DragEvent.ACTION_DRAG_EXITED:
        {
          mHovering = false;
          invalidate();
        }
        break;

      default:
        result = mAcceptsDrag;
        break;
    }

    return result;
  }
 public void updateHints() {
   activity.runOnUiThread(updateHints);
 }
示例#21
0
 protected void onPostExecute(Boolean gameOver) {
   if (gameOver) {
     gameActivity = GameActivity.getTheGameActivity();
     gameActivity.setPause(true);
   }
 }
 public void showScore() {
   activity.runOnUiThread(showScore);
 }
 public void showGameLostMenu() {
   activity.runOnUiThread(showLostMenu);
 }
 public void showGameWonMenu() {
   activity.runOnUiThread(showWonMenu);
 }
 public void showMainButtons() {
   activity.runOnUiThread(showMainButtons);
 }
示例#26
0
  public void run() {

    // game loop
    while (m_run) {
      try {
        Thread.sleep(m_sleep);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      // if view isn't loaded yet, go to beginning
      if (m_spaceBetweenRectangles == 0) continue;

      if (mPaused) waitOnPause();

      synchronized (m_balls) {
        updateBalls();
      }

      synchronized (m_bonusBalls) {
        updateBonusBalls();
      }

      moveScenario();
      fixCollisions();
      updateScorePoints();

      m_view.postInvalidate();
    }

    Score.onSave(m_gameActivity.getBaseContext(), (int) m_score);

    if (Score.score.get(0) == m_score) playSound("win");
    else playSound("gameover");

    synchronized (m_barriers) {
      m_barriers.clear();
    }
    synchronized (m_balls) {
      m_balls.clear();
    }
    synchronized (m_bonusBalls) {
      BonusBall.runAll = false;

      for (BonusBall ball : m_bonusBalls) {
        if (ball.getThread() != null && ball.getThread().isAlive()) {
          ball.terminateAndReset();
          try {
            ball.getThread().join();
          } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }

      m_bonusBalls.clear();
    }

    synchronized (m_newScorePoints) {
      m_bonusBalls.clear();
    }

    synchronized (m_nameToMediaPlayer) {
      Iterator<Entry<String, MediaPlayer>> it = m_nameToMediaPlayer.entrySet().iterator();

      while (it.hasNext()) {
        Map.Entry<String, MediaPlayer> entry = (Entry<String, MediaPlayer>) it.next();
        if (!entry.getValue().isPlaying()) {
          entry.getValue().release();
          it.remove();
        }
      }
    }

    System.gc();

    m_view.showGameOverDialog();
  }
示例#27
0
  private void createButton() {
    // Button Exit
    btn_exit =
        new ButtonSprite(
            GameActivity.getCameraWidth() - shift_col / 3,
            GameActivity.getCameraHeight() / 4,
            m_resource_manager.m_button_region[Constant.BTN_EXIT],
            m_vbom) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            if (pTouchEvent.isActionDown()) {
              pauseGame();
              m_activity.runOnUiThread(
                  new Runnable() {
                    @Override
                    public void run() {
                      new DialogExit(m_activity).show();
                    }
                  });
            }
            return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
          }
        };
    registerTouchArea(btn_exit);
    btn_exit.setScale(0.75f);
    attachChild(btn_exit);

    // Button sound on

    btn_sound_on =
        new ButtonSprite(
            GameActivity.getCameraWidth() - shift_col / 3,
            GameActivity.getCameraHeight() / 2,
            m_resource_manager.m_button_region[Constant.BTN_SOUND_ON],
            m_vbom) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {

            if (pTouchEvent.isActionDown()) {
              this.setVisible(false);
              sound_on = false;
              btn_sound_off.setVisible(true);
            }
            return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
          }
        };
    btn_sound_on.setScale(0.75f);
    registerTouchArea(btn_sound_on);
    attachChild(btn_sound_on);
    // Button sound off
    btn_sound_off =
        new ButtonSprite(
            GameActivity.getCameraWidth() - shift_col / 3,
            GameActivity.getCameraHeight() / 2,
            m_resource_manager.m_button_region[Constant.BTN_SOUND_OFF],
            m_vbom) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            if (pTouchEvent.isActionDown()) {
              this.setVisible(false);
              sound_on = true;
              btn_sound_on.setVisible(true);
            }
            return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
          }
        };
    btn_sound_off.setScale(0.75f);
    btn_sound_off.setVisible(false);
    registerTouchArea(btn_sound_off);
    attachChild(btn_sound_off);
    // Button Settings
    btn_settings =
        new ButtonSprite(
            GameActivity.getCameraWidth() - shift_col / 3,
            3 * GameActivity.getCameraHeight() / 4,
            m_resource_manager.m_button_region[Constant.BTN_SETTINGS],
            m_vbom) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            pauseGame();
            if (pTouchEvent.isActionDown()) {
              //
              m_activity.runOnUiThread(
                  new Runnable() {
                    @Override
                    public void run() {
                      new DialogLevel(m_activity).show();
                    }
                  });
            }
            return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
          }
        };
    btn_settings.setScale(0.75f);
    registerTouchArea(btn_settings);
    attachChild(btn_settings);
    // Button Play
    btn_play =
        new ButtonSprite(
            shift_col / 3,
            2 * GameActivity.getCameraHeight() / 5,
            m_resource_manager.m_button_region[Constant.BTN_PLAY],
            m_vbom) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            pauseGame();
            if (pTouchEvent.isActionDown()) {
              //					this.setVisible(false);
              //	btn_pause.setVisible(true);
              m_activity.runOnUiThread(
                  new Runnable() {
                    @Override
                    public void run() {
                      new DialogPause(m_activity).show();
                    }
                  });
            }
            return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
          }
        };
    btn_play.setScale(0.75f);
    registerTouchArea(btn_play);

    attachChild(btn_play);

    //		btn_pause = new ButtonSprite(shift_col/3 , 2*GameActivity.getCameraHeight()/5,
    // m_resource_manager.m_button_region[Constant.BTN_PAUSE], m_vbom){
    //			@Override
    //			public boolean onAreaTouched(TouchEvent pTouchEvent, float pTouchAreaLocalX, float
    // pTouchAreaLocalY) {
    //				if(pTouchEvent.isActionDown()) {
    //					this.setVisible(false);
    //					btn_play.setVisible(true);
    //					resumeGame();
    //
    //				}
    //				return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
    //			}
    //
    //		};
    //		btn_pause.setScale(0.75f);
    //		registerTouchArea(btn_pause);
    //		btn_pause.setVisible(false);
    //		attachChild(btn_pause);

    // Button restart
    btn_restart =
        new ButtonSprite(
            shift_col / 3,
            GameActivity.getCameraHeight() / 5,
            m_resource_manager.m_button_region[Constant.BTN_RESTART],
            m_vbom) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            if (pTouchEvent.isActionDown()) {
              restartGame();
            }
            return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
          }
        };
    btn_restart.setScale(0.75f);
    registerTouchArea(btn_restart);
    attachChild(btn_restart);
  }
示例#28
0
 public void onLoad() {
   ((GameActivity) activity).getLayout().get().setBackgroundResource(R.drawable.background_newtoo);
   setScene(screenState);
   if (startTime == 0) startTime = System.currentTimeMillis();
 }
 public void hideScore() {
   activity.runOnUiThread(hideScore);
 }