当我想在 Farseer 中创建多边形时,我总是收到很多错误消息。
“FarseerPhysics.Common.Vertices”不包含“CreatePolygon”的定义“FarseerPhysics.Factories.BodyFactory”不包含“Instance”的定义当前上下文中不存在名称“physicsSimulator”名称“triangleGeomtry”有当前上下文中不存在名称“GeomFactory”当前上下文中不存在名称“physicsSimulator”当前上下文中不存在
怎么了?如何在 Farseer 中创建多边形?
triangleSprite = Content.Load<Texture2D>("triangle"); // Load the Sprite
data = new uint[triangleSprite.Width * triangleSprite.Height];
triangleSprite.GetData(data);
verts = Vertices.CreatePolygon(data, triangleSprite.Width, triangleSprite.Height);
polygonOrigin = verts.GetCentroid();
triangleBody = BodyFactory.Instance.CreatePolygonBody(physicsSimulator, verts, 3);
triangleBody.Position = new Vector2(400, 600);
triangleGeomtry = GeomFactory.Instance.CreatePolygonGeom(physicsSimulator, triangleBody, verts, 0);