@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(); }
@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(); }