コード例 #1
0
  public ResultScene(Camera mCamera) {
    super(mCamera);
    activity = BaseActivity.getSharedInstance();
    setBackgroundEnabled(false);
    GameScene scene = (GameScene) activity.mCurrentScene;
    float accureay = 1 - (float) scene.missCount / scene.bulletCount;
    if (Float.isNaN(accureay)) accureay = 0;
    accureay *= 100;
    Text result =
        new Text(
            0,
            0,
            activity.mFont,
            activity.getString(R.string.accuracy) + ": " + String.format("%.2f", accureay) + "%",
            BaseActivity.getSharedInstance().getVertexBufferObjectManager());

    final int x = (int) (mCamera.getWidth() / 2 - result.getWidth() / 2);
    final int y = (int) (mCamera.getHeight() / 2 - result.getHeight() / 2);

    done = false;
    result.setPosition(x, mCamera.getHeight() + result.getHeight());
    MoveYModifier mod =
        new MoveYModifier(5, result.getY(), y) {
          @Override
          protected void onModifierFinished(IEntity pItem) {
            done = true;
          }
        };
    attachChild(result);
    result.registerEntityModifier(mod);
    setOnSceneTouchListener(this);
  }
コード例 #2
0
ファイル: Modal.java プロジェクト: nigelchanyk/SilentTempest
 public Modal(CommonResource resource, String label) {
   text =
       new Text(0, 0, resource.getRegularFont(), label, resource.getVertexBufferObjectManager());
   text.setColor(Color.WHITE);
   PositionHelper pos =
       new PositionHelper(resource.getScreenWidth(), resource.getScreenHeight())
           .setAnchorX(PositionHelper.AnchorX.LEFT)
           .setAnchorY(PositionHelper.AnchorY.BOTTOM)
           .setWidth((int) text.getWidth() + resource.getDPI() / 2)
           .setHeight((int) text.getHeight() + resource.getDPI() / 2);
   shadow = new UiShadow(resource, pos);
   attachChild(shadow);
   shadow.attachChild(text);
   text.setPosition(
       (pos.getDimension().x() - text.getWidth()) / 2,
       (pos.getDimension().y() - text.getHeight()) / 2);
 }
コード例 #3
0
 private void addMessage(final String pMessage) {
   final Text messageText =
       new Text(
           0,
           0,
           mFont,
           pMessage,
           MAXIMUM_CHARACTERS_PER_LINE,
           new TextOptions(HorizontalAlign.LEFT),
           mVertexBufferObjectManager);
   messageText.setAlpha(0.8f);
   for (Text text : this.mChatMessages) {
     text.setPosition(text.getX(), text.getY() - messageText.getHeight());
   }
   messageText.setPosition(
       TEXT_PADDING_X, this.getHeight() - (messageText.getHeight() + TEXT_PADDING_Y));
   this.mChatMessages.add(messageText);
   this.attachChild(messageText);
 }
コード例 #4
0
 private static void addLoadingMessage(Context context, Engine engine, Scene scene) {
   Font font = ResourceRegistry.getFont();
   Text label =
       new Text(
           0, 0, font, context.getString(R.string.loading), engine.getVertexBufferObjectManager());
   label.setHorizontalAlign(HorizontalAlign.CENTER);
   label.setX(engine.getCamera().getCenterX() - label.getWidth() / 2);
   label.setY(engine.getCamera().getCenterY() - label.getHeight() / 2);
   label.setColor(Color.WHITE);
   scene.attachChild(label);
 }
コード例 #5
0
ファイル: GameoverScene.java プロジェクト: Ganjasims/Balliada
  public GameoverScene() {
    super(BaseActivity.getSharedInstance().mCamera);
    activity = BaseActivity.getSharedInstance();

    setBackground(new Background(Color.WHITE));
    attachChild(activity.backgroundSprite);

    continueText =
        new Text(0, 0, activity.mFont, "Continue", activity.getVertexBufferObjectManager());
    continueText.setPosition(
        mCamera.getWidth() / 2 - continueText.getWidth() / 2,
        mCamera.getHeight() - continueText.getHeight() - 20);

    gameOverText =
        new Text(0, 0, activity.mFont, "Game Over", activity.getVertexBufferObjectManager());
    gameOverText.setPosition(
        mCamera.getWidth() / 2 - gameOverText.getWidth() / 2, mCamera.getHeight() / 6);

    scoreText =
        new Text(
            0,
            0,
            activity.mSmallFont,
            "Score: " + activity.score.getScore(),
            activity.getVertexBufferObjectManager());
    scoreText.setPosition(
        mCamera.getWidth() / 2 - scoreText.getWidth() / 2,
        mCamera.getHeight() / 2 - scoreText.getHeight() / 2 - gameOverText.getHeight());

    highscoreText =
        new Text(
            0,
            0,
            activity.mSmallFont,
            "Highscore: " + activity.highscore,
            activity.getVertexBufferObjectManager());
    highscoreText.setPosition(
        mCamera.getWidth() / 2 - highscoreText.getWidth() / 2,
        mCamera.getHeight() / 2
            - scoreText.getHeight() / 2
            - continueText.getHeight()
            + scoreText.getHeight()
            + activity.mCamera.getWidth() / 108f);

    IMenuItem startButton =
        new SpriteMenuItem(
            MENU_MAINMENU, activity.buttonRegion, activity.getVertexBufferObjectManager());
    startButton.setPosition(mCamera.getWidth() / 10, continueText.getY());
    startButton.setSize(mCamera.getWidth() - mCamera.getWidth() / 5, continueText.getHeight());

    Sprite panel =
        new Sprite(
            mCamera.getWidth() / 10 - mCamera.getWidth() / 20,
            gameOverText.getY() - 20,
            activity.panelRegion,
            activity.getVertexBufferObjectManager());
    panel.setSize(
        mCamera.getWidth() - mCamera.getWidth() / 10,
        mCamera.getHeight()
            - panel.getY()
            - (mCamera.getHeight() - highscoreText.getY())
            + highscoreText.getHeight()
            + 40);

    attachChild(panel);
    addMenuItem(startButton);
    attachChild(gameOverText);
    attachChild(highscoreText);
    attachChild(scoreText);
    attachChild(continueText);

    setOnMenuItemClickListener(this);

    if (activity.mGoogleApiClient == null || !activity.mGoogleApiClient.isConnected()) {
      activity.runOnUiThread(
          new Runnable() {
            @Override
            public void run() {
              Toast.makeText(
                      activity,
                      "Not connected to Google Play Services. Score not uploaded. Highscore gets uploaded automatically next time.",
                      Toast.LENGTH_LONG)
                  .show();
            }
          });
    }
  }
コード例 #6
0
ファイル: GameDialogBox.java プロジェクト: xMrAx/Tactics
  public GameDialogBox(HUD hud, String message, int back, boolean text, ButtonSprite... buttons) {
    super();
    dismissed = false;
    this.buttons = buttons;
    this.hud = hud;
    this.text = text;

    ResourcesManager resourcesManager = ResourcesManager.getInstance();

    // Attach Background
    switch (back) {
      case 1:
        hud.attachChild(
            backgroundSprite =
                new Sprite(240, 400, resourcesManager.dialog_background, resourcesManager.vbom));
        break;

      case 2:
        if (resourcesManager.dialog_background2 == null) {
          Log.d("Null", "null");
        }

        hud.attachChild(
            backgroundSprite =
                new Sprite(240, 400, resourcesManager.dialog_background2, resourcesManager.vbom));
        break;

      case 3:
        hud.attachChild(
            backgroundSprite =
                new Sprite(240, 400, resourcesManager.dialog_background3, resourcesManager.vbom));
        break;
      default:
        break;
    }
    if (text) {

      messageText =
          new Text(
              240,
              400,
              resourcesManager.cartoon_font_white,
              message,
              new TextOptions(
                  AutoWrap.WORDS,
                  backgroundSprite.getWidth() - 100,
                  HorizontalAlign.CENTER,
                  Text.LEADING_DEFAULT),
              resourcesManager.vbom);

      hud.attachChild(messageText);
      if (400 + (backgroundSprite.getHeight() / 2) - 50 + (messageText.getHeight() / 2)
          > 400 + backgroundSprite.getHeight() / 2) {
        messageText.setPosition(240, 400 + backgroundSprite.getHeight() / 2 - 100);
        j = 400 + (backgroundSprite.getHeight() / 2 - 100) - messageText.getHeight() - 25;
      } else {
        messageText.setPosition(240, 400 + backgroundSprite.getHeight() / 2 - 50);
        j = 400 + (backgroundSprite.getHeight() / 2 - 50) - messageText.getHeight() - 25;
      }

    } else {
      j = 400 + ((buttons.length * 100) / 2);
    }

    int i = 0;
    for (ButtonSprite button : buttons) {
      hud.attachChild(button);
      button.setPosition(240, j - (100 * i));
      hud.registerTouchArea(button);
      i++;
    }

    // hud.registerTouchArea(okayButton);
  }
コード例 #7
0
  private void init(KeyListenScene pBaseScene) {
    // 共通ウィンドウを作成
    CommonWindowRectangle comonWindowRectangle =
        new CommonWindowRectangle(
            0,
            0,
            pBaseScene.getWindowWidth(),
            pBaseScene.getWindowHeight(),
            Color.BLACK,
            0.8f,
            pBaseScene);
    attachChild(comonWindowRectangle);
    // タイトル
    float titleY = 12;
    Font titleFont = pBaseScene.createFont(Typeface.DEFAULT_BOLD, 30, Color.WHITE);
    Text titleText =
        new Text(
            10,
            10,
            titleFont,
            "〜 経験値振り分け 〜",
            pBaseScene.getBaseActivity().getVertexBufferObjectManager());
    pBaseScene.placeToCenterX(titleText, titleY);
    attachChild(titleText);

    float titleLineY = titleText.getY() + titleText.getHeight() + 4;

    Line line =
        new Line(
            10,
            titleLineY,
            pBaseScene.getWindowWidth() - 16,
            titleLineY,
            pBaseScene.getBaseActivity().getVertexBufferObjectManager());
    line.setLineWidth(1);
    line.setColor(Color.WHITE);
    line.setAlpha(1.0f);
    attachChild(line);

    TextLogic textLogic = new TextLogic();
    Font defaultFont = pBaseScene.createFont(Typeface.SANS_SERIF, 16, Color.WHITE);
    Font paramFont = pBaseScene.createFont(Typeface.DEFAULT, 16, Color.YELLOW);
    // Font upParamFont = pBaseScene.createFont(Typeface.DEFAULT, 16, Color.BLUE);
    // Expの表示
    float expY = titleLineY + 4;
    Rectangle totalExpTextRect =
        textLogic.createTextRectangle(
            "所持経験値:",
            defaultFont,
            "100 Exp",
            paramFont,
            pBaseScene.getBaseActivity().getVertexBufferObjectManager());
    attachChild(totalExpTextRect);

    Rectangle afterExpTextRect =
        textLogic.createTextRectangle(
            "振り分け後経験値:",
            defaultFont,
            "0 Exp",
            paramFont,
            pBaseScene.getBaseActivity().getVertexBufferObjectManager());
    attachChild(afterExpTextRect);

    totalExpTextRect.setPosition(
        pBaseScene.getWindowWidth() / 2
            - (totalExpTextRect.getX()
                    + totalExpTextRect.getWidth()
                    + 50
                    + afterExpTextRect.getWidth())
                / 2,
        expY);

    afterExpTextRect.setPosition(
        totalExpTextRect.getX() + totalExpTextRect.getWidth() + 50, totalExpTextRect.getY());

    float expLineY = totalExpTextRect.getY() + totalExpTextRect.getHeight() + 4;
    Line expLine =
        new Line(
            10,
            expLineY,
            pBaseScene.getWindowWidth() - 16,
            expLineY,
            pBaseScene.getBaseActivity().getVertexBufferObjectManager());
    expLine.setLineWidth(1);
    expLine.setColor(Color.WHITE);
    expLine.setAlpha(1.0f);
    attachChild(expLine);

    // プレイヤー情報
    float playerX = 12;
    float playerY = expLineY + 12;

    ActorPlayerLogic actorPlayerLogic = new ActorPlayerLogic();
    ActorPlayerDto actorPlayerDto = actorPlayerLogic.createActorPlayerDto(pBaseScene, 1);

    PlayerStatusRectangle playerStatusRectangle =
        new PlayerStatusRectangle(
            pBaseScene,
            defaultFont,
            actorPlayerDto,
            ActorSpriteUtil.getFaceFileName(actorPlayerDto.getImageResId()),
            playerX,
            playerY);
    playerStatusRectangle.show(PlayerStatusRectangleType.MINI_STATUS);
    attachChild(playerStatusRectangle);
  }
コード例 #8
0
  private void createHUD() {
    minigameHUD = new HUD();

    // Textures
    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
    HUDTextureAtlas =
        new BitmapTextureAtlas(
            ResourcesManager.getInstance().activity.getTextureManager(), 256, 256);

    blueHeartTR =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            HUDTextureAtlas, ResourcesManager.getInstance().activity, "heartBlue.png", 0, 0);
    greenHeartTR =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            HUDTextureAtlas, ResourcesManager.getInstance().activity, "heartGreen.png", 50, 0);
    yellowHeartTR =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            HUDTextureAtlas, ResourcesManager.getInstance().activity, "heartYellow.png", 0, 50);
    redHeartTR =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            HUDTextureAtlas, ResourcesManager.getInstance().activity, "heartRed.png", 50, 50);
    timerTR =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            HUDTextureAtlas, ResourcesManager.getInstance().activity, "timer.png", 110, 110);

    timerSprite = new Sprite(0, 0, timerTR, vbom);
    redHeartSprite = new Sprite(0, 0, redHeartTR, vbom);
    yellowHeartSprite = new Sprite(0, 0, yellowHeartTR, vbom);
    greenHeartSprite = new Sprite(0, 0, greenHeartTR, vbom);
    blueHeartSprite = new Sprite(0, 0, blueHeartTR, vbom);

    timerSprite.setPosition(timerTR.getWidth() / 2, camera.getHeight() - timerTR.getHeight());

    if (PlayerManager.getInstance().player.getPlayerName().equalsIgnoreCase("Player 1")) {
      redHeartSprite.setPosition(
          2 + redHeartTR.getWidth() / 2, timerSprite.getY() - redHeartTR.getHeight() - 5);
      yellowHeartSprite.setPosition(
          camera.getWidth() - (yellowHeartTR.getWidth() / 2) - 2,
          camera.getHeight() - (yellowHeartTR.getHeight() / 2) - 2);
    } else {
      redHeartSprite.setPosition(
          camera.getWidth() - (yellowHeartTR.getWidth() / 2) - 2,
          camera.getHeight() - (yellowHeartTR.getHeight() / 2) - 2);
      yellowHeartSprite.setPosition(
          2 + redHeartTR.getWidth() / 2, timerSprite.getY() - redHeartTR.getHeight() - 5);
    }

    greenHeartSprite.setPosition(
        yellowHeartSprite.getX() - greenHeartTR.getWidth() - 5, yellowHeartSprite.getY());
    blueHeartSprite.setPosition(
        greenHeartSprite.getX() - blueHeartTR.getWidth() - 5, greenHeartSprite.getY());

    // Timer
    timeLeft = MinigameManager.TIMER_SECONDS;
    timerText =
        new Text(
            0, 0, resourcesManager.font, "0123456789", new TextOptions(HorizontalAlign.LEFT), vbom);
    timerText.setText(timeLeft + "");
    timerText.setPosition(50, camera.getHeight() - timerText.getHeight() / 2);

    // Player lives
    p1LivesLeft = 10;
    p2LivesLeft = 10;
    p3LivesLeft = 10;
    p4LivesLeft = 10;

    p1LivesText =
        new Text(
            0,
            0,
            resourcesManager.p1LivesFont,
            "0123456789",
            new TextOptions(HorizontalAlign.LEFT),
            vbom);
    p2LivesText =
        new Text(
            0,
            0,
            resourcesManager.p1LivesFont,
            "0123456789",
            new TextOptions(HorizontalAlign.LEFT),
            vbom);
    p3LivesText =
        new Text(
            0,
            0,
            resourcesManager.p1LivesFont,
            "0123456789",
            new TextOptions(HorizontalAlign.LEFT),
            vbom);
    p4LivesText =
        new Text(
            0,
            0,
            resourcesManager.p1LivesFont,
            "0123456789",
            new TextOptions(HorizontalAlign.LEFT),
            vbom);

    p1LivesText.setPosition(redHeartSprite.getX(), redHeartSprite.getY());
    p2LivesText.setPosition(blueHeartSprite.getX(), blueHeartSprite.getY());
    p3LivesText.setPosition(greenHeartSprite.getX(), greenHeartSprite.getY());
    p4LivesText.setPosition(yellowHeartSprite.getX(), yellowHeartSprite.getY());

    p1LivesText.setText(PlayerManager.getInstance().player1.getPlayerHearts() + "");

    // p3LivesText.setText(p3LivesLeft + "");
    // p4LivesText.setText(p4LivesLeft + "");

    // Attach
    HUDTextureAtlas.load();
    // minigameHUD.attachChild(blueHeartSprite);
    minigameHUD.attachChild(redHeartSprite);
    // minigameHUD.attachChild(greenHeartSprite);

    minigameHUD.attachChild(timerSprite);

    minigameHUD.attachChild(timerText);
    minigameHUD.attachChild(p1LivesText);
    // minigameHUD.attachChild(p2LivesText);
    // minigameHUD.attachChild(p3LivesText);

    if (PlayerManager.getInstance().player2 != null) {
      p4LivesText.setText(PlayerManager.getInstance().player2.getPlayerHearts() + "");
      minigameHUD.attachChild(yellowHeartSprite);
      minigameHUD.attachChild(p4LivesText);
    }

    camera.setHUD(minigameHUD);
  }