Created
April 22, 2015 18:50
-
-
Save cobolfoo/43f15d06d1331b84f45b to your computer and use it in GitHub Desktop.
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
// 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