當前位置: 首頁>>代碼示例>>C#>>正文


C# World.AddBody方法代碼示例

本文整理匯總了C#中Project290.Physics.Dynamics.World.AddBody方法的典型用法代碼示例。如果您正苦於以下問題:C# World.AddBody方法的具體用法?C# World.AddBody怎麽用?C# World.AddBody使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Project290.Physics.Dynamics.World的用法示例。


在下文中一共展示了World.AddBody方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MasslessItem

        public MasslessItem(Texture2D t, PhysicsShape shape, Vector2 position, World w)
            : base(position, w, t.Width, t.Height)
        {
            texture = t;
            body.BodyType = BodyType.Static;
            body.Position = position;

            switch (shape)
            {
                case PhysicsShape.Rectangle:
                    fixture = FixtureFactory.CreateRectangle(
                        texture.Width,
                        texture.Height,
                        0.0f,
                        Vector2.Zero,
                        body);
                    break;
            }

            //fixture.CollisionFilter.IgnoreCollisionWith();

            fixture.OnCollision += new OnCollisionEventHandler(this.OnCollision);
            w.AddBody(body);

            //drawOrigin = new Vector2(texture.Width / 2, texture.Height / 2);
            //drawRectangle = new Rectangle(0, 0, texture.Width, texture.Height);
        }
開發者ID:scastle,項目名稱:Solitude,代碼行數:27,代碼來源:MasslessItem.cs

示例2: Bomb

        public Bomb(Vector2 position, World world, Vector2 velocity)
            : base(position, world, TextureStatic.Get("bomb").Width, TextureStatic.Get("bomb").Height)
        {
            body.BodyType = BodyType.Dynamic;
            texture = TextureStatic.Get("bomb");
            fixture = FixtureFactory.CreateCircle(TextureStatic.Get("bomb").Width / 2, 1, body);

            laidTime = GameClock.Now;
            world.AddBody(body);
            body.LinearVelocity = velocity;
        }
開發者ID:scastle,項目名稱:Solitude,代碼行數:11,代碼來源:Bomb.cs

示例3: Mauler

 public Mauler(Vector2 position, World w)
     : base(position, w, TextureStatic.Get("solitudeMauler").Width, TextureStatic.Get("solitudeMauler").Height)
 {
     health = Settings.maulerHealth;
     world = w;
     body.BodyType = BodyType.Dynamic;
     body.Position = position;
     texture = TextureStatic.Get("solitudeMauler");
     fixture = FixtureFactory.CreateCircle(texture.Width/2, 0.25f, body, Vector2.Zero);
     fixture.OnCollision += new OnCollisionEventHandler(OnCollision);
     world.AddBody(body);
     targetPoint = body.Position;
 }
開發者ID:scastle,項目名稱:Solitude,代碼行數:13,代碼來源:Mauler.cs

示例4: Fighter

 public Fighter(Vector2 position, World w)
     : base(position, w, TextureStatic.Get("fighter").Width, TextureStatic.Get("fighter").Height)
 {
     this.health = Settings.fighterHealth;
     world = w;
     lastShot = GameClock.Now;
     world = w;
     body.BodyType = BodyType.Dynamic;
     body.Position = position;
     texture = TextureStatic.Get("fighter");
     fixture = FixtureFactory.CreateRectangle(texture.Width, texture.Height, 0.25f, Vector2.Zero, body);
     world.AddBody(body);
     targetPoint = body.Position;
 }
開發者ID:scastle,項目名稱:Solitude,代碼行數:14,代碼來源:Fighter.cs

示例5: TyTaylor

        public TyTaylor(World w, Vector2 position)
            : base(position, w, TextureStatic.Get("ty").Width, TextureStatic.Get("ty").Height)
        {
            health = Settings.TyHealth;
            world = w;
            lastShot = GameClock.Now;
            body.BodyType = BodyType.Dynamic;
            body.Position = position;
            texture = TextureStatic.Get("ty");
            fixture = FixtureFactory.CreateRectangle(texture.Width, texture.Height, 0.25f, Vector2.Zero, body);
            world.AddBody(body);
            targetPoint = body.Position;

            fixture.OnCollision += new OnCollisionEventHandler(this.OnCollision);
        }
開發者ID:scastle,項目名稱:Solitude,代碼行數:15,代碼來源:TyTaylor.cs

示例6: Bullet

        public Bullet(Vector2 velocity, Vector2 position, World w, Color color, Fixture sender)
            : base(position, w, 15f, 15f)
        {
            senderFixture = sender;
            world = w;
            BulletColor = color;
            body.BodyType = BodyType.Dynamic;
            body.IsBullet = true;
            body.LinearVelocity = velocity;
            body.Position = position;
            texture = TextureStatic.Get("bullet");
            fixture = FixtureFactory.CreateCircle(7f, 1, body);
            body.Mass = 0;
            fixture.Body.UserData = "bullet";
            body.Inertia = 0;
            body.Torque = 0;
            fixture.CollisionFilter.IgnoreCollisionWith(senderFixture);

            fixture.BeforeCollision += new BeforeCollisionEventHandler(BeforeCollision);
            fixture.OnCollision += new OnCollisionEventHandler(OnCollision);

            w.AddBody(body);
        }
開發者ID:scastle,項目名稱:Solitude,代碼行數:23,代碼來源:Sentinel.cs

示例7: Sentinel

 public Sentinel(Vector2 position, Vector2 velocity, World w, int rate)
     : base(position, w, TextureStatic.Get("sentinel").Width, TextureStatic.Get("sentinel").Height)
 {
     health = Settings.sentinelHealth;
     patrolRate = rate;
     lastShot = GameClock.Now;
     lastTurn = lastShot;
     world = w;
     body.BodyType = BodyType.Dynamic;
     speed = velocity;
     body.LinearVelocity = velocity;
     //body.Position = position;
     texture = TextureStatic.Get("sentinel");
     fixture = FixtureFactory.CreateRectangle(texture.Width, texture.Height, 0.25f, Vector2.Zero, body);
     world.AddBody(body);
 }
開發者ID:scastle,項目名稱:Solitude,代碼行數:16,代碼來源:Sentinel.cs

示例8: Body

        public Body(World world, Object userData)
        {
            FixtureList = new List<Fixture>(32);

            World = world;
            UserData = userData;

            FixedRotation = false;
            IsBullet = false;
            SleepingAllowed = true;
            Awake = true;
            BodyType = BodyType.Static;
            Enabled = true;

            Xf.R.Set(0);

            world.AddBody(this);
        }
開發者ID:scastle,項目名稱:Solitude,代碼行數:18,代碼來源:Body.cs

示例9: Ship

        public Ship(SolitudeScreen s)
        {
            screen = s;
            toKill = new List<SolitudeObject>();

            roomStatus = new int[Settings.maxShipRows, Settings.maxShipColumns];

            random = new Random();
            //create the world, player, and boundaries
            PhysicalWorld = new World(Vector2.Zero);
            Player = new Player(new Vector2(900f, 830f), PhysicalWorld);

            border.Add(new Wall(new Vector2(192, 540), PhysicalWorld, 32, 1080, 1f, WallType.Smooth, Direction.Left));
            border.Add(new Wall(new Vector2(960, 108), PhysicalWorld, 1920, 64, 1f, WallType.Smooth, Direction.Left));
            border.Add(new Wall(new Vector2(1727, 540), PhysicalWorld, 32, 1080, 1f, WallType.Smooth, Direction.Left));
            border.Add(new Wall(new Vector2(960, 971), PhysicalWorld, 1920, 32, 1f, WallType.Smooth, Direction.Left));
            //term = new Terminal(new Vector2(500, 500), PhysicalWorld, "Derp Derp Derp Derp Derp Dfffffffferp Desdfrp Derp Derp Dffffferp Derp Derp Deffffffffffrp Derp Derp Deffrp Derp Derp Derp Derp");

            foreach (Wall j in border){
                PhysicalWorld.AddBody(j.body);
            }
            contents = new List<SolitudeObject>();
        }
開發者ID:scastle,項目名稱:Solitude,代碼行數:23,代碼來源:Ship.cs


注:本文中的Project290.Physics.Dynamics.World.AddBody方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。