當我嘗試將燈具附加到主體時,我總是在此行中收到此錯誤消息。無法將類型'System.Collections.Generic.List'隱式轉換爲'FarseerPhysics.Dynamics.Fixture'
Fixture Newfixture = FixtureFactory.AttachCompoundPolygon(list, 1.0f, TestBody);
無法隱式轉換類型「System.Collections.Generic.List」到「FarseerPhysics.Dynamics.Fixture」
如何創建一個夾具和其附加到身體?是否有可能將多個固定裝置連接到身體上?
我的代碼的其餘部分:
List<Vertices> list = new List<Vertices>();
Vector2 _origin;
float _scale;
uint[] data = new uint[Sprite.Width * Sprite.Height];
Sprite.GetData(data);
Vertices textureVertices = PolygonTools.CreatePolygon(data, Sprite.Width, false);
Vector2 centroid = -textureVertices.GetCentroid();
textureVertices.Translate(ref centroid);
_origin = -centroid;
textureVertices = SimplifyTools.ReduceByDistance(textureVertices, 4f);
list = Triangulate.ConvexPartition(textureVertices, TriangulationAlgorithm.Bayazit);
_scale = 1f;
Vector2 vertScale = new Vector2(ConvertUnits.ToSimUnits(1)) * _scale;
foreach (Vertices vertices in list)
{
vertices.Scale(ref vertScale);
}
'FixtureFactory.AttachCompoundPolygon'返回一個列表不是一個單一的項目。 – Habib