0

我正在像这样创建我的迷宫:

agentBody = BodyFactory.CreateBody(world, position);
_agentBody.BodyType = BodyType.Dynamic;
_agentBody.IgnoreGravity = true;
_agentBody.Restitution = 0.1f;
_agentBody.Friction = 1f;

_offset = ConvertUnits.ToDisplayUnits(1.5f);

FixtureFactory.AttachRectangle(3f, 0.1f, 1f, new Vector2(0, 1.55f), _agentBody);
FixtureFactory.AttachRectangle(3f, 0.1f, 1f, new Vector2(0f, -1.55f), _agentBody);
FixtureFactory.AttachRectangle(width, 3f, 1f, new Vector2(-1.55f, 0f), _agentBody);
FixtureFactory.AttachRectangle(width, 3f, 1f, new Vector2(1.55f, 0f), _agentBody);

我的沙粒是这样的:

for (int i = 0; i < 8; i++){
    _sands[i] = BodyFactory.CreateRectangle(_world, 0.05f, 0.05f, 1f);
    _sands[i].IsStatic = false;
    _sands[i].Restitution = 0.1f;
    _sands[i].Friction = 0.1f;
    _sands[i].Position = new Vector2(1.8f + i * 0.2f, 2.2f);
}

_sand = new Sprite(
    ScreenManager.Assets.TextureFromShape(
        _sands[0].FixtureList[0].Shape,
        MaterialType.Dots,
        Color.SandyBrown, 0.8f
    ));

我在调试视图中检查了夹具,它看起来不错。但事实并非如此。当粒子出现在屏幕上时,它们会掉下来(由于重力)并毫无问题地穿过我的迷宫边界,它们会停在有静止物体的底部。这是为什么?为什么粒子不会在我的迷宫中停下来?

有关上下文,请参阅我之前的问题:
Farseer - Particles doesn't move/bounceaccord to borders

4

1 回答 1

0

我对 farseer 不是很流利,但我能从不久前的一个项目中记得我们使用了夹具的“CollidesWith”属性

就像是 :

fixture.CollisionFilter.CollidesWith = CollisionCategories.All;

否则codeplex项目的讨论板可以提供很多信息。

于 2012-10-17T11:14:35.510 回答