0

我尝试了 Farseer 文档中的“纹理到多边形”示例。 https://farseerphysics.codeplex.com/documentation 但我总是在以下行中收到此错误消息:

//Find the vertices that makes up the outline of the shape in the texture
Vertices  verts = PolygonTools.CreatePolygon(data, polygonTexture.Width, polygonTexture.Height, true);

No overload for method 'CreatePolygon' takes 4 arguments    

Farseer 文档中是否有错误或有什么问题?我应该在这条线上改变什么?

此外,我在以下几行中收到这两条错误消息:

_list = BayazitDecomposer.ConvexPartition(verts);
List<Fixture> compund = FixtureFactory.CreateCompoundPolygon(World, _list, 1);

The name 'BayazitDecomposer' does not exist in the current context  
'FarseerPhysics.Factories.FixtureFactory' does not contain a definition for 'CreateCompoundPolygon' 

怎么了?

我的代码中有以下三个用法:

using FarseerPhysics.Dynamics;
using FarseerPhysics.Factories;
using FarseerPhysics.Common;

我应该添加另一个使用吗?

4

2 回答 2

3

我认为你所有的问题都可以通过不包括正确的库来总结。我承认,您链接的 FarseerPhysics 文档不是很有帮助。例如,您可以在他们自己的源代码中看到BayazitDecomposerFarseerPhysics.Common.Decomposition命名空间的一部分,因此您可以通过以下方式引用它

using FarseerPhysics.Common.Decomposition;

在顶部,或者只是using FarseerPhysics.Common;在您的代码中:

Decomposition.BayazitDecomposer() //etc.

我建议查看其他开发人员的示例代码,或深入研究 FarseerPhysics 的源代码,以了解您还缺少哪些其他库。

我还注意到在您的CreatePolygon情况下,根据我正在查看的BodyFactoryVertices定义,该方法甚至不会返回您认为的类型。因此,在这种情况下,您不仅可能缺少所需的库,而且当您包含它时,它会说返回类型错误。

考虑到这些问题,可能建议您使用的示例代码基于旧版本的 Farseer 的评论者是正确的。

于 2013-05-20T17:09:58.543 回答
1

当您下载文件时Farseer Physics Engine 3.3.1 Samples XNA!Advanced Demo 1 有一个“Texture to polygon”的例子

该页面的文档已过时。

于 2013-07-16T14:27:20.740 回答