public TowerUpgraderBack hide() {

    for (final TiledSprite ts : mUpgradeSprites) {
      unregisterTouchArea(ts);
      detachChild(ts);
      ts.reset();
    }

    mUpgradeSprites.clear();

    // turn off updates and visibility
    mPositionMarker.setIgnoreUpdate(true);
    mPositionMarker.setVisible(false);
    mRadiusMarker.setIgnoreUpdate(true);
    mRadiusMarker.setVisible(false);

    // detach the radius marker to the position marker, then to
    // the scene
    Registry.sSceneLayerTowers.detachChild(mPositionMarker);

    Registry.sGameActivity.setScrollMode(GameActivity.SCROLL_MODE_CAMERA);
    Registry.sGameActivity.getCamera().setHUD(Registry.sHud);

    // enable tower interaction
    TowerManager.ENABLE_TOWER_INTERACTION = true;

    return this;
  }
예제 #2
0
 public void win() {
   if (mEngine.isRunning()) {
     failSprite.setVisible(false);
     winSprite.setVisible(true);
     mMainScene.setChildScene(mResultScene, false, true, true);
     mEngine.stop();
   }
 }
예제 #3
0
  @Override
  public Scene onLoadScene() {
    mEngine.registerUpdateHandler(new FPSLogger());

    final int barX = (int) ((mCamera.getWidth() - mBarTextureRegion.getWidth()) / 2);
    ballX = barX;
    final int barY = (int) ((mCamera.getHeight() - mBarTextureRegion.getHeight()) / 2);

    // player = new Sprite(PlayerX, PlayerY, mPlayerTextureRegion);
    // player.setScale(2);

    bar = new Sprite(barX, barY, mBarTextureRegion);
    bar.setScale(4, 2.5f);

    ball = new Sprite(ballX, barY + bar.getHeight(), mBallTextureRegion);
    ball.setScale(2.5f);

    mMainScene = new Scene();
    mMainScene.setBackground(new ColorBackground(0.09804f, 0.6274f, 0.8784f));

    // mMainScene.attachChild(player);
    mMainScene.attachChild(bar);
    mMainScene.attachChild(ball);

    mMainScene.registerUpdateHandler(detect);

    // projectileLL = new LinkedList();
    // projectilesToBeAdded = new LinkedList();

    mMainScene.setOnSceneTouchListener(this);

    mPauseScene = new CameraScene(mCamera);
    final int x = (int) (mCamera.getWidth() / 2 - mPausedTextureRegion.getWidth() / 2);
    final int y = (int) (mCamera.getHeight() / 2 - mPausedTextureRegion.getHeight() / 2);
    final Sprite pausedSprite = new Sprite(x, y, mPausedTextureRegion);
    mPauseScene.attachChild(pausedSprite);
    mPauseScene.setBackgroundEnabled(false);

    mResultScene = new CameraScene(mCamera);
    winSprite = new Sprite(x, y, mWinTextureRegion);
    failSprite = new Sprite(x, y, mFailTextureRegion);
    mResultScene.attachChild(winSprite);
    mResultScene.attachChild(failSprite);
    mResultScene.setBackgroundEnabled(false);

    winSprite.setVisible(false);
    failSprite.setVisible(false);
    score = new ChangeableText(0, 0, mFont, "ButtsButtsButts");
    score.setPosition(5, 5); // mCamera.getWidth() - score.getWidth() - 5, 5);
    score.setWidth(2000);
    mMainScene.attachChild(score);

    sensorManager = (SensorManager) this.getSystemService(this.SENSOR_SERVICE);
    sensorManager.registerListener(
        this, sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR), 1);

    return mMainScene;
  }
예제 #4
0
 @Override
 public void onSensorChanged(SensorEvent event) {
   if (event.sensor.getType() != Sensor.TYPE_ROTATION_VECTOR) return;
   rotation -= event.values[1]; // it's dumb, just go with it.
   score.setText("" + rotation);
   bar.setRotation(rotation);
   ballX += rotation / 100;
   ball.setPosition(ballX, ball.getY());
 }
 public void addFace(final int pID, final float pX, final float pY) {
   final Scene scene = this.mEngine.getScene();
   /* Create the face and add it to the scene. */
   final Sprite face = new Sprite(0, 0, this.mFaceTextureRegion);
   face.setPosition(pX - face.getWidth() * 0.5f, pY - face.getHeight() * 0.5f);
   face.setUserData(pID);
   this.mFaces.put(pID, face);
   scene.registerTouchArea(face);
   scene.attachChild(face);
 }
 public void moveFace(final int pID, final float pX, final float pY) {
   /* Find and move the face. */
   final Sprite face = this.mFaces.get(pID);
   face.setPosition(pX - face.getWidth() * 0.5f, pY - face.getHeight() * 0.5f);
 }
  public TowerUpgraderBack(
      final TowerManager pTowerManager, final TiledTextureRegion pTowerMenuTiledTextureRegion) {

    // ref our tower manager
    mTowerManager = pTowerManager;

    // create our position marker
    mPositionMarker = new Rectangle(0, 0, TowerManager.TOWER_WIDTH, TowerManager.TOWER_HEIGHT);
    mPositionMarker.setColor(1, 0, 0, 0.25f);
    mPositionMarker.setVisible(false);
    mPositionMarker.setIgnoreUpdate(true);

    // setup the radius marker
    mRadiusMarker = new Sprite(0, 0, mTowerManager.getTowerCircleTextureRegion().deepCopy());
    mRadiusMarker.setAlpha(0.25f);
    mRadiusMarker.setColor(.25f, .25f, .25f);
    mRadiusMarker.setVisible(false);
    mRadiusMarker.setIgnoreUpdate(true);

    // attach the radius marker to the position marker, then to the scene
    mPositionMarker.attachChild(mRadiusMarker);

    // assign our textures/font
    mTowerMenuTiledTextureRegion = pTowerMenuTiledTextureRegion;

    // calculate the total columns/rows
    mTotalColumns =
        3; // (int) Math.floor((TOWERS_UI_CAMERA_WIDTH - (TOWERS_UI_MIN_BORDER_WIDTH * 2)) /
           // (TOWERS_UI_ITEM_WIDTH + (TOWERS_UI_SPACER * 2)));
    mTotalRows =
        2; // (int) Math.floor((TOWERS_UI_CAMERA_HEIGHT - (TOWERS_UI_MIN_BORDER_WIDTH * 2)) /
           // (TOWERS_UI_ITEM_HEIGHT + (TOWERS_UI_SPACER * 2)));

    // decide the width of our box
    mBoxWidth = TOWERS_UI_SPACER + (mTotalColumns * (TOWERS_UI_ITEM_WIDTH + TOWERS_UI_SPACER));
    mBoxHeight = TOWERS_UI_SPACER + (mTotalRows * (TOWERS_UI_ITEM_HEIGHT + TOWERS_UI_SPACER));

    // decide our box x/y coords
    mBoxX = (TOWERS_UI_CAMERA_WIDTH / 2) - (mBoxWidth / 2);
    mBoxY = (TOWERS_UI_CAMERA_HEIGHT / 2) - (mBoxHeight / 2);

    // create our overlay "box", just a transparent rectangle
    final Rectangle rect =
        new Rectangle(mBoxX, mBoxY, mBoxWidth, mBoxHeight) {

          @Override
          public boolean onAreaTouched(
              final TouchEvent pSceneTouchEvent,
              final float pTouchAreaLocalX,
              final float pTouchAreaLocalY) {
            Debug.i("WTF");
            return true;
          }
        };
    rect.setColor(1, 1, 1, 0.50f);
    rect.setZIndex(0);
    attachChild(rect);
    // registerTouchArea(rect);

    /*
            // our sell button
            final TiledSprite sellButton = new TiledSprite(mBoxX + TOWERS_UI_ITEM_WIDTH + (TOWERS_UI_SPACER * 2), mBoxY + TOWERS_UI_SPACER, mTowerManager.getTowerMenuTiledTextureRegionClone()) {

                @Override
                public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
                    if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_UP) {
                        Registry.sGameActivity.runOnUpdateThread(new Runnable() {

                                @Override
                                public void run() {
                                    TowerUpgrader.this.sell();
                                }
                            }
                        );
                    }
                    return true;
                }
            };
            sellButton.setCurrentTileIndex(TOWERS_UI_SELL[0], TOWERS_UI_SELL[1]);
            sellButton.setZIndex(1);
            attachChild(sellButton);
            registerTouchArea(sellButton);

            mTowerSellText = new ChangeableText(TOWERS_UI_ITEM_WIDTH / 2, TOWERS_UI_ITEM_HEIGHT - (TOWERS_UI_ITEM_HEIGHT / 4), Registry.sFontWhite12, "", HorizontalAlign.CENTER, "XXXXX".length());
            mTowerSellText.setColor(1f, 85f, 0f);
            sellButton.attachChild(this.mTowerSellText);
    */
    mTowerSellText =
        new ChangeableText(
            TOWERS_UI_ITEM_WIDTH / 2,
            TOWERS_UI_ITEM_HEIGHT - (TOWERS_UI_ITEM_HEIGHT / 4),
            Registry.sFontWhite12,
            "",
            HorizontalAlign.CENTER,
            "XXXXX".length());

    sortChildren();
  }
  public TowerUpgraderBack show(final Tower pTowerBase) {
    // Debug.i("TowerUpgrader :: show :: type=" + pTowerBase.getTowerType());

    // disable tower interaction
    TowerManager.ENABLE_TOWER_INTERACTION = false;

    // set our current tower base
    mCurrentTowerBase = pTowerBase;

    // update our sell text
    mTowerSellText.setText(Integer.toString(pTowerBase.getTowerType().getCost()));

    // set our current row/col, make sure to account for our cancel +
    // sell button
    int currentCol = 0;
    int currentRow = 0;

    // find the coords
    final int[] coords =
        Registry.sMap.getCoordsFromTiles(pTowerBase.mTowerCol, pTowerBase.mTowerRow);

    // update the position
    mPositionMarker.setPosition(coords[0], coords[1]);
    mPositionMarker.setColor(1, 1, 1, 1.0f);

    // turn on updates and visibility
    mPositionMarker.setIgnoreUpdate(false);
    mPositionMarker.setVisible(true);

    // setup the radius marker
    mRadiusMarker.setIgnoreUpdate(false);
    mRadiusMarker.setVisible(true);
    mRadiusMarker.setWidth(pTowerBase.getTowerRange() * 2);
    mRadiusMarker.setHeight(pTowerBase.getTowerRange() * 2);

    // set the position of the marker
    mRadiusMarker.setPosition(
        (-pTowerBase.getTowerRange()) + (TowerManager.TOWER_WIDTH / 2),
        (-pTowerBase.getTowerRange()) + (TowerManager.TOWER_HEIGHT / 2));

    // attach the radius marker to the position marker, then to the scene
    Registry.sSceneLayerTowers.attachChild(mPositionMarker);

    // get this towers upgrade types
    for (final TowerTypes tt : pTowerBase.getTowerUpgradeTypes()) {

      /**
       * final TiledSprite upgradableTower = new TiledSprite(this.mBoxX + TOWERS_UI_SPACER +
       * (TOWERS_UI_SPACER * currentCol) + (TOWERS_UI_ITEM_WIDTH * currentCol), mBoxY +
       * TOWERS_UI_SPACER + (TOWERS_UI_SPACER * currentRow) + (TOWERS_UI_ITEM_WIDTH * currentRow),
       * mTowerManager.getTowerMenuTiledTextureRegionClone()) {
       */

      // PUT BORDERS ABOVE THESE FROM THE UI SPRITES THEY COME IN LARGE SIZE

      final float lX =
          mBoxX
              + TOWERS_UI_SPACER
              + (TOWERS_UI_SPACER * currentCol)
              + (TOWERS_UI_ITEM_WIDTH * currentCol);
      final float lY =
          mBoxY
              + TOWERS_UI_SPACER
              + (TOWERS_UI_SPACER * currentRow)
              + (TOWERS_UI_ITEM_HEIGHT * currentRow);

      final float placeX = (TOWERS_UI_ITEM_WIDTH / 2) + (lX - tt.getTowerTileCenterX());
      final float placeY =
          (TOWERS_UI_ITEM_HEIGHT - TOWERS_UI_SPACER) + (lY - tt.getTowerTileCenterY());

      final TiledSprite upgradableTower =
          new TiledSprite(
              placeX,
              placeY,
              Registry.sTowerTextureRegions[tt.getTowerTopSprite().getId()].deepCopy());
      upgradableTower.setScale(.90f);

      if (null == tt.getPlayerRewardType()
          || Registry.sPlayerRewards.isRewardEarned(tt.getPlayerRewardType())) {
        upgradableTower.setAlpha(1f);

      } else {
        upgradableTower.setAlpha(.25f);
      }

      if (null != tt.getTowerBaseSprite()) {
        upgradableTower.setCurrentTileIndex(tt.getTowerBaseSprite().getInitialTileIndex());
        // Debug.i("getTowerBaseSprite=" + tt.getTowerBaseSprite().getInitialTileIndex());
      }

      if (null != tt.getTowerTopSprite()) {
        upgradableTower.setCurrentTileIndex(tt.getTowerTopSprite().getInitialTileIndex());
        // Debug.i("getTowerTopSprite=" + tt.getTowerTopSprite().getInitialTileIndex());
      }

      upgradableTower.setZIndex(100);
      attachChild(upgradableTower);
      registerTouchArea(upgradableTower);
      mUpgradeSprites.add(upgradableTower);

      final Rectangle rect =
          new Rectangle(lX, lY, TOWERS_UI_ITEM_WIDTH, TOWERS_UI_ITEM_HEIGHT) {
            @Override
            public boolean onAreaTouched(
                TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
              if (null == tt.getPlayerRewardType()
                  || Registry.sPlayerRewards.isRewardEarned(tt.getPlayerRewardType())) {
                this.setAlpha(1f);

                if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) {
                  TowerUpgraderBack.this.isValidClick = true;
                }
                if (TowerUpgraderBack.this.isValidClick
                    && pSceneTouchEvent.getAction() == TouchEvent.ACTION_UP
                    && GameActivity.SCROLL_MODE_DISABLED
                        == Registry.sGameActivity.getScrollMode()) {
                  Registry.sGameActivity.runOnUpdateThread(
                      new Runnable() {

                        @Override
                        public void run() {
                          TowerUpgraderBack.this.upgrade(pTowerBase, tt);
                          TowerUpgraderBack.this.isValidClick = false;
                        }
                      });
                }

                return true;
              } else {
                this.setAlpha(.25f);

                Registry.sGameActivity.userNotifyShort(
                    "This tower requires the \""
                        + tt.getPlayerRewardType()
                        + "\" reward to be unlocked. Visit the Game Points section from the main menu for more information about earning and spending Game Points (The currency \"GP\" you see above).");

                return false;
              }
            }
          };
      rect.setZIndex(90);
      attachChild(rect);

      if (++currentCol >= mTotalColumns) {
        currentRow++;
        currentCol = 0;
      }
    }

    sortChildren();

    Debug.i("SpriteSheets.UI_128x128_01.ordinal()=" + SpriteSheets.UI_128x128_01.ordinal());

    final TiledSprite ts =
        new TiledSprite(
            25,
            25,
            Registry.sSpriteTextureRegions[SpriteSheets.UI_128x128_01.ordinal()].deepCopy());
    // final TiledSprite ts = new TiledSprite(25, 25,
    // Registry.sTowerTextureRegions[TowerTypes.ARCH_MAGE.getTowerTopSprite().getId()].deepCopy());
    ts.setZIndex(110);
    ts.setCurrentTileIndex(0);
    attachChild(ts);

    Registry.sGameActivity.setScrollMode(GameActivity.SCROLL_MODE_DISABLED);
    Registry.sGameActivity.getCamera().setHUD(TowerUpgraderBack.this);

    return this;
  }
  @Override
  public Scene onLoadScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());

    client = new WBClient(host, port, this);

    if (client.ConnectToServer()) {
      client.sendRegitsteringRequestForPlayerName("acbelter");
    } else {
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder
          .setMessage("Can't connect to server")
          .setCancelable(false)
          .setPositiveButton(
              "Exit",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                  WordsBattleActivity.this.finish();
                }
              })
          .setNegativeButton(
              "Close",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                  dialog.cancel();
                }
              });
      AlertDialog alert = builder.create();
      alert.show();
    }

    // TODO(acbelter): Был глюк,что буквы сами появляются на сетке.
    // TODO(acbelter): После разблокировки экрана иногда не работает тачскрин и сцена
    // перезагружается.
    // TODO(acbelter): Причем не работают нажатия только на кнопки в сетке.
    // TODO(acbelter): Иногда неправильное отображение слов.
    // TODO(acbelter): Новые буквы не привязываются к сцене.
    fieldGrid = new CoordinateGrid(CAMERA_WIDTH, CAMERA_HEIGHT, SPRITE_SIZE, SCALE);

    SceneManager.init(this);
    MenuScene.load();
    // TODO(acbelter):Попросить пользователя ввести имя [userName].
    // затем вызвать client.sendRegitsteringRequestForPlayerName(userName);
    // Далее все дело проиходит в вызове реализации IWBClientDelegate в методе
    // UserNameSuccessfullyRegistered(), либо в любое время после.
    // тоесть, когда игрок зарегистрировался, дальше он уже может запрашивать игру. Можешь пока это
    // делать hard кодом, а можешь выдавать окошки,
    // которые будут спрашивать у пользователя имя оппонента.

    // gameScene.setBackground(new ColorBackground(10f/255f, 134f/255f, 7f/255f));
    gameScene = new Scene();
    gameScene.setBackground(new SpriteBackground(new Sprite(0, 0, texBase.getBackgroundTexture())));

    float fieldWidth = CAMERA_WIDTH - leftOffset - rightOffset;
    int wordMaxLength = (int) (fieldWidth / (SPRITE_SIZE * SCALE));

    // Позиции, от которых рисуются слова.
    float wordX = leftOffset + (fieldWidth - wordMaxLength * SPRITE_SIZE * SCALE) / 2;

    float opponentWordY = (upOffset - SPRITE_SIZE * SCALE) / 2;
    float playerWordY =
        CAMERA_HEIGHT - SPRITE_SIZE * SCALE - (downOffset - SPRITE_SIZE * SCALE) / 2;

    final WordSprite opponentWord =
        new WordSprite(wordMaxLength, wordX, opponentWordY, texBase.getPlaceTexture(), false);
    final WordSprite playerWord =
        new WordSprite(wordMaxLength, wordX, playerWordY, texBase.getPlaceTexture(), true);

    myWord = playerWord;

    for (Sprite spr : opponentWord.cells) {
      gameScene.attachChild(spr, 0);
      gameScene.registerTouchArea(spr);
    }

    for (Sprite spr : playerWord.cells) {
      gameScene.attachChild(spr, 0);
      gameScene.registerTouchArea(spr);
    }

    // TODO(acbelter): Разобраться с добавлением новых букв.
    Sprite menuButton =
        new Sprite(
            CAMERA_WIDTH - 2 * SPRITE_SIZE + (SPRITE_SIZE - SPRITE_SIZE * SCALE),
            -(SPRITE_SIZE - SPRITE_SIZE * SCALE) * 0.5f,
            texBase.getMenuButtonTexture()) {
          @Override
          public boolean onAreaTouched(
              final TouchEvent pSceneTouchEvent,
              final float pTouchAreaLocalX,
              final float pTouchAreaLocalY) {
            // TODO(acbelter): Реализовать этот метод.
            // Пока тут будет тест сервера.
            // FieldFiller.fill(gameScene, conn);
            SceneManager.setScene(MenuScene.run());
            return false;
          }
        };

    menuButton.setScale(0);
    menuButton.registerEntityModifier(new ScaleModifier(3, 0, SCALE, EaseBounceOut.getInstance()));

    // fillgrid

    gameScene.attachChild(menuButton);
    gameScene.registerTouchArea(menuButton);

    Sprite submitButton =
        new Sprite(
            CAMERA_WIDTH - 2 * SPRITE_SIZE + (SPRITE_SIZE - SPRITE_SIZE * SCALE),
            CAMERA_HEIGHT - SPRITE_SIZE * SCALE - (SPRITE_SIZE - SPRITE_SIZE * SCALE) * 0.5f,
            texBase.getSubmitButtonTexture()) {
          @Override
          public boolean onAreaTouched(
              final TouchEvent pSceneTouchEvent,
              final float pTouchAreaLocalX,
              final float pTouchAreaLocalY) {
            // String str = conn.checkWord(playerWord.getWord());
            String str = playerWord.getWord().toUpperCase();

            Toast toast = Toast.makeText(getApplicationContext(), str, Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
            toast.show();

            return false;
          }
        };

    submitButton.setScale(0);
    submitButton.registerEntityModifier(
        new ScaleModifier(3, 0, SCALE, EaseBounceOut.getInstance()));

    gameScene.attachChild(submitButton);
    gameScene.registerTouchArea(submitButton);

    // TODO: При нажатии на меню нажимается game scene.
    gameScene.setTouchAreaBindingEnabled(false);
    // return gameScene;
    return MenuScene.run();
  }
예제 #10
0
  public GameOverScreen(Camera pCamera, LineikiActivity pActivity, int pScore, int pHighscore) {
    super(pCamera);

    this.setBackgroundEnabled(false);

    /*final SpriteMenuItem resetMenuItem = new SpriteMenuItem(MENU_RESET, this.mMenuNewGame);
    resetMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    this.mMenuthis.addMenuItem(resetMenuItem);*/

    // mGameOverthis.setBackground(new ColorBackground(0.5f, 0.1f, 0.1f, 0.5f));

    Rectangle r = new Rectangle(0, 0, pActivity.getScreenWidth(), pActivity.getScreenHeight());
    r.setColor(0, 0, 0, 0.0f);
    r.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    r.setAlpha(0.5f);
    // r.registerEntityModifier(new AlphaModifier(1.0f, 0.0f, 0.5f));

    this.attachChild(r);
    int w = pActivity.getTileSize();

    final Sprite game_over = new Sprite(w * .5f, w * 2, pActivity.getGameOverTexture());
    this.attachChild(game_over);

    /*mScoreDisplay = new ScoreDisplay(pActivity, 3);
    mScoreDisplay.setPosition(w*3, w*4);
    mScoreDisplay.setScore(pScore);
    this.attachChild(mScoreDisplay);*/

    final TextMenuItem resetMenuItem =
        new TextMenuItem(LineikiActivity.MENU_RESET, pActivity.mFont, "New Game");
    this.addMenuItem(resetMenuItem);

    final TextMenuItem quitMenuItem =
        new TextMenuItem(LineikiActivity.MENU_QUIT, pActivity.mFont, "Quit");
    this.addMenuItem(quitMenuItem);

    // this.buildAnimations();
    float scoreTop;
    float scoreLeft;
    // manually override menu items position
    if (pActivity.getIsTablet()) { // TABLET
      game_over.setPosition(w * 1.0f, w * 1.5f);
      resetMenuItem.setPosition(w * 10.5f, w * 6.5f);
      quitMenuItem.setPosition(w * 10.5f, w * 8.5f);
      scoreTop = w * 6.5f;
      scoreLeft = w * 0.5f;
    } else { // PHONE
      game_over.setPosition(w * .5f, w * 2);
      resetMenuItem.setPosition(w * 1, w * 11);
      quitMenuItem.setPosition(w * 5, w * 11);
      scoreTop = w * 6;
      scoreLeft = 0;
    }

    this.setBackgroundEnabled(false);

    Text t;

    t =
        new Text(
            100,
            60,
            pActivity.getFont(),
            "Your score: " + Integer.valueOf(pScore).toString(),
            HorizontalAlign.CENTER);
    this.attachChild(t);
    t.setPosition(scoreLeft + (w * 9 - t.getWidth()) / 2, scoreTop);

    if (pHighscore > 0) { // highscore is zero initially
      t =
          new Text(
              100,
              60,
              pActivity.getFont(),
              "Personal best: " + Integer.valueOf(pHighscore).toString(),
              HorizontalAlign.CENTER);
      this.attachChild(t);
      t.setPosition(scoreLeft + (w * 9 - t.getWidth()) / 2, scoreTop + w);

      if (pScore > pHighscore) {
        t = new Text(100, 60, pActivity.getFont(), "YOU WIN!!!", HorizontalAlign.CENTER);
        this.attachChild(t);
        t.setPosition(scoreLeft + (w * 9 - t.getWidth()) / 2, scoreTop + w * 2);
      }
    }

    this.setOnMenuItemClickListener(pActivity);
  }