1
\$\begingroup\$

I'm using a ConeLight at 180 degrees, with this setup:
pl = new ConeLight(rayHandler, 256, new Color(0.5f, 0.5f, 0.5f, 1f), 280f, 400 - x, 300 - y, 0, 180);
And the object I'm casting a shadow on (with?) is set up like so:

sprite = new Sprite(new Texture(imgP));

BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.DynamicBody;
bodyDef.position.set(x - 392.5f, y - 292.5f);

body = Main.world.createBody(bodyDef);

PolygonShape pushBlock = new PolygonShape();

pushBlock.setAsBox(((float) w / 2), ((float) h / 2));

FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = pushBlock;
fixtureDef.density = 0.5f; 
fixtureDef.friction = 0.8f;
fixtureDef.restitution = 0f;

Fixture fixture = body.createFixture(fixtureDef);

body.setUserData(sprite);
body.setGravityScale(0);
body.setFixedRotation(true);
body.setLinearDamping(40f);

pushBlock.dispose();

The problem is that the light creates the shadows in a sort of glob form in the center of the square (not casting nicely around the corners as I've seen in others' projects), also leaving nearly the whole sprite black. I require the ambient colour to be black, and also require shadows, so Xray is out. I've messed around with filters but haven't been able to achieve what I want - being able to cast shadows without overshadowing the sprite.
Is it possible? How might I do this, if possible?

Edit: I took a screenshot.The screenshot

\$\endgroup\$
1
\$\begingroup\$

This needs to be done when you create the Box2DLight's Light object.

You can fix this by setting the setSoftnessLength(float) on the Light object.

For example:

m_Light = new ConeLight(...);
m_Light.setSoftnessLength(1.5f);
\$\endgroup\$
  • \$\begingroup\$ Unfortunately I can't vote your answer up yet. \$\endgroup\$ – IHazABone Jul 28 '14 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.