本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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>();
}