Search code examples
javaandroidlibgdxbox2d

LibGDX, How to create a 2d collision terrain


How can I create a surface so my bike collides with the ground?

I'm thinking of placing x,y coordinates on the surface, but that will be too straight and I want it more smooth. (I don't want to place 1 million dots)

I don't want the ground to be randomized generated, I want pre-made pictures.

See picture: https://i.sstatic.net/xCevE.png

Is it possible to make a background image (the sky) and another layer with the ground displayed on top of it and then make it collide with my bike?


Solution

  • To create more complex shapes see this :

    https://code.google.com/archive/p/box2d-editor/

    http://www.aurelienribon.com/blog/wp-content/uploads/2012/04/pbe-01.jpg