How to make a game on android libgdx using ShapeRenderer




This video will show you  how to make a basic game on android using libgdx game engine,
I hope you follow along with me and for my upcoming video tutorial. don't forget to subscribe to my channel and turn on the bell icon to get notified every upload of a new video.

Example:


import com.badlogic.gdx.*;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.GL20;

public class ShapeRendererSample implements ApplicationListener{
private OrthographicCamera camera;
private ShapeRenderer sr;
public void create(){
camera = new OrthographicCamera();
configureCamera();
sr = new ShapeRenderer();


}
configureCamera(){
if(Gdx.graphics.getHeight()<Gdx.graphics.getWidth())

camera.setToOrtho(false,800,800*Gdx.graphics.getHeight()/Gdx.graphics.getWidth());
}
else{
     camera.setToOrtho(false,800*Gdx.graphics.getWidth()/Gdx.graphics.getHeight(),800);
}
}
public void render(){
Gdx.gl.glClearColor(0,0,0,0);
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update();
sr.setProjectionMatrix(camera.combined);
sr.begin(ShapeRenderer.ShapeType.Filled);
sr.setColor(Color.RED);
sr.Circle(0,0,4.0f,);
sr.end();

}
public void resize(int width, int height){
configureCamera();

}
public void pause(){

}
public void resume(){

}
public void dispose(){
sr.dispose();
}

}



Post a Comment

0 Comments