F# and IEnumerable
-
I can't for the life of me work out how to implement this in f# protected override IEnumerable GetShapeDefinition() { // Yield out a Box2D shape definition PolygonDef def = new PolygonDef(); def.VertexCount = 3; def.Vertices[0] = new Vector2(0f, 6f); def.Vertices[1] = new Vector2(-2f, -3f); def.Vertices[2] = new Vector2(2f, -3f); def.Restitution = 0f; def.Friction = 1f; def.Density = 1f; yield return def; } The closest I've come is this override x.GetShapeDefinition = seq{ let def = new PolygonDef() def.VertexCount <- 3 def.Vertices.(0) <- new Vector2(1.0f, 2.0f) def.Vertices.(1) <- new Vector2(-2.0f,-3.0f) def.Vertices.(2) <- new Vector2(2.0f,-3.0f) def.Restitution <- 0.0f def.Friction <- 1.0f def.Density <- 1.0f yield (def :> ShapeDef) } But I get No abstract property was found that corresponds to this override. (FS0191) - C:\Users\Matthew\Documents\SharpDevelop Projects\FSharpGame\FSharpGame\Ship.fs:20,14
-
I can't for the life of me work out how to implement this in f# protected override IEnumerable GetShapeDefinition() { // Yield out a Box2D shape definition PolygonDef def = new PolygonDef(); def.VertexCount = 3; def.Vertices[0] = new Vector2(0f, 6f); def.Vertices[1] = new Vector2(-2f, -3f); def.Vertices[2] = new Vector2(2f, -3f); def.Restitution = 0f; def.Friction = 1f; def.Density = 1f; yield return def; } The closest I've come is this override x.GetShapeDefinition = seq{ let def = new PolygonDef() def.VertexCount <- 3 def.Vertices.(0) <- new Vector2(1.0f, 2.0f) def.Vertices.(1) <- new Vector2(-2.0f,-3.0f) def.Vertices.(2) <- new Vector2(2.0f,-3.0f) def.Restitution <- 0.0f def.Friction <- 1.0f def.Density <- 1.0f yield (def :> ShapeDef) } But I get No abstract property was found that corresponds to this override. (FS0191) - C:\Users\Matthew\Documents\SharpDevelop Projects\FSharpGame\FSharpGame\Ship.fs:20,14
Got it to work; override this.GetShapeDefinition() = seq{ let def = new PolygonDef() def.VertexCount <- 3 def.Vertices.[0] <- new Vector2(1.0f, 2.0f) def.Vertices.[1] <- new Vector2(-2.0f,-3.0f) def.Vertices.[2] <- new Vector2(2.0f,-3.0f) def.Restitution <- 0.0f def.Friction <- 1.0f def.Density <- 1.0f yield (def :> ShapeDef) }