Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libgdx and android application. Image as background

I am new and I just start my journey with libgdx. I would like to know how I can do image.png in resolution 960x640 as background in my game? This is possible? Thx for advices and forbearance. Maybe you hava a simply tutorial? This is my render class:

public void render() {

     texture = new Texture(Gdx.files.internal("E:/background.png"));

     Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); 
     batch.begin();
     batch.draw(texture, 0, 0);
     batch.end();
}

Second question. I need to insert two active images, active means when I click on that image, the next image show me on the screen. I want to implement action when I click on that picture.

like image 966
edi233 Avatar asked Feb 21 '12 20:02

edi233


1 Answers

In your create() method, create a new Texture referencing your image.png, and then use your existing SpriteBatch to render it in the render() loop. Immediately after your GL.clear() call, go your batch.draw(backgroundTexture, 0. 0) and make sure you're in OrthographicProjection mode for your camera.

like image 177
Shinzul Avatar answered Oct 19 '22 14:10

Shinzul