Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mygdx.makescents;
- import com.badlogic.gdx.Game;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.graphics.Color;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.BitmapFont;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import com.badlogic.gdx.utils.ScreenUtils;
- public class GameScreen extends com.badlogic.gdx.ScreenAdapter {
- private Game game;
- private SpriteBatch batch;
- private BitmapFont font;
- private Texture backgroundTexture;
- public GameScreen(Game game) {
- this.game = game;
- }
- @Override
- public void show() {
- batch = new SpriteBatch();
- // Create a new BitmapFont with black color
- font = new BitmapFont();
- font.setColor(Color.BLACK);
- // Set the font's properties
- font.getData().setScale(2f); // Set the font scale
- font.getData().setLineHeight(50f); // Set the line height
- // Load the background texture
- backgroundTexture = new Texture("atypicalGamescreen.png");
- }
- @Override
- public void render(float delta) {
- // Clear the screen to black
- ScreenUtils.clear(Color.BLACK);
- // Begin the SpriteBatch and draw the background texture
- batch.begin();
- batch.draw(backgroundTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
- // Draw the text with the black font
- font.draw(batch, "This is the game screen", 100, 200);
- batch.end();
- if (Gdx.input.justTouched()) {
- System.out.println("Touched screen - advancing to GameOverScreen");
- game.setScreen(new GameOverScreen(game)); // Set the screen to the GameOverScreen
- }
- }
- @Override
- public void dispose() {
- if (batch != null) {
- batch.dispose();
- }
- if (font != null) {
- font.dispose();
- }
- if (backgroundTexture != null) {
- backgroundTexture.dispose();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement