Created
July 23, 2013 04:48
-
-
Save jjurach/6059921 to your computer and use it in GitHub Desktop.
Here is a gdx Game class which creates and sets a screen, which clears and then uses a SpriteBatch to draw a single texture. This pair of classes "flickers" or "tears".. it seems to blink as a grey bar goes from top to bottom.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BlankGame extends Game { | |
MainScreen screen; | |
@Override | |
public void create () { | |
MainScreen screen = new MainScreen(); | |
this.setScreen(screen); | |
} | |
@Override | |
public void dispose () { | |
screen.dispose(); | |
} | |
@Override | |
public void render () { | |
super.render(); | |
} | |
} | |
public class MainScreen implements Screen { | |
SpriteBatch batch = new SpriteBatch(); | |
@Override | |
public void resize (int width, int height) { | |
batch.begin(); | |
Texture tile = new Texture(Gdx.files.internal("thatch.png")); | |
int tWidth = tile.getWidth(); | |
int tHeight = tile.getHeight(); | |
if (tWidth <= 0 || tHeight <= 0) { | |
throw new RuntimeException("expected tile width and height"); | |
} | |
int sWidth = Gdx.graphics.getWidth(); | |
int sHeight = Gdx.graphics.getHeight(); | |
Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1); | |
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); | |
batch.draw(tile, (sWidth - tWidth) / 2, (sHeight - tHeight) / 2); | |
batch.end(); | |
} | |
@Override | |
public void render (float delta) { | |
} | |
@Override | |
public void show () { | |
// TODO Auto-generated method stub | |
} | |
@Override | |
public void hide () { | |
// TODO Auto-generated method stub | |
} | |
@Override | |
public void pause () { | |
// TODO Auto-generated method stub | |
} | |
@Override | |
public void resume () { | |
// TODO Auto-generated method stub | |
} | |
@Override | |
public void dispose () { | |
batch.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment