本文整理汇总了C#中FarseerPhysics.GetWorldManifold方法的典型用法代码示例。如果您正苦于以下问题:C# FarseerPhysics.GetWorldManifold方法的具体用法?C# FarseerPhysics.GetWorldManifold怎么用?C# FarseerPhysics.GetWorldManifold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FarseerPhysics
的用法示例。
在下文中一共展示了FarseerPhysics.GetWorldManifold方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCollide
public override void OnCollide(Entity entB, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
contact.Enabled = false;
// Don't collide if the entity is the owner.
// Don't collide if the entity is not freezable, but still allow collisions with the environment and other
// force fields if we are not frozen.
if (entB == owner || !(entB is Freezable || (!hasFrozen && (entB is Environment || entB is ForceField)))) {
return;
}
FarseerPhysics.Collision.WorldManifold manifold;
contact.GetWorldManifold(out manifold);
Vector2 posOfCollision = manifold.Points[0]*GameEnvironment.k_invPhysicsScale;
if (entB is Freezable) {
if (m_frozen.Contains((Freezable) entB)) {
return;
} else {
m_frozen.Add((Freezable) entB);
}
}
OnNextUpdate += () => {
if (!hasFrozen) {
hasFrozen = true;
CollisionBody.LinearVelocity = Vector2.Zero;
CollisionBody.IsStatic = true;
Position = posOfCollision;
}
if (entB is Freezable) {
Sound.PlayCue("freeze_zap", entB);
((Freezable) entB).Freeze(owner);
entB.Zindex = Zindex + RandomUtil.NextFloat(0.001f, 0.009f);
}
};
}
示例2: OnCollide
public override void OnCollide(Entity entB, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
if (entB is Bullet)
{
//Horrible Casting makes me sad.
ai.GotShotBy(this, (GameEntity)((Bullet)entB).owner);
}
else if (entB is Environment || entB.CollisionBody.IsStatic)
{
FarseerPhysics.Collision.WorldManifold manifold;
contact.GetWorldManifold(out manifold);
if (ai != null) ai.HitWall(manifold.Points[0] * GameEnvironment.k_invPhysicsScale);
}
if (this is Tractorable && m_lastCollideTime <= 0.0f)
{
if (((Tractorable)this).IsTractored && (ActualVelocity - entB.ActualVelocity).Length() > 700.0f){
this.TakeHit(dmgWhileTractored);
m_lastCollideTime = timeBetweenCollisions;
Sound.PlayCue("crash", this);
}
}
base.OnCollide(entB, contact);
}
示例3: onCollision
bool onCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
// since this event handler is called everytime player collides with object,
// we check if it's a wall or dynamic object (Category 2). Category 1 are waypoints
// so we want it to return false and allow it into the region.
if (fixtureA.CollisionCategories == Category.Cat2
|| fixtureA.CollisionCategories == Category.Cat3
|| fixtureB.CollisionCategories == Category.Cat2
|| fixtureB.CollisionCategories == Category.Cat3)
{
Vector2 norm;
FixedArray2<Vector2> pts;
contact.GetWorldManifold(out norm, out pts);
// if normal is facing up and vertical velocity is downward we can jump
if ((GameplayScreen.getWorld().Gravity.Y >= 0 && norm.Y < 0) ||
GameplayScreen.getWorld().Gravity.Y <=0 && norm.Y > 0) // && this._body.LinearVelocity.Y > 0)
{
isJumping = false;
this._body.AngularVelocity = 0f;
this._body.Rotation = 0f;
}
// determine a wall collision to drop horizontal velocity
// if I can't jump and the normal is not the same direction as the
// direction player is moving towards then player cant move (IE: wall collision)
// this.canMove = !(this.direction != norm.X); // (not working need better solution)
// allow jumping through a platform from the bottom
return true;
}
else return false;
}
示例4: OnCollisionEnter
public override bool OnCollisionEnter(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
if (!fixtureB.IsSensor)
{
Vector2 norm;
FixedArray2<Vector2> pts;
contact.GetWorldManifold(out norm, out pts);
//If player is falling and the collision is downwards
if (norm.Y < 0 && this.body.LinearVelocity.Y >= 0)
{
this.isOnGround = true;
}
return true;
}
return false;
}