I am Trying to show Image as background, but it doesn't fit to the screen.
When I use this class as the start screen it fit the screen properly but when I call this class after winning the level, the image becomes bigger than the device screen and only part of it is shown
but when I divide the width and height on 2 the image is becomes smaller than the screen :game.batch.draw(background, 0, 0, Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight()/2);
this is the code :
public class Celebration implements Screen {
private Fruits game;
private OrthographicCamera gamecam;
private Viewport gameport;
private Stage stage;
private World world;
private static float temp;
private float level;
private Texture background;
private Texture start;
private Texture loading;
private float counter;
public Celebration(Fruits game, float level)
{
this.game=game;
this.level=level;
gamecam=new OrthographicCamera();
gameport=new StretchViewport(820/Fruits.PPM,580/Fruits.PPM,gamecam);
stage=new Stage(gameport,((Fruits) game).batch);
background=new Texture("Wining.jpg");
gamecam.position.set(gameport.getWorldWidth() , gameport.getWorldHeight() , 0);
temp=0;
counter=100;
world=new World(new Vector2(0,-10),true);
}
@Override
public void show() {
}
public void handleinput(float dt)
{
if (counter<0)
{
game.setScreen(new PlayScreen(game,level));
}
}
public void update(float dt)
{
handleinput(dt);
world.step(1 / 60f, 6, 2);
gamecam.update();
}
@Override
public void render(float delta) {
float level;
update(delta);
Gdx.gl.glClearColor(0, 0, 0, 0);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
counter--;
game.batch.begin();
game.batch.draw(background, 0, 0, Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight()/2);
game.batch.end();
}
@Override
public void resize(int width, int height) {
gameport.update(width, height);
}
}