Skip to content

Instantly share code, notes, and snippets.

@cobolfoo
Created April 22, 2015 18:50
Show Gist options
  • Save cobolfoo/43f15d06d1331b84f45b to your computer and use it in GitHub Desktop.
Save cobolfoo/43f15d06d1331b84f45b to your computer and use it in GitHub Desktop.
// Initialize the ray handler
RayHandler.setGammaCorrection(true);
RayHandler.useDiffuseLight(true);
rayHandler = new RayHandler(world);
rayHandler.setAmbientLight(0.1f, 0.1f, 0.1f, 0.5f);
rayHandler.setBlurNum(15);
// Set the point light of the player at the center of the screen initially. with 320 pixels of range (radius)
playerLight = new PointLight(rayHandler, 100, new Color(1,1,1,1), 320, Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight()/2);
In the render loop you do:
rayHandler.setCombinedMatrix(stage.getCamera().combined);
rayHandler.updateAndRender();
// Create box2d part (my walls are 64x64 tiles, I center the body(32x32))
BodyDef def = new BodyDef();
def.position.set(new Vector2(getX()+32, getY()+32));
body = parent.screenMain.world.createBody(def);
PolygonShape shape = new PolygonShape();
shape.setAsBox(32, 32);
body.createFixture(shape, 0);
shape.dispose();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment