English 中文(简体)
方框2D - 是否有办法清理地面布2EdgeShape
原标题:Box 2D - Is there a way to Move the Ground b2EdgeShape up

I m在“i”游戏中工作,地面长,重复直径层的物体,该物体在屏幕底线上延伸了约30个。 我试图使我的地面对冲形成30个els子,这样,当参与者从跳跃到地面上的土地时,他就会以地面形象为重。 当我尝试增加以下法典时,它就没有工作:

b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0, 30/PTM_RATIO);

b2Body *groundBody=world->CreateBody(&groundBodyDef);

b2EdgeShape groundLine;
groundLine.Set(b2Vec2(0, 30/PTM_RATIO), b2Vec2(screenSize.width/PTM_RATIO, 30/PTM_RATIO));
groundBody->CreateFixture(&groundLine, 0);

I realize I could probably use a rectangle shape for the ground, but since my player sprite is only colliding with the top of the image, I would rather get away with an edge shape.

问题回答

当你确定形状的位置时(例如,根据你的例子),你将担任关于体/体格的地位的立场的职位。 因此,贵机构已经处于 y30,因此,你们的形状将是上面的30个。

For ground bodies I recommend just leaving the body position at 0,0 and then adding the fixtures at the position you want them - typically there is only one ground body.

我也建议采用缺省略语,以便你能够看到实际进展,立即表明问题。





相关问题
Breaking a concave polygon into convex ones

I m using a game physics library (Box2D) which only supports convex polygon shapes. However, I d like the level builder to be able to just specify concave polygons without having to worry about that. ...

How to set the position of a sprite within a box2d body?

Basically I have 2 polygons for my body. When I add a sprite for userData, the position of the texture isn t where I want it to be. What I want to do is adjust the position of the texture within the ...

Farseer or Box2D? Top-down shooter physics implementation

Which one of these would fit a top down shooter better? I ve heard that Box2D performs faster, but I ve also noticed that it lacks wider community support for XNA (it rather seems to be used for ...

Box2D in Flash runs quicker when drawing debug data than not

I ve created a small game with Box2d for AS3 - I have sprites attached to the stage that take their position from the underlying Box2d world. These sprites are mostly PNGs. When the game runs with ...

GetBodyCount() always returning 0 in Box2d?

I am using the cocos2d-iphone + Box2d engine, I have a simple call in Box2d to create a body: b2Body *crateBody = world->CreateBody(&crateBodyDef); Then I am printing the newly incremented ...

box2d: bigger clickable/touchable area

I m using Box2D on my iPhone app using Cocos2D. I m using mouse joint to drag objects by touch. The touch event is handled to find the corresponding Box2D body using AABB queries. I would want to ...

Falling object in Box2D should rotate due to centre of mass?

I m trying to simulate a falling balloon in Box2DAS3. What is important is that balloon falls the such that the bottom part were you blow it up rotates towards the bottom if it s knock sideways or is ...