コード例 #1
0
  @Override
  public void render(SpriteBatch sb) {
    delta = (TimeUtils.millis() - startTime + 700) / 1000;
    tweenManager.update(delta);
    bgManager.render(sb);

    sb.setProjectionMatrix(camera.combined);
    sb.begin();
    backButton.render(sb);
    randomCardButton.draw(sb);
    rareCardButton.draw(sb);

    Fonts.MFont.draw(
        sb, "Cost: " + randomCardCost, randomCardButton.getX(), randomCardButton.getY() - 40);
    Fonts.MFont.draw(
        sb, "Cost: " + rareCardCost, rareCardButton.getX(), rareCardButton.getY() - 40);

    Fonts.MFont.draw(
        sb,
        currGold,
        MainGame.WIDTH - Fonts.MFont.getBounds(currGold).width - 40,
        MainGame.HEIGHT - 50);

    if (showingCard) {
      sb.draw(alpha, 0, 0, MainGame.WIDTH, MainGame.HEIGHT);
      purchasedCard.render(
          new Vector2(
              MainGame.WIDTH / 2 - (Card.WIDTH / 2 * cardAnimSprite.getScaleX()),
              MainGame.HEIGHT / 2 - (Card.HEIGHT / 2 * cardAnimSprite.getScaleX())),
          cardAnimSprite.getScaleX(),
          sb);
      unlockedText.draw(sb);
    }
    sb.end();
  }
コード例 #2
0
 @Override
 public synchronized void stop() {
   mContext.unregisterReceiver(mUsbReceiver);
   Log.d(TAG, "stop: " + this);
   stateChange(State.FINISHED);
   super.stop();
 }
コード例 #3
0
  @Override
  public synchronized void start() {
    Log.d(TAG, "start: " + this);
    stateChange(State.IDLE);

    final IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
    filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); // never fired by framework :-\
    filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
    mContext.registerReceiver(mUsbReceiver, filter);
    super.start();
  }
コード例 #4
0
  @Override
  public void update() {
    if (Gdx.input.justTouched()) {
      touch = MainGame.camera.unprojectCoordinates(Gdx.input.getX(), Gdx.input.getY());

      if (showingCard) {

        TweenCallback myCallBack =
            new TweenCallback() {
              @Override
              public void onEvent(int type, BaseTween<?> source) {
                purchasedCard = null;
                showingCard = false;
              }
            };

        Tween.to(cardAnimSprite, SpriteAccessor.SCALE_XY, 10f)
            .target(0.001f, 0.001f)
            .ease(TweenEquations.easeNone)
            .setCallback(myCallBack)
            .setCallbackTriggers(TweenCallback.END)
            .start(tweenManager);
        startTime = TimeUtils.millis();

      } else {

        if (backButton.checkTouch(touch)) {
          SoundManager.play(Assets.CLICK);
          ScreenManager.setScreen(new MainMenuScreen());

        } else if (randomCardButton.checkTouch(touch)) {

          long myGold = MainGame.userStats.getPlayerGold();

          if (myGold >= randomCardCost) {
            MainGame.userStats.addGold(-randomCardCost);

            purchasedCard =
                CardCreator.createCard((int) (Math.random() * MainGame.numberOfCards + 1));
            MainGame.userStats.getPlayerCardList().insert(0, purchasedCard.getID());
            MainGame.saveManager.saveDataValue("PLAYER", MainGame.userStats);

            currGold = "Gold: " + MainGame.userStats.getPlayerGold();
            Tween.to(cardAnimSprite, SpriteAccessor.SCALE_XY, 10f)
                .target(1.5f, 1.5f)
                .ease(TweenEquations.easeNone)
                .start(tweenManager);
            startTime = TimeUtils.millis();
            showingCard = true;
          }
        } else if (rareCardButton.checkTouch(touch)) {

          long myGold = MainGame.userStats.getPlayerGold();

          if (myGold >= rareCardCost) {
            MainGame.userStats.addGold(-rareCardCost);

            purchasedCard =
                CardCreator.createCard((int) (Math.random() * MainGame.numberOfCards + 1));
            MainGame.userStats.getPlayerCardList().insert(0, purchasedCard.getID());
            MainGame.saveManager.saveDataValue("PLAYER", MainGame.userStats);

            currGold = "Gold: " + MainGame.userStats.getPlayerGold();
            Tween.to(cardAnimSprite, SpriteAccessor.SCALE_XY, 10f)
                .target(1.5f, 1.5f)
                .ease(TweenEquations.easeNone)
                .start(tweenManager);
            startTime = TimeUtils.millis();
            showingCard = true;
          }
        }
      }
    }
    bgManager.update();
  }
コード例 #5
0
ファイル: MainMenu.java プロジェクト: kim-rid/ScrollNinja
  // コンストラクタ
  public MainMenu(Game game) {
    this.scrollNinja = game;

    // カメラ作成
    camera =
        new OrthographicCamera(
            ScrollNinja.window.x * ScrollNinja.scale, ScrollNinja.window.y * ScrollNinja.scale);
    // スプライトバッチ作成
    spriteBatch = new SpriteBatch();

    nextStageNum = 0;
    // TODO 読み込んだセーブファイルからコンティニューする時のステージを設定
    // stage =
    // StageManager.StageTrance(stage);
    // nextStageNum = StageManager.GetNowStage();
    BackgroundManager.CreateBackground(nextStageNum, false);

    // テクスチャ読み込み
    Texture texture = new Texture(Gdx.files.internal("data/menu.png"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    spritePositionX = -105;
    // TODO 位置は後で要調整
    // 選択肢コンテニュー
    TextureRegion region = new TextureRegion(texture, 0, 0, 256, 35);
    modeContinue = new Sprite(region);
    modeContinue.setPosition(spritePositionX, 0);
    modeContinue.setScale(ScrollNinja.scale);

    // 選択肢ニューゲーム
    region = new TextureRegion(texture, 0, 40, 256, 35);
    modeNewGame = new Sprite(region);
    modeNewGame.setPosition(spritePositionX, -4);
    modeNewGame.setScale(ScrollNinja.scale);

    // 選択肢ロードゲーム
    region = new TextureRegion(texture, 0, 85, 256, 35);
    modeLoadGame = new Sprite(region);
    modeLoadGame.setPosition(spritePositionX, -8);
    modeLoadGame.setScale(ScrollNinja.scale);

    // 選択肢ネットワーク
    region = new TextureRegion(texture, 0, 128, 256, 35);
    modeNetwork = new Sprite(region);
    modeNetwork.setPosition(spritePositionX, -12);
    modeNetwork.setScale(ScrollNinja.scale);

    // 選択肢オプション
    region = new TextureRegion(texture, 0, 176, 256, 35);
    modeOption = new Sprite(region);
    modeOption.setPosition(spritePositionX, -16);
    modeOption.setScale(ScrollNinja.scale);

    // 選択肢終了
    region = new TextureRegion(texture, 0, 218, 256, 35);
    modeExit = new Sprite(region);
    modeExit.setPosition(spritePositionX, -20);
    modeExit.setScale(ScrollNinja.scale);

    // 初期化
    scrollFlag = false;
  }