New answers tagged

1

You can call the createBalls at some interval from your game loop, and possibly pass in how many balls you want it to create. For example; public class YourGame extends Game { private long lastTime; @Override public void create() { } @Override public void render() { if (TimeUtils.nanoTime() - lastTime; > ...


0

I had the same Problem with my game and i watch a tutorial series on youtube from Brent Aureli. He is explaining this really well i will put a link right here. Maybe it will help you as well . https://www.youtube.com/watch?v=tcH6Mp03KC0 Edit: Have you set the CategoryBits? like that public static final short NOTHING_BIT = 0; public static final short ...


0

You can use the filter on the FixtureDefinitions to define what type of objects can collide with what. You define a category bit-pattern, this describes what the fixture is. Then you define a set of categories that the fixture collides with. For example; class PhysicsConstants { // Categories public static final int CAT_SHIP = 1; public static ...


3

R.U.B.E. does this. The feature was included with the addition of samplers since v1.6.0. This tutorial video gives a description of how it can be done. To test, I used Anko's and Xander's images for comparison. First I imported the image of the sword and heart wand into RUBE (I'm on v1.7.0) and created some samplers (shown by dashed outlines) over them. ...


0

Do I need to create a large static body with the size of the world that can't collide with anything? No. Or is there a better method? In the wise words of master Yoda: Size matters not In this case it means that the joint anchor points on a body need not be inside any of the fixtures of the body. They can be miles away if you want. Make a small ...


9

I tried this. It was hard, but I did it. Left is GIMP, top-right is a Box2D debug renderer, bottom-right is a build shell Code repository for reference The full code is on github here. It's scattered in a whole lot of files, so it's a bit big to put here. See below for an explanation of the technique. How? I used ImageMagick, Potrace, Node.js ...


0

Try setting the position on the FixtureDef. I'll assume that you already converted the units to Box2d: public static Body createCarBody(Vector2 position, float sizeX, float sizeY, float density, float friction, float restitution, float linearDamping, float angularDamping){ System.out.println("position createCarBody " + position); Body body = ...


0

Instead of applying the position to the Shape if the FixtureDef, apply the position to the Body. Something like this might work for you; public static Body createCarBody(Vector2 position, float sizeX, float sizeY, float density, float friction, float restitution, float linearDamping, float angularDamping) { System.out.println("position createCarBody " ...


0

Your code is a little bit confuse. Also, I tried cloning it and the project is incomplete, so I can't import it. If I understood your code, you're using box2d bodies but you're not setting the sprite position taking in consideration the Box2d units. Box2d works with meters, so you have to convert pixels to meters and take in consideration the fact that box2d ...


0

This is a really interesting question. I think the way you could do this, using strictly box2d, would be store all the points in some kind of array, and then pop them into the polygon function. I've never used a poly myself, but judging from this: http://stackoverflow.com/questions/4360084/creating-complex-shapes-with-box2d You may be able to use the ...


0

Incidentally, I have done exactly what you are trying to do. The only catch is I was using Jbox2d so the code is in Java, but you should still be able to figure it out if you are using C++ You basically need to use joints/motors and all that fun stuff if you want to do swinging action. Here's a snippet of what my code looks like based on the key input: ...


0

Since you're not strictely looking for code-based answers you might want to try: Of course assuming it doesn't constrict your level design. (Skitskraj's answer is pretty good too tho)


2

If I understand the problem correctly, you were close to properly solving it. Your approach with the normals is what you want, but instead of only saving the normal of the last collision, save a list of normals from all current collisions/overlappings. Then, play the sound whenever the new normal of the new collision is not yet present in the list. In ...


1

Ok, I'm piggy-backing on Skitskraj's answer here so if you like mine, upvote his/hers too. Solution: Play the sound only if there is a new contact and there is a significant velocity change. I would suggest using the postSolve callback on the first iteration of the collision to determine if the impulse is above some threshold value required to generate the ...


1

I reccomend you delete and load smaller pieces (~50m) at a time to keep a more stable (if not lower) fps.


3

I don't think you can fix that "loading" issue, if your game has to open a file from HDD, load the content, parse it and draw it there's nothing to do that could speed it up. I would say that, the best you can do is store the whole map in memory and get chunks more often, like 100m sou you should be able to high speed reading from ram and the lag would ...


2

You can find all what you need here Tile maps class, and read the section Rendering Tiled Maps according to Libgdx docs: Performance considerations While we try to make the renderers as fast as possible, there are a few things you can consider to boost rendering performance. Only use tiles from a single tile set in a layer. This will reduce ...


2

Summary My recommendation is to compute a restorative torque to apply to the object. This is physically more accurate than setting the velocity directly, and the simulation will be better behaved. This solution should also work for any launch angle. Below is a gif of this method at work stabilizing arrows launched from a car. Restorative Torque This ...


3

Have you considered playing the sound when the direction of the ball changes? Or like add that as a condition, in addition to the already "collide with object" condition.


1

One way to approach this would be to represent the definition of the first bodies as Rectangles, then the problem of figuring out the position and rotation of the bridges goes aways as the bridge is always made up as a polygon touching the top corners of the Rectangle. The above image was generated using this approach, full source code below. It uses ...


0

Stated that i agree with MickLH comments. Assuming no Air resistance. The flight time of a parabola thorw is : T=2*V0 * sin(a) / g where V0 is launch velocity , a is launch angle and g is gravitational acceleration. Th = V0 * sin(a) / g is the time from ground to higher point. In higher point your desired angle is 0 so compute (0 - angle) / Th ...



Top 50 recent answers are included