本文整理汇总了C#中FarseerPhysics.Dynamics.Body.RegisterOnSeparatedListener方法的典型用法代码示例。如果您正苦于以下问题:C# Body.RegisterOnSeparatedListener方法的具体用法?C# Body.RegisterOnSeparatedListener怎么用?C# Body.RegisterOnSeparatedListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FarseerPhysics.Dynamics.Body
的用法示例。
在下文中一共展示了Body.RegisterOnSeparatedListener方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializePhysics
public override void InitializePhysics(bool force, IComponentContext engineRegistrations)
{
if (force || !initialized)
{
var cache = engineRegistrations.Resolve<IResourceCache<Texture2D>>();
var texture = cache.GetResource(TextureName);
var world = engineRegistrations.Resolve<PhysicsManager>().World;
game = engineRegistrations.ResolveOptional<EngineGame>();
if (game != null && game.GamepadEnabled)
{
ACTION_POPUP = InputManager.Instance.GamepadTextures[InputManager.ButtonActions.Pickup];
}
//Width = texture.Width;
//Height = texture.Height;
Physics = BodyFactory.CreateRectangle(
world,
PhysicsConstants.PixelsToMeters(Width),
PhysicsConstants.PixelsToMeters(Height),
1,
Position);
Physics.FixedRotation = true;
Physics.BodyType = BodyType.Static;
Physics.UserData = this;
var fix = Physics.FixtureList[0];
fix.CollisionCategories = Category.Cat3;
fix.CollidesWith = Category.Cat1;
HitSensor = BodyFactory.CreateRectangle(
world,
PhysicsConstants.PixelsToMeters(Width) * 2,
PhysicsConstants.PixelsToMeters(Height),
1,
Position);
HitSensor.IsSensor = true;
HitSensor.CollisionCategories = Category.Cat2;
HitSensor.CollidesWith = Category.Cat2;
HitSensor.RegisterOnCollidedListener<UserControlledCharacter>(OnCollidedWith);
HitSensor.RegisterOnSeparatedListener<UserControlledCharacter>(OnSeparation);
popup = new ItemPopup(ACTION_POPUP,
Physics.Position + new Vector2(0, -PhysicsConstants.PixelsToMeters(Height / 2 + POPUP_OFFSET)),
cache);
initialized = true;
}
base.InitializePhysics(false, engineRegistrations);
}