area
The area covered by the body.
Declaration
var area: CGFloat { get }Mentioned in
Discussion
This property is used in conjunction with the density property to calculate the body’s mass.
The value returned for the area is measured in meters: if you need to convert it into points — as used by SpriteKit — multiply the values by 150². The following listing shows how to calculate the area of a box which is ten points square.
let bodySize = CGSize(width: 10, height: 10)
let physicsBody = SKPhysicsBody(rectangleOf: bodySize)
let areaInPoints = physicsBody.area * pow(150, 2) // areaInPoints = 100