Advertisement
TeamOneButton

GameTitle.java

Mar 22nd, 2023
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.mygdx.makescents;
  2.  
  3. import com.badlogic.gdx.graphics.g2d.BitmapFont;
  4. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  5. import com.badlogic.gdx.utils.Align;
  6.  
  7. public class GameTitle {
  8.     private BitmapFont font;
  9.     private String title;
  10.     private float x;
  11.     private float y;
  12.     private float width;
  13.     private float height;
  14.     private SpriteBatch batch;
  15.  
  16.     public GameTitle(String title, float x, float y, float width, float height) {
  17.         this.font = new BitmapFont();
  18.         this.title = "Makes Cents";
  19.         this.x = x;
  20.         this.y = y;
  21.         this.width = width;
  22.         this.height = height;
  23.     }
  24.  
  25.     public void draw(SpriteBatch batch) {
  26.         font.getData().setScale(2);
  27.         font.draw(batch, title, x, y, width, Align.center, true);
  28.     }
  29.  
  30.     public void dispose() {
  31.         font.dispose();
  32.         if (batch != null) {
  33.             batch.dispose();
  34.         }
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement