Question

I'm new in programing Java and I want to learn more. I hear about libgdx and box2d, and I want to play a bit with them, I want to create a field with an object that changes the gravity when the screen is touched. My problem is the field, I want to implement something like this:

Shape I want to create

But I don't know how this shape is called, to look over the internet, and how I should keep in memory this shape...

Can you give me some advices and examples, please? :)

Was it helpful?

Solution

Shapes like those are called "Spline"s. There are several different kinds of those.

In Box2D terms you would create a Body with an Edge-Fixture and Box2D will then keep this shape itself, once it was created in the World.

I think you are probably trying to achieve some kind of "ground". So you might want to check out this article: http://www.iforce2d.net/blog/2013-07-20

OTHER TIPS

You can use ChainShape class in Box2D (or JBox2D). Please take a look at this great resource: http://natureofcode.com/book/chapter-5-physics-libraries/

There is a part of using ChainShape class along with Vec2's which define Chain's points.

chainshape example

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top