本文整理汇总了C#中Box2DX.Dynamics.Body类的典型用法代码示例。如果您正苦于以下问题:C# Body类的具体用法?C# Body怎么用?C# Body使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Body类属于Box2DX.Dynamics命名空间,在下文中一共展示了Body类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: World
public World(AABB worldAABB, Vec2 gravity, bool doSleep)
{
this._destructionListener = null;
this._boundaryListener = null;
this._contactFilter = WorldCallback.DefaultFilter;
this._contactListener = null;
this._debugDraw = null;
this._bodyList = null;
this._contactList = null;
this._jointList = null;
this._bodyCount = 0;
this._contactCount = 0;
this._jointCount = 0;
this._warmStarting = true;
this._continuousPhysics = true;
this._allowSleep = doSleep;
this._gravity = gravity;
this._lock = false;
this._inv_dt0 = 0f;
this._contactManager = new ContactManager();
this._contactManager._world = this;
this._broadPhase = new BroadPhase(worldAABB, this._contactManager);
BodyDef def = new BodyDef();
this._groundBody = this.CreateBody(def);
}
示例2: TimeOfImpact
public TimeOfImpact()
{
{
PolygonDef sd = new PolygonDef();
sd.Density = 0.0f;
sd.SetAsBox(0.1f, 10.0f, new Vec2(10.0f, 0.0f), 0.0f);
BodyDef bd = new BodyDef();
bd.Position.Set(0.0f, 20.0f);
bd.Angle = 0.0f;
_body1 = _world.CreateBody(bd);
_shape1 = _body1.CreateShape(sd);
}
{
PolygonDef sd = new PolygonDef();
sd.SetAsBox(0.25f, 0.25f);
sd.Density = 1.0f;
BodyDef bd = new BodyDef();
bd.Position.Set(9.6363468f, 28.050615f);
bd.Angle = 1.6408679f;
_body2 = _world.CreateBody(bd);
_shape2 = (PolygonShape)_body2.CreateShape(sd);
_body2.SetMassFromShapes();
}
}
示例3: DistanceTest
public DistanceTest()
{
PolygonDef sd = new PolygonDef();
sd.SetAsBox(1.0f, 1.0f);
sd.Density = 0.0f;
BodyDef bd = new BodyDef();
bd.Position.Set(0.0f, 10.0f);
_body1 = _world.CreateBody(bd);
_shape1 = _body1.CreateShape(sd);
PolygonDef sd2 = new PolygonDef();
sd2.VertexCount = 3;
sd2.Vertices[0].Set(-1.0f, 0.0f);
sd2.Vertices[1].Set(1.0f, 0.0f);
sd2.Vertices[2].Set(0.0f, 15.0f);
sd2.Density = 1.0f;
BodyDef bd2 = new BodyDef();
bd2.Position.Set(0.0f, 10.0f);
_body2 = _world.CreateBody(bd2);
_shape2 = _body2.CreateShape(sd2);
_body2.SetMassFromShapes();
_world.Gravity = new Vec2(0.0f, 0.0f);
}
示例4: Projectile
public Projectile(Player creator, float x, float y, float width, float height)
: base(creator, 0, 0)
{
/* Create New Projectile Body */
BodyDef def = new BodyDef();
def.IsBullet = true;
def.Position = creator.body.GetPosition() + new Vec2(x, y);
projectile = creator.body.GetWorld().CreateBody(def);
/* Create a fixture for the projectile */
PolygonDef fixdef = new PolygonDef();
fixdef.Density = 1.0f;
fixdef.SetAsBox(width / 2, height / 2);
fixdef.Filter.GroupIndex = creator.ID;
fixture = projectile.CreateFixture(fixdef);
fixture.Filter.CategoryBits = 0x0004;
fixture.Filter.MaskBits = 0xFFFF;
/* Made a 2nd fixture, one to observe all collisions */
fixdef.IsSensor = true;
fix2 = projectile.CreateFixture(fixdef);
fix2.UserData = this;
/* Finally, give this projectile some mass */
projectile.SetMassFromShapes();
/* Also, make sure we destroy the projectile when it is time */
this.OnDestroy += Cleanup;
}
示例5: Breakable
public Breakable()
{
// Ground body
{
BodyDef bd = new BodyDef();
Body ground = _world.CreateBody(bd);
PolygonShape shape = new PolygonShape();
shape.SetAsEdge(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f));
ground.CreateFixture(shape, 0);
}
// Breakable dynamic body
{
BodyDef bd = new BodyDef();
bd.Position.Set(0.0f, 40.0f);
bd.Angle = 0.25f * Box2DX.Common.Settings.PI;
_body1 = _world.CreateBody(bd);
_shape1.SetAsBox(0.5f, 0.5f, new Vec2(-0.5f, 0.0f), 0.0f);
_piece1 = _body1.CreateFixture(_shape1, 1.0f);
_shape2.SetAsBox(0.5f, 0.5f, new Vec2(0.5f, 0.0f), 0.0f);
_piece2 = _body1.CreateFixture(_shape2, 1.0f);
}
_break = false;
_broke = false;
}
示例6: PolyCollision
public PolyCollision()
{
_localPoints[0].state = ContactState.ContactRemoved;
_localPoints[1].state = ContactState.ContactRemoved;
{
PolygonDef sd = new PolygonDef();
sd.Vertices[0].Set(-9.0f, -1.1f);
sd.Vertices[1].Set(7.0f, -1.1f);
sd.Vertices[2].Set(5.0f, -0.9f);
sd.Vertices[3].Set(-11.0f, -0.9f);
sd.VertexCount = 4;
sd.Density = 0.0f;
BodyDef bd = new BodyDef();
bd.Position.Set(0.0f, 10.0f);
_body1 = _world.CreateBody(bd);
_body1.CreateShape(sd);
}
{
PolygonDef sd = new PolygonDef();
sd.SetAsBox(0.5f, 0.5f);
sd.Density = 1.0f;
BodyDef bd = new BodyDef();
bd.Position.Set(0.0f, 10.0f);
_body2 = _world.CreateBody(bd);
_body2.CreateShape(sd);
_body2.SetMassFromShapes();
}
_world.Gravity = Vec2.Zero;
}
示例7: ShapeEditing
public ShapeEditing()
{
{
PolygonDef sd = new PolygonDef();
sd.SetAsBox(50.0f, 10.0f);
BodyDef bd = new BodyDef();
bd.Position.Set(0.0f, -10.0f);
Body ground = _world.CreateBody(bd);
ground.CreateShape(sd);
}
BodyDef bodydef = new BodyDef();
bodydef.Position.Set(0.0f, 10.0f);
_body = _world.CreateBody(bodydef);
PolygonDef sd_ = new PolygonDef();
sd_.SetAsBox(4.0f, 4.0f, new Vec2(0.0f, 0.0f), 0.0f);
sd_.Density = 10.0f;
_shape1 = _body.CreateShape(sd_);
_body.SetMassFromShapes();
_shape2 = null;
}
示例8: JointDef
public JointDef()
{
this.Type = JointType.UnknownJoint;
this.UserData = null;
this.Body1 = null;
this.Body2 = null;
this.CollideConnected = false;
}
示例9: Initialize
public void Initialize(Body body1, Body body2, Vec2 anchor)
{
this.Body1 = body1;
this.Body2 = body2;
this.LocalAnchor1 = body1.GetLocalPoint(anchor);
this.LocalAnchor2 = body2.GetLocalPoint(anchor);
this.ReferenceAngle = body2.GetAngle() - body1.GetAngle();
}
示例10: Initialize
public void Initialize(Body body1, Body body2, Vec2 anchor1, Vec2 anchor2)
{
this.Body1 = body1;
this.Body2 = body2;
this.LocalAnchor1 = body1.GetLocalPoint(anchor1);
this.LocalAnchor2 = body2.GetLocalPoint(anchor2);
this.Length = (anchor2 - anchor1).Length();
}
示例11: Initialize
public void Initialize(Body body1, Body body2, Vec2 anchor, Vec2 axis)
{
this.Body1 = body1;
this.Body2 = body2;
this.localAnchor1 = body1.GetLocalPoint(anchor);
this.localAnchor2 = body2.GetLocalPoint(anchor);
this.localAxis1 = body1.GetLocalVector(axis);
}
示例12: Fixture
public Fixture()
{
UserData = null;
Body = null;
_next = null;
ProxyId = BroadPhase.NullProxy;
Shape = null;
}
示例13: Initialize
/// <summary>
/// Initialize the bodies, anchors, axis, and reference angle using the world
/// anchor and world axis.
/// </summary>
/// <param name="body1"></param>
/// <param name="body2"></param>
/// <param name="anchor"></param>
/// <param name="axis"></param>
public void Initialize(Body body1, Body body2, Vec2 anchor, Vec2 axis)
{
Body1 = body1;
Body2 = body2;
LocalAnchor1 = body1.GetLocalPoint(anchor);
LocalAnchor2 = body2.GetLocalPoint(anchor);
LocalAxis1 = body1.GetLocalVector(axis);
ReferenceAngle = body2.GetAngle() - body1.GetAngle();
}
示例14: Initialize
/// <summary>
/// Initialize the bodies, anchors, and length using the world anchors.
/// </summary>
public void Initialize(Body body1, Body body2, Vec2 anchor1, Vec2 anchor2)
{
Body1 = body1;
Body2 = body2;
LocalAnchor1 = body1.GetLocalPoint(anchor1);
LocalAnchor2 = body2.GetLocalPoint(anchor2);
Vec2 d = anchor2 - anchor1;
Length = d.Length();
}
示例15: Joint
protected Joint(JointDef def)
{
this._type = def.Type;
this._prev = null;
this._next = null;
this._body1 = def.Body1;
this._body2 = def.Body2;
this._collideConnected = def.CollideConnected;
this._islandFlag = false;
this._userData = def.UserData;
}