Advertisement
wreed12345

helping

May 27th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.57 KB | None | 0 0
  1. import com.badlogic.gdx.ApplicationListener;
  2. import com.badlogic.gdx.Gdx;
  3. import com.badlogic.gdx.graphics.GL10;
  4. import com.badlogic.gdx.graphics.OrthographicCamera;
  5. import com.badlogic.gdx.graphics.Texture;
  6. import com.badlogic.gdx.graphics.Texture.TextureFilter;
  7. import com.badlogic.gdx.graphics.g2d.Sprite;
  8. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  9. import com.badlogic.gdx.graphics.g2d.TextureRegion;
  10.  
  11. public class GdxDemo implements ApplicationListener {
  12.     private OrthographicCamera camera;
  13.     private SpriteBatch batch;
  14.     private Texture texture;
  15.    
  16.     @Override
  17.     public void create() {     
  18.         float w = Gdx.graphics.getWidth();
  19.         float h = Gdx.graphics.getHeight();
  20.        
  21.         camera = new OrthographicCamera(1, h/w);
  22.         camera.zoom = - 100;
  23.         batch = new SpriteBatch();
  24.        
  25.         texture = new Texture(Gdx.files.internal("data/libgdx.png"));
  26.         texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
  27.        
  28.         TextureRegion region = new TextureRegion(texture, 0, 0, 512, 275);
  29.     }
  30.  
  31.     @Override
  32.     public void dispose() {
  33.         batch.dispose();
  34.         texture.dispose();
  35.     }
  36.  
  37.     @Override
  38.     public void render() {     
  39.         Gdx.gl.glClearColor(1, 1, 1, 1);
  40.         Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
  41.         System.out.println("zoom:" + camera.zoom);
  42.         batch.setProjectionMatrix(camera.combined);
  43.         batch.begin();
  44.         batch.draw(region, 10, 10); // not sure where to draw it so maybe u should change these
  45.         sprite.draw(batch);
  46.         batch.end();
  47.     }
  48.  
  49.     @Override
  50.     public void resize(int width, int height) {
  51.     }
  52.  
  53.     @Override
  54.     public void pause() {
  55.     }
  56.  
  57.     @Override
  58.     public void resume() {
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement