Reputation: 13
I have been trying to figure out how to get the area of an SKShapeNode that has no pattern to it.
Here are the things that I have tried:
Make a physics body and use the .area property, but this is an arbitrary value that doesn't have anything to do with the actual area of the shape.
Use height times width, but being an irregular shape there is no pattern to it and this only works with rectangles.
Is there any way that I can get the area of an SKShapeNode?
Upvotes: 1
Views: 667
Reputation: 1931
By utilizing lineLength
(see Apple Docs), you can find the perimeter of the shape, or the length of each segment which creates the entire node.
From there, you could get the area for each square/rect created by the lines.
Upvotes: 1