English 中文(简体)
如何增加用户界定的机构
原标题:How to add a user-defined body
  • 时间:2012-01-16 08:34:53
  •  标签:
  • box2d
  • shapes

I am a beginer of BOX2D, and I found I don t know how to CREATE a user-difined body from specific sprite. All box2d body shape are Polygon related shapes :(

下面,由于您的事先帮助,我仅靠大麻使用一种特定的形式。

PhysicsSprite *rightSprite =  [PhysicsSprite spriteWithFile:@"mySpecificShape.png"];
[self addChild:rightSprite];

b2BodyDef bodyDef;
bodyDef.type = b2_staticBody;
bodyDef.position = b2Vec2(400/PTM_RATIO, 512/PTM_RATIO);

b2Body * bodyA = world->CreateBody(&bodyDef);
bodyA->SetUserData(rightSprite);
[rightSprite setPhysicsBody:bodyA];
问题回答

这样做并不简单。 你们必须从简单的形状——多角、圈子和边缘——来建设自己的体。

You can do this be an external tool , There are few tools that you can read about:

Vertex Helper 和物理学编辑。

I m recommending on Physics Editor in this tool you load you image , and its export the shape into a XML , than you can load it in the engine that you are using and it will collide in the proper why

你们可以读到更多,可以下载:

http://www.codeandweb.com/physicseditor/feature





相关问题
How to cast a shape object?

I want to assign a ComboBox control to a class member of ComboBox type. This control is in a group on a worksheet. The problem is through GroupItems property, I can only get a Shape object, not a ...

Drag & Drop Shapes on Canvas

I used MouseDragElementBehavior to let user drag & drop Shapes on a Canvas: MouseDragElementBehavior dragBehavior = new MouseDragElementBehavior(); dragBehavior.Attach(myShape); Now, I would ...

Java Updating Small Circles

I need to display a large number (500+) of small circles on a form to simulate LEDs. However, these circles need to be quite small, around 8 or 9 pixels diameter. So far, in my testing, I ve put ...

OpenGL, remove sections from a shape

In OpenGL, how can one cut a triangle shaped hole from a square? making the hole transparent. I m also using SDL, maybe it can be achieved with an SDL surface?

Java OpenGL draw a star

I m working on an OpenGL project in which I want to draw a star. It doesn t necessarily have to be a 3d looking star (2d looking is fine). I have the xyz coordinates for the center of the star and I ...

Creating a Squircle

I m a first year programmer. I m trying to create a squircle. (square with round corners). So far i have managed to get. I have been given the constants of a,b and r. If anyone could help i would be ...

热门标签