本文整理汇总了C#中Body.SetLinearVelocity方法的典型用法代码示例。如果您正苦于以下问题:C# Body.SetLinearVelocity方法的具体用法?C# Body.SetLinearVelocity怎么用?C# Body.SetLinearVelocity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Body
的用法示例。
在下文中一共展示了Body.SetLinearVelocity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Keyboard
public override void Keyboard(KeyboardState state, KeyboardState oldState)
{
if (state.IsKeyDown(Keys.OemComma) && oldState.IsKeyUp(Keys.OemComma))
{
if (_bullet != null)
{
_world.DestroyBody(_bullet);
_bullet = null;
}
{
CircleShape shape = new CircleShape();
shape._radius = 0.25f;
FixtureDef fd = new FixtureDef();
fd.shape = shape;
fd.density = 20.0f;
fd.restitution = 0.05f;
BodyDef bd = new BodyDef();
bd.type = BodyType.Dynamic;
bd.bullet = true;
bd.position = new Vector2(-31.0f, 5.0f);
_bullet = _world.CreateBody(bd);
_bullet.CreateFixture(fd);
_bullet.SetLinearVelocity(new Vector2(400.0f, 0.0f));
}
}
}
示例2: Step
public override void Step(Framework.Settings settings)
{
base.Step(settings);
_debugDraw.DrawString(50, _textLine, "Press: (,) to launch a bullet.");
if (_stepCount == 300)
{
if (_bullet != null)
{
_world.DestroyBody(_bullet);
_bullet = null;
}
{
CircleShape shape = new CircleShape();
shape._radius = 0.25f;
FixtureDef fd = new FixtureDef();
fd.shape = shape;
fd.density = 20.0f;
fd.restitution = 0.05f;
BodyDef bd = new BodyDef();
bd.type = BodyType.Dynamic;
bd.bullet = true;
bd.position = new Vector2(-31.0f, 5.0f);
_bullet = _world.CreateBody(bd);
_bullet.CreateFixture(fd);
_bullet.SetLinearVelocity(new Vector2(400.0f, 0.0f));
}
}
_textLine += 15;
}
示例3: LaunchBomb
public void LaunchBomb(Vector2 position, Vector2 velocity)
{
if (_bomb != null)
{
_world.DestroyBody(_bomb);
_bomb = null;
}
BodyDef bd = new BodyDef();
bd.type = BodyType.Dynamic;
bd.position = position;
bd.bullet = true;
_bomb = _world.CreateBody(bd);
_bomb.SetLinearVelocity(velocity);
CircleShape circle = new CircleShape();
circle._radius = 0.3f;
FixtureDef fd = new FixtureDef();
fd.shape = circle;
fd.density = 20.0f;
fd.restitution = 0.0f;
Vector2 minV = position - new Vector2(0.3f,0.3f);
Vector2 maxV = position + new Vector2(0.3f,0.3f);
AABB aabb;
aabb.lowerBound = minV;
aabb.upperBound = maxV;
_bomb.CreateFixture(fd);
}