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

C# Dynamics.Fixture类代码示例

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

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



Fixture类属于FarseerPhysics.Dynamics命名空间,在下文中一共展示了Fixture类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AreaBody_OnSeparation

 public void AreaBody_OnSeparation(Fixture fixa, Fixture fixb)
 {
     if (fixb.Body.BodyId == 19)
         {
             isTouchingPickUp = false;
         }
 }
开发者ID:hvp,项目名称:Squareosity,代码行数:7,代码来源:Area.cs


示例2: CreateBody

        public override Body CreateBody(World world)
        {
            Int32 count = 0;
            foreach (var key in _resource.TileDefinitionKeys)
            {
                var tileDefinition = (TerrainTileDefinitionResource)ResourceDictionary.GetResource(key);

                if (!String.IsNullOrEmpty(tileDefinition.CollisionHullKey))
                {
                    var vertices = new Vertices((Vector2[])this.ResourceDictionary.GetResource(tileDefinition.CollisionHullKey));

                    var body = new Body(world);
                    _bodies.Add(body);
                    body.BodyType = BodyType.Static;

                    var location = ((ILocatable)_actor).Location;
                    body.Position = new Vector2(((count % _resource.Columns) * _resource.TileWidth + location.X) / Settings.MetersToPixels, ((Int32)(count / _resource.Columns) * _resource.TileHeight + location.Y) / Settings.MetersToPixels);
                    
                    var shape = new PolygonShape(vertices, 0f);
                    var fixture = new Fixture(body, shape, 1.0f);
                    
                    fixture.UserData = new CollisionData { Actor = _actor, Data = tileDefinition.CollisionData };
                }
                
                count++;
            }
            return null;
        }
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:28,代码来源:TerrainPhysics.cs


示例3: OnCollision

        protected override bool OnCollision(Fixture projectile, Fixture collided, Contact contact)
        {
            if (NoCollide)
                return false;

            var collidedUnit = (collided.Body.UserData is Unit) ? (Unit)(collided.Body.UserData) : null;

            if (collidedUnit != null) {
                if (collidedUnit == Owner) {
                    Owner.ModifyAttackCooldown(-1000f);
                    Expire();
                }
                else {
                    foreach (Aura aura in Auras) {
                        collidedUnit.AddAura(aura);
                    }
                    collidedUnit.Hurt(Damage);
                    Body.LinearVelocity = Vector2.Zero;
                    Body.IgnoreGravity = false;
                    Body.ApplyLinearImpulse(new Vector2((Owner.Position.X - collidedUnit.Position.X)*7, -200));
                    Body.ApplyTorque(-2000f);
                    Body.CollidesWith = Category.Cat1 | Category.Cat2;
                    Body.CollisionCategories = Category.Cat5;
                }
            }

            return false;
        }
开发者ID:ndssia,项目名称:Corsair3,代码行数:28,代码来源:DravensAxes.cs


示例4: Turret

        public Turret(Vector2 farseerLoc, World w, RagdollManager r, Fixture f)
        {
            

            DebugMaterial gray = new DebugMaterial(MaterialType.Blank)
            {
                Color = Color.DarkGray
            };

            body = new Body(w);
            pivot = FixtureFactory.AttachCircle(.9f, 1, body, gray);
            FixtureFactory.AttachRectangle(barrelLength, .5f, 1, new Vector2(barrelLength / 2, 0), body, gray);
            body.Position = farseerLoc;
            body.BodyType = BodyType.Dynamic;
            //b.CollidesWith = Category.None;

            if (f == null)
            {

                motor = JointFactory.CreateFixedRevoluteJoint(w, body, Vector2.Zero, farseerLoc);
            }
            else
            {
                motor = new RevoluteJoint(body, f.Body, Vector2.Zero, f.Body.GetLocalPoint(farseerLoc));
                w.AddJoint(motor);
            }

            motor.MotorEnabled = true;
            motor.MaxMotorTorque = 5000;

            Init(w, r);
        }
开发者ID:guozanhua,项目名称:KinectRagdoll,代码行数:32,代码来源:Turret.cs


示例5: ProximityTrigger

 public ProximityTrigger(Body sensorBody, Fixture sensorTemplate)
 {
     this.sensorBody = sensorBody;
     this.CreateSensors(sensorTemplate);
     this.IsEnabled = true;
     this.IsContinuous = false;
 }
开发者ID:00erik2,项目名称:Physicist,代码行数:7,代码来源:ProximityTrigger.cs


示例6: body_OnCollision

        bool body_OnCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
        {
            if (body.BodyType == BodyType.Static) return true;

            Fixture surface;
            if (fixtureA.Body == body)
                surface = fixtureB;
            else
                surface = fixtureA;

            if (surface.Body.BodyType == BodyType.Static && surface.Shape.MassData.Area > 100)
            {
                // rotate to contact normal
                Vector2 normal = contact.Manifold.LocalNormal;

                if (Vector2.Dot(normal, body.LinearVelocity) > 0)
                {
                    return false;
                }

                isPendingAttach = true;
                pendingRotation = (float)Math.Atan2(normal.Y, normal.X);

                body.CollidesWith = Category.None;

                return false;
            }

            return true;
        }
开发者ID:guozanhua,项目名称:KinectRagdoll,代码行数:30,代码来源:WallPopper.cs


示例7: CollisionWithEnemy

        // Collision handlers
        public bool CollisionWithEnemy(Fixture f1, Fixture f2, Contact contact)
        {
            Vector2 normal;
            FixedArray2<Vector2> points;
            contact.GetWorldManifold(out normal, out points);

            foreach (IGameComponent comp in this.game.Components)
            {
                GameEnemy enemy = comp as GameEnemy;
                if (enemy != null)
                {
                    if (enemy.getFixture() == f2)
                    {

                        if ((Math.Abs(normal.Y) > Math.Abs(normal.X)) && (normal.Y < 0))    // The contact is coming from above
                        {
                            enemy.Die(); // Uncomment this line if we decide to fix the timing so we dispose after the animation
                            this.increaseScore(10);
                            this.Jump();
                            break;
                        }
                        else
                        {
                            this.Die();
                        }

                        break;
                    }
                }
            }

            return true;
        }
开发者ID:askjervold,项目名称:limak,代码行数:34,代码来源:GamePlayer.cs


示例8: OnCollision

        public virtual bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            Vector2 normal = Vector2.Zero;

            Contact currentContact = contact;
            Vector2 nextNormal = Vector2.Zero;
            FixedArray2<Vector2> fx; // No idea what that is, but the function wants it
            // Iterate through the contacts, summing the normals
            do
            {
                Vector2 vec = Vector2.Zero;
                contact.GetWorldManifold(out vec, out fx);
                normal += vec;
                currentContact = currentContact.Next;
            } while (currentContact != null);

            if (normal.Y > Y && normal.X == 0)
            {
                Pressed = true;

                _pressing.Add(fixtureB);
            }

            return true;
        }
开发者ID:Catchouli-old,项目名称:Fariss,代码行数:25,代码来源:PressurePad.cs


示例9: Ship

        public Ship(World world, SpawnData spawn, int id)
        {
            Ball = null;
            Id = id;
            IsThrusting = false;
            IsReversing = false;
            IsBoosting = false;
            IsLeftTurning = false;
            IsRightTurning = false;
            IsShooting = false;
            IsBlocked = false;
            IsBlockedFrame = false;

            Color = spawn.Color;
            var body = new Body(world);

            body.Rotation = FMath.Atan2(-spawn.Position.Y, -spawn.Position.X);
            body.Position = spawn.Position;
            var shape = new CircleShape(radius, 1f);
            body.BodyType = BodyType.Dynamic;
            body.FixedRotation = true;
            Fixture = body.CreateFixture(shape);
            Fixture.Restitution = restitution;

            var bodyGravity = new Body(world);
            bodyGravity.Position = spawn.Position;
            var shapeGravity = new CircleShape(radiusGravity, 1f);
            bodyGravity.FixedRotation = true;
            FixtureGravity = bodyGravity.CreateFixture(shapeGravity);
            FixtureGravity.IsSensor = true;
        }
开发者ID:det,项目名称:Rimbalzo,代码行数:31,代码来源:Ship.cs


示例10: HandleRaycast

        private float HandleRaycast(Fixture fixture, Vector2 point, Vector2 normal, float fraction)
        {
            if (fixture.CollisionCategories == _type.Category)
                return fraction;

            var dist = (point - Body.Position).Length();

            var linksCount = (int)(Math.Floor(dist / LinksHeight) / 2);
            if (linksCount == 0)
                return fraction;

            // TODO: adapt this to Farseer 3.5
            /*var chain = Add(K2.World.CreateChain(Body.Position, point, .005f, LinksHeight, linksCount, 1, false));

            if (!chain.Bodies.Any())
                return 0;

            chain.Bodies.ForEach(b => b.SetCollisionType(_type));

            var first = chain.Bodies.First();
            var last = chain.Bodies.Last();
            K2.World.CreateRevoluteJoint(fixture.Body, last, new Vector2(0, LinksHeight));
            K2.World.CreateRevoluteJoint(Body, chain.Bodies.First(), Vector2.Zero);
            //_joint = _factory.CreateDistanceJoint(first, last, new Vector2(0, LinksHeight), Vector2.Zero);*/
            return 0;
        }
开发者ID:hgrandry,项目名称:Mgx,代码行数:26,代码来源:GrapplingShooter.cs


示例11: PhysicsGameObject

        public PhysicsGameObject(Texture2D texture, World world, bool isStatic,
            Vector2 position, float scale, float density, float depth)
        {
            this.texture = texture;
            this.scale = scale;
            this.density = density;
            this.depth = depth;

            //loads body details
            objectBody = new Body(world);
            objectBody.Position = position;
            if (isStatic)
                objectBody.BodyType = BodyType.Static;
            else
                objectBody.IsStatic = false;
            this.scale = scale;
            this.depth = depth;

            //loads fixture details
            objectFixture = FixtureFactory.AttachRectangle(
               texture.Width / PIXELS_PER_METER,
               texture.Height / PIXELS_PER_METER,
               1, Vector2.Zero, objectBody);
            objectFixture.Restitution = RESTITUTION;
            objectFixture.Friction = FRICTION;
        }
开发者ID:TiegiserII,项目名称:Caffeine-Junkies-Game,代码行数:26,代码来源:PhysicsGameObject.cs


示例12: LoadContent

		public void LoadContent(ContentManager content, World world, Vector2 position, Vector2 size)
		{
			body = BodyFactory.CreateRectangle(world, size.X, size.Y, 1f);

			body.FixedRotation = true;

			body.FixtureList[0].UserData = 9000;

			body.Position = ConvertUnits.ToSimUnits(position);

			body.BodyType = BodyType.Dynamic;

            CircleShape circle1 = new CircleShape(size.X / 4, 1f);
            CircleShape circle2 = new CircleShape(size.Y / 6, 1f);
            CircleShape circle3 = new CircleShape(size.Y / 6, 1f);

            circle1.Position = new Vector2(0, -size.Y / 3);
            circle2.Position = new Vector2(-1.5f * size.X / 5, -size.Y / 10);
			circle3.Position = new Vector2(-0.4f * size.X / 5, -size.Y / 10);

			head = body.CreateFixture(circle1);
			hands[0] = body.CreateFixture(circle2);
			hands[1] = body.CreateFixture(circle3);

			head.UserData = (int)10000;
			hands[0].UserData = (int)11000;
			hands[1].UserData = (int)11000;

			image.LoadContent(content, "Graphics/tezka", Color.White, position);

			image.ScaleToMeters(size);

			image.position = ConvertUnits.ToDisplayUnits(body.Position);
		}
开发者ID:Woktopus,项目名称:Acllacuna,代码行数:34,代码来源:Boss.cs


示例13: DebrisComponent

 public DebrisComponent(Fixture fixture, int timeToLive, float restitutionIncrement)
 {
     _fixture = fixture;
     _timeToLive = timeToLive;
     _restitutionIncrement = restitutionIncrement;
     _restitutionCount = 0;
 }
开发者ID:klutch,项目名称:StasisEngine,代码行数:7,代码来源:DebrisComponent.cs


示例14: ColEvent

			public ColEvent(EventType type, Fixture fxA, Fixture fxB, CollisionData data)
			{
				this.Type = type;
				this.FixtureA = fxA;
				this.FixtureB = fxB;
				this.Data = data;
			}
开发者ID:griffynn,项目名称:duality,代码行数:7,代码来源:RigidBody.cs


示例15: OnCollisionExit

 public override void OnCollisionExit(Fixture fixtureA, Fixture fixtureB)
 {
     //Is the CameraObject for the X or Y axis?
     if (this.height > this.width) // It is for the X axis
     {
         //Check which side the player is leaving
         if (fixtureB.Body.Position.X < fixtureA.Body.Position.X && fixtureB.Body.LinearVelocity.X < 0) //Player is moving to the left
         {
             if (this.unlockDirection == UnlockWhenPlayerMovesLeft)
             {
                 this.UnlockCameraHorizontally();
             }
             else
             {
                 this.LockCameraHorizontally();
             }
         }
         else if (fixtureB.Body.Position.X > fixtureA.Body.Position.X && fixtureB.Body.LinearVelocity.X > 0) //Player is moving to the right
         {
             if (this.unlockDirection == UnlockWhenPlayerMovesRight)
             {
                 this.UnlockCameraHorizontally();
             }
             else
             {
                 this.LockCameraHorizontally();
             }
         }
     }
     else //It is for the Y axis
     {
     }
 }
开发者ID:Orujimaru,项目名称:Orujin2,代码行数:33,代码来源:CameraObject.cs


示例16: CoolRibbonObject

        public CoolRibbonObject(World world, Texture2D tex)
        {
            points = new List<Vector2>();

            points.Add(new Vector2(4, -1));
            points.Add(new Vector2(4, 22));
            points.Add(new Vector2(30, 22));
            points.Add(new Vector2(30, -1));

            stops = new float[4];

            for(int i = 0; i < points.Count-1; i++)
            {
                stops[i] = Vector2.Distance(points[i],points[i+1]);
            }

            body = BodyFactory.CreateBody(world);
            body.BodyType = BodyType.Static;
            body.Position = new Vector2(0,0);
            body.UserData = this;

            hinges = new List<Hinge>();

            AddBox(world, tex);

            ChainShape chain = new ChainShape(new Vertices(points));

            fixture = body.CreateFixture(chain);
        }
开发者ID:kjin,项目名称:ribbon_gameplay,代码行数:29,代码来源:CoolRibbonObject.cs


示例17: OneSidedPlatformTest

        private OneSidedPlatformTest()
        {
            //Ground
            BodyFactory.CreateEdge(World, new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f));

            // Platform
            {
                Body body = BodyFactory.CreateBody(World);
                body.Position = new Vector2(0.0f, 10.0f);

                PolygonShape shape = new PolygonShape(1);
                shape.SetAsBox(3.0f, 0.5f);
                _platform = body.CreateFixture(shape);

                _top = 10.0f + 0.5f;
            }

            // Actor
            {
                Body body = BodyFactory.CreateBody(World);
                body.BodyType = BodyType.Dynamic;
                body.Position = new Vector2(0.0f, 12.0f);

                _radius = 0.5f;
                CircleShape shape = new CircleShape(_radius, 20);
                _character = body.CreateFixture(shape);

                body.LinearVelocity = new Vector2(0.0f, -50.0f);
            }
        }
开发者ID:danzel,项目名称:FarseerPhysics,代码行数:30,代码来源:OneSidedPlatformTest.cs


示例18: Goalie

 public Goalie(World world, GoalieData spawn)
 {
     var body = new Body(world);
     var angle = spawn.End - spawn.Begin;
     body.Rotation = FMath.Atan2(angle.Y, angle.X);
     segment.A = spawn.Begin;
     segment.B = spawn.End;
     var normal = new Vector2(-angle.Y, angle.X);
     normal.Normalize();
     delta = normal * .5f;
     segmentOut.A = spawn.Begin + delta;
     segmentOut.B = spawn.End + delta;
     segmentIn.A = spawn.Begin - delta;
     segmentIn.B = spawn.End - delta;
     body.Position = spawn.Begin;
     var verts = new Vertices();
     verts.Add(new Vector2(left, bottom));
     verts.Add(new Vector2(right, bottom));
     verts.Add(new Vector2(right, top));
     verts.Add(new Vector2(left, top));
     var shape = new PolygonShape(verts, 1f);
     body.FixedRotation = true;
     body.BodyType = BodyType.Dynamic;
     Fixture = body.CreateFixture(shape);
 }
开发者ID:det,项目名称:Rimbalzo,代码行数:25,代码来源:Goalie.cs


示例19: SensorTest

        private SensorTest()
        {
            {
                Body ground = BodyFactory.CreateBody(World);

                {
                    EdgeShape shape = new EdgeShape(new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f));
                    ground.CreateFixture(shape);
                }

                {
                    CircleShape shape = new CircleShape(5.0f, 1);
                    shape.Position = new Vector2(0.0f, 10.0f);

                    _sensor = ground.CreateFixture(shape);
                    _sensor.IsSensor = true;
                }
            }

            {
                CircleShape shape = new CircleShape(1.0f, 1);

                for (int i = 0; i < Count; ++i)
                {
                    _touching[i] = false;
                    _bodies[i] = BodyFactory.CreateBody(World);
                    _bodies[i].BodyType = BodyType.Dynamic;
                    _bodies[i].Position = new Vector2(-10.0f + 3.0f * i, 20.0f);
                    _bodies[i].UserData = i;

                    _bodies[i].CreateFixture(shape);
                }
            }
        }
开发者ID:hilts-vaughan,项目名称:Farseer-Physics,代码行数:34,代码来源:SensorTest.cs


示例20: collisionBullet

        public Boolean collisionBullet(Fixture fixA, Fixture fixB, Contact contact)
        {
            if (!isHung)
            //je joins la balle a la cible avec un angle strict, et la balle au joueur avec un distance joint
            {
                Vector2 diff = bullet.FixtureObject.Body.Position - fixB.Body.Position;
                //ObjCercle bulletTP = new ObjCercle(diff, radius, 0.0f, worldPhysic, fixB.Body);
                //worldPhysic.RemoveBody(bullet.FixtureObject.Body);
                //bullet = bulletTP;
                //bullet.addDisplayer();

                //juncture = new FarseerPhysics.Dynamics.Joints.DistanceJoint(juncturePoint.Body, bullet.FixtureObject.Body, new Vector2(1, 1)/*AnchorPointJuncturePoint*/, new Vector2(1, 1));
                //juncture = JointFactory.CreateDistanceJoint(worldPhysic, juncturePoint.Body, bullet.FixtureObject.Body, new Vector2(10,0)/*AnchorPointJuncturePoint*/, new Vector2(10,0));
                //worldPhysic.AddJoint(juncture);

                //junctureHook = JointFactory. CreateRevoluteJoint(worldPhysic, fixA.Body, fixB.Body, diff);
                //junctureHook.MaxImpulse = 3;
                //junctureHook.

                worldPhysic.RemoveBody(bullet.FixtureObject.Body);
                bullet = null;
                //bullet.FixtureObject.Body.BodyType = BodyType.Dynamic;
                juncture = new FarseerPhysics.Dynamics.Joints.DistanceJoint(juncturePoint.Body, fixB.Body, AnchorPointJuncturePoint, new Vector2(diff.X, diff.Y));

                worldPhysic.AddJoint(juncture);
                isHung = true;
            }
            return false;
        }
开发者ID:stickman,项目名称:gameBungee,代码行数:29,代码来源:Bullet.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Dynamics.TimeStep类代码示例发布时间:2022-05-26
下一篇:
C# Dynamics.BreakableBody类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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