Stage stage;
TextureAtlas atlas;
@Override
public void create() {
stage =new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
atlas =new TextureAtlas(Gdx.files.internal("test/test.pack"));
Image image1=new Image(atlas.findRegion("005"));
image1.setPosition(20, 20);
image1.scale(0.001f);
Image image2=new Image(atlas.findRegion("006"));
image2.setPosition(400, 20);
image2.scale(0.001f);
stage.addActor(image1);
stage.addActor(image2);
}
@Override
public void resize(int width, int height) {
// TODO Auto-generated method stub
}
@Override
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
// TODO Auto-generated method stub
stage.dispose();
}
运行效果图: