0

I'm using box2dflash for as3 and i need to create curvy ground like thisNeeded ground.

Facts:

  • I can't create one solid object as far as I know because box2d support convex objects;
  • I didn't find any line-based objects.

Question: Is there any better way than doing this the way shown on image below? maybe bad solution

2 Answers2

1

I couldn't say for sure, but I think that is the best way of doing it.

There is some code on this article for doing a similar thing: Terrain like tiny wings

You will want to look at the "drawHill" function (Line 91). Sorry I can't be of much more help, I have limited experience with box2D.

Michael
  • 325
  • 1
  • 5
0

I've discovered that you actually can create line.

var groundFixtureDef:b2FixtureDef = new b2FixtureDef();
groundFixtureDef.density = 1;
var someShape: b2PolygonShape = new b2PolygonShape();
someShape.SetAsArray( new Array(new b2Vec2(-3,0),new b2Vec2(2,0)), 2);
groundFixtureDef.shape = someShape;

This would create a simple line. But if you add more points, it'll form convex shape.