Tag Info

New answers tagged

0

the RayHandler render creates a black and white mask and mask the alpha channel with it, so some parts are darker what you can do is detect that an object should now lighten (maybe with the use of RayHandler.pointAtLight(x,y), or calculate the radious of the light ) and edit the mask so the whole area of the object is totally white(or as light as the edge ...


0

Okay I feel like an idiot now. The problem was that I had the box2d debug renderer running all along. The only thing it does is render a bunch of lines around boxes which I didn't think would be that costly, and I found it to be quite useful so never turned it off during development. Thanks for your input though. PS: Still curious though as to why it would ...


0

Run your simulation on the Server, send Clients timestamped object state updates (delta-compressed) at a fixed rate, send other game event messages as they occur, and let Clients deal with interpolating/extrapolating between network state updates. You don't need to send updates for all objects in the game, to all clients. Simulate the player camera frustums ...


0

Your problem is that you're exceeding Box2D's maximum offset-per-physics-update. This is a common mistake. There is a maximum movement limit of 2.0 units per time step give in the file b2Settings.h in the source code. Assuming that you're running at 60 updates per second, your starting velocity of 120 units per second is already exactly at Box2D's ...


1

Well on your question fixture def, you set sensor true which makes it ignore collisions. fixtureDef.isSensor = true; Unrelated but as a side note, I think you need to dispose your polygonShape at the end after creating everything. polygonShape.dispose()


3

Yet having these 3500 sleeping static bodies degrades performance to such a degree that even when running the game on my MacBook Pro 2012 in a Genymotion emulator, I get about 5 FPS. As Anko said in his comment, you shouldn't be guessing about whether this is Box2D or rendering or something else. Measure what's taking all the frame time. Use a profiler ...


1

Try sprite.setOriginCenter(); This should help


1

There is no need to update each body when modifying the camera. Bodies' positions stays the same when you move the camera around. batch.setProjectionMatrix(cam.combined); already offsets your batch to the right position. The problem must result of this line : player.body.setTransform(fingerPosition.x, fingerPosition.y, player.body.getAngle()); Assuming ...


1

Assuming the rope has no weight, this problem is about finding the lowest point of an ellipse (http://en.wikipedia.org/wiki/Ellipse ) where (PF1+PF2 == rope length) This image show how the ellipse is rotated. From there you can figure out the lowest point by tracing the ellipse with a binary search to find the lowest point. That's where the weight should ...


1

I have seen two ways of achieving this, one is to let the UserData of the Box2D Body hold the Sprite. body.setUserData(mySprite); And in the update you retrieve that and apply position and rotation to the Sprite according to the Body's transform; Sprite sprite = (Sprite)body.getUserData(); Vector2 position = body.getPosition(); // Center body is center ...


1

You can use the setUserData method to attach an Object to the box2D body (like for example a Sprite or an Actor): body.setUserData(sprite); Accordingly you can get your Sprite back like this: (Sprite) body.getUserData(); Note that you need to cast to Sprite.


0

replace this line: var angle = ((b.GetAngle()*180)/(Math.PI))/SCALE; with this: var angle = b.GetAngle(); the input parameter in ctx.rotate should be in radians, so there is no need to convert it in your code in any way. The output of b.GetAngle() is in radians.


0

When using box2D, the camera you use to render your world should not be your resolution size, it should be your resolution divided by PPM. So when you are making your cam, do something like this: public static final int PPM = 16; //This means that for every meter in your box2D world there are 16 pixels on your camera. If you have a body at position 1,1 and ...


1

Correct me if I'm wrong, but I believe the density of fixtures will affect the mass of the body. Anyway, the only settings that affect the "bounciness" is restitution. If changing the restitution of the box doesn't fix it, have you tried changing the restitution of the ground (or whatever the box shouldn't be bouncing off of)? If that doesn't work, as far ...



Top 50 recent answers are included