Hi So I’m pretty sure you’re all confused over the title, so I’ll try to be more clear
Im currently adding score to my game, but my problem is that I want to display the Score in the top-right corner, but when I do that, it adds the extra numbers to the right so they go offscreen Is there any way to make it put the extra numbers to the left?
Here’s a pic to explain what I mean
package com.mayogames.zombiecubes;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.mayogames.zombiecubes.entities.Player;
import com.mayogames.zombiecubes.screens.GameScreen;
import com.mayogames.zombiecubes.weapon.Weapon;
public class HUD {
ZombieCubes zombieCubes;
private GameScreen gameScreen;
private Player player;
private Weapon weapon;
private float stateTime;
private TextureRegion currentHeartFrame;
public HUD(ZombieCubes zombieCubes, GameScreen gameScreen, Player player, Weapon weapon){
this.zombieCubes = zombieCubes;
this.gameScreen = gameScreen;
this.player = player;
this.weapon = weapon;
}
public void tick(){
}
public void render(SpriteBatch hudBatch){
renderHearts(hudBatch);
Assets.white.draw(hudBatch, getPointsAsString(gameScreen.getPoints()), 700, 483);
}
public void renderHearts(SpriteBatch hudBatch){
stateTime += Gdx.graphics.getDeltaTime();
currentHeartFrame = Assets.healthHUDAnim.getKeyFrame(stateTime, true);
if(player.getHp() >= 3){
hudBatch.draw(currentHeartFrame, 64, 448);
hudBatch.draw(currentHeartFrame, 32, 448);
hudBatch.draw(currentHeartFrame, 0, 448);
}else if(player.getHp() == 2){
hudBatch.draw(Assets.heartEmpty, 64, 448);
hudBatch.draw(currentHeartFrame, 32, 448);
hudBatch.draw(currentHeartFrame, 0, 448);
}else if(player.getHp() == 1){
hudBatch.draw(Assets.heartEmpty, 64, 448);
hudBatch.draw(Assets.heartEmpty, 32, 448);
hudBatch.draw(currentHeartFrame, 0, 448);
}else if(player.getHp() <= 0){
hudBatch.draw(Assets.heartEmpty, 64, 448);
hudBatch.draw(Assets.heartEmpty, 32, 448);
hudBatch.draw(Assets.heartEmpty, 0, 448);
}
}
public String getPointsAsString(int convertToString){
return String.format("%02d", convertToString);
}
}