fahad005

SpriteBatch

Apr 19th, 2022 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. package com.mygdx.game;
  2.  
  3. import com.badlogic.gdx.Game;
  4. import com.badlogic.gdx.Gdx;
  5. import com.badlogic.gdx.Input;
  6. import com.badlogic.gdx.graphics.Texture;
  7. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  8. import com.badlogic.gdx.utils.ScreenUtils;
  9.  
  10. public class MyGdxGame extends Game {
  11.     SpriteBatch batch;
  12.     Texture img;
  13.     float x = 0, y = 0;
  14.    
  15.     @Override
  16.     public void create () {
  17.         batch = new SpriteBatch();
  18.         img = new Texture("badlogic.jpg");
  19.     }
  20.  
  21.     @Override
  22.     public void render () {
  23.         ScreenUtils.clear(0, 1, 0, 1);
  24.         batch.begin();
  25.         batch.draw(img, x, y);
  26.         batch.end();
  27.     }
  28.    
  29.     @Override
  30.     public void dispose () {
  31.         batch.dispose();
  32.         img.dispose();
  33.     }
  34. }
  35.  
Add Comment
Please, Sign In to add comment