• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Dynamics.Body类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Box2DX.Dynamics.Body的典型用法代码示例。如果您正苦于以下问题:C# Body类的具体用法?C# Body怎么用?C# Body使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Body类属于Box2DX.Dynamics命名空间,在下文中一共展示了Body类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:25,代码来源:World.cs


示例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();
			}
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:28,代码来源:TimeOfImpact.cs


示例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);
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:28,代码来源:DistanceTest.cs


示例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;
        }
开发者ID:CloneDeath,项目名称:PokemonSmash,代码行数:29,代码来源:Projectile.cs


示例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;
        }
开发者ID:rbrother,项目名称:seikkailulaakso,代码行数:29,代码来源:Breakable.cs


示例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;
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:34,代码来源:PolyCollision.cs


示例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;
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:25,代码来源:ShapeEditing.cs


示例8: JointDef

 public JointDef()
 {
     this.Type = JointType.UnknownJoint;
     this.UserData = null;
     this.Body1 = null;
     this.Body2 = null;
     this.CollideConnected = false;
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:8,代码来源:JointDef.cs


示例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();
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:8,代码来源:RevoluteJointDef.cs


示例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();
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:8,代码来源:DistanceJointDef.cs


示例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);
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:8,代码来源:LineJointDef.cs


示例12: Fixture

 public Fixture()
 {
     UserData = null;
     Body = null;
     _next = null;
     ProxyId = BroadPhase.NullProxy;
     Shape = null;
 }
开发者ID:rbrother,项目名称:seikkailulaakso,代码行数:8,代码来源:Fixture.cs


示例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();
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:17,代码来源:PrismaticJoint.cs


示例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();
		}
开发者ID:ajmaya,项目名称:box2dx,代码行数:12,代码来源:DistanceJoint.cs


示例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;
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:11,代码来源:Joint.cs


示例16: GearJoint

 public GearJoint(GearJointDef def)
     : base(def)
 {
     JointType type = def.Joint1.GetType();
     JointType type2 = def.Joint2.GetType();
     Box2DXDebug.Assert(type == JointType.RevoluteJoint || type == JointType.PrismaticJoint);
     Box2DXDebug.Assert(type2 == JointType.RevoluteJoint || type2 == JointType.PrismaticJoint);
     Box2DXDebug.Assert(def.Joint1.GetBody1().IsStatic());
     Box2DXDebug.Assert(def.Joint2.GetBody1().IsStatic());
     this._revolute1 = null;
     this._prismatic1 = null;
     this._revolute2 = null;
     this._prismatic2 = null;
     this._ground1 = def.Joint1.GetBody1();
     this._body1 = def.Joint1.GetBody2();
     float num;
     if (type == JointType.RevoluteJoint)
     {
         this._revolute1 = (RevoluteJoint)def.Joint1;
         this._groundAnchor1 = this._revolute1._localAnchor1;
         this._localAnchor1 = this._revolute1._localAnchor2;
         num = this._revolute1.JointAngle;
     }
     else
     {
         this._prismatic1 = (PrismaticJoint)def.Joint1;
         this._groundAnchor1 = this._prismatic1._localAnchor1;
         this._localAnchor1 = this._prismatic1._localAnchor2;
         num = this._prismatic1.JointTranslation;
     }
     this._ground2 = def.Joint2.GetBody1();
     this._body2 = def.Joint2.GetBody2();
     float num2;
     if (type2 == JointType.RevoluteJoint)
     {
         this._revolute2 = (RevoluteJoint)def.Joint2;
         this._groundAnchor2 = this._revolute2._localAnchor1;
         this._localAnchor2 = this._revolute2._localAnchor2;
         num2 = this._revolute2.JointAngle;
     }
     else
     {
         this._prismatic2 = (PrismaticJoint)def.Joint2;
         this._groundAnchor2 = this._prismatic2._localAnchor1;
         this._localAnchor2 = this._prismatic2._localAnchor2;
         num2 = this._prismatic2.JointTranslation;
     }
     this._ratio = def.Ratio;
     this._constant = num + this._ratio * num2;
     this._impulse = 0f;
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:51,代码来源:GearJoint.cs


示例17: Initialize

 public void Initialize(Body body1, Body body2, Vec2 groundAnchor1, Vec2 groundAnchor2, Vec2 anchor1, Vec2 anchor2, float ratio)
 {
     this.Body1 = body1;
     this.Body2 = body2;
     this.GroundAnchor1 = groundAnchor1;
     this.GroundAnchor2 = groundAnchor2;
     this.LocalAnchor1 = body1.GetLocalPoint(anchor1);
     this.LocalAnchor2 = body2.GetLocalPoint(anchor2);
     this.Length1 = (anchor1 - groundAnchor1).Length();
     this.Length2 = (anchor2 - groundAnchor2).Length();
     this.Ratio = ratio;
     Box2DXDebug.Assert(ratio > Settings.FLT_EPSILON);
     float num = this.Length1 + ratio * this.Length2;
     this.MaxLength1 = num - ratio * PulleyJoint.MinPulleyLength;
     this.MaxLength2 = (num - PulleyJoint.MinPulleyLength) / ratio;
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:16,代码来源:PulleyJointDef.cs


示例18: PulleyJoint

 public PulleyJoint(PulleyJointDef def)
     : base(def)
 {
     this._ground = this._body1.GetWorld().GetGroundBody();
     this._groundAnchor1 = def.GroundAnchor1 - this._ground.GetXForm().Position;
     this._groundAnchor2 = def.GroundAnchor2 - this._ground.GetXForm().Position;
     this._localAnchor1 = def.LocalAnchor1;
     this._localAnchor2 = def.LocalAnchor2;
     Box2DXDebug.Assert(def.Ratio != 0f);
     this._ratio = def.Ratio;
     this._constant = def.Length1 + this._ratio * def.Length2;
     this._maxLength1 = Box2DX.Common.Math.Min(def.MaxLength1, this._constant - this._ratio * PulleyJoint.MinPulleyLength);
     this._maxLength2 = Box2DX.Common.Math.Min(def.MaxLength2, (this._constant - PulleyJoint.MinPulleyLength) / this._ratio);
     this._impulse = 0f;
     this._limitImpulse1 = 0f;
     this._limitImpulse2 = 0f;
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:17,代码来源:PulleyJoint.cs


示例19: VerticalStack

		public VerticalStack()
		{
			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(50.0f, 10.0f, new Vec2(0.0f, -10.0f), 0.0f);

				BodyDef bd = new BodyDef();
				bd.Position.Set(0.0f, 0.0f);
				Body ground = _world.CreateBody(bd);
				ground.CreateShape(sd);

				sd.SetAsBox(0.1f, 10.0f, new Vec2(20.0f, 10.0f), 0.0f);
				ground.CreateShape(sd);
			}

			float[] xs = new float[5] { 0.0f, -10.0f, -5.0f, 5.0f, 10.0f };

			for (int j = 0; j < 5; ++j)
			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(0.5f, 0.5f);
				sd.Density = 1.0f;
				sd.Friction = 0.3f;

				for (int i = 0; i < 12; ++i)
				{
					BodyDef bd = new BodyDef();

					// For this test we are using continuous physics for all boxes.
					// This is a stress test, you normally wouldn't do this for
					// performance reasons.
					bd.AllowSleep = true;
					bd.Position.Set(xs[j], 0.752f + 1.54f * i);
					Body body = _world.CreateBody(bd);

					body.CreateShape(sd);
					body.SetMassFromShapes();
				}
			}

			_bullet = null;
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:42,代码来源:VerticalStack.cs


示例20: Initialize

		/// Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors.
		public void Initialize(Body body1, Body body2,
						Vec2 groundAnchor1, Vec2 groundAnchor2,
						Vec2 anchor1, Vec2 anchor2,
						float ratio)
		{
			Body1 = body1;
			Body2 = body2;
			GroundAnchor1 = groundAnchor1;
			GroundAnchor2 = groundAnchor2;
			LocalAnchor1 = body1.GetLocalPoint(anchor1);
			LocalAnchor2 = body2.GetLocalPoint(anchor2);
			Vec2 d1 = anchor1 - groundAnchor1;
			Length1 = d1.Length();
			Vec2 d2 = anchor2 - groundAnchor2;
			Length2 = d2.Length();
			Ratio = ratio;
			Box2DXDebug.Assert(ratio > Settings.FLT_EPSILON);
			float C = Length1 + ratio * Length2;
			MaxLength1 = C - ratio * PulleyJoint.MinPulleyLength;
			MaxLength2 = (C - PulleyJoint.MinPulleyLength) / ratio;
		}
开发者ID:ajmaya,项目名称:box2dx,代码行数:22,代码来源:PulleyJoint.cs



注:本文中的Box2DX.Dynamics.Body类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Internals.Core类代码示例发布时间:2022-05-24
下一篇:
C# Common.Vec2类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap