2014-06-19 9 views
0

본문에 조명기를 연결하려고하면이 줄에 항상이 오류 메시지가 나타납니다.'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); 
} 
+0

'FixtureFactory.AttachCompoundPolygon'는 단일 목록을하지 반환, (당신이 가정하고 있기 때문에, 경우 수 있습니다 하나가있을 것입니다) 목. – Habib

답변

0
Fixture Newfixture = FixtureFactory.AttachCompoundPolygon(list, 1.0f, TestBody); 

이 코드 라인은 여기 List<Fixture> 반환은 FixtureFactory 소스 코드에서 메소드 서명입니다.

public static List<Fixture> AttachCompoundPolygon(List<Vertices> list, float density, Body body) 

그러면 List<Fixture>이 다시 나타납니다. 당신이 그 목록의 첫 번째 항목 얻고 싶다면 다음

Fixture Newfixture = FixtureFactory.AttachCompoundPolygon(list, 1.0f, TestBody).First(); 
+0

3 개의 조명기를 TestBody에 연결하고 싶습니다. 어떻게해야합니까? – Leo

+0

무슨 뜻인지 잘 모르겠습니다. AttachCompoundPolygon을 정점 목록과 함께 호출하면 TestBody에 여러 개의 조명기가 연결됩니다. –