Docs for SKPhysicsBody
bodyWithCircleOfRadius:
says:
Creates a circular physics body centered on the owning node’s origin.
So is origin a node position? Couldnt find it anywere.
Docs for SKPhysicsBody
bodyWithCircleOfRadius:
says:
Creates a circular physics body centered on the owning node’s origin.
So is origin a node position? Couldnt find it anywere.
So is origin a node position?
The origin is the point with coordinates (0, 0) in a given coordinate system. However, you typically deal with a number of different coordinate systems when working with computer graphics, and each one has its own origin. For example, every view in a view hierarchy has its own coordinate system. So, you need some context to know exactly which one you're talking about.
From the SKNode docs:
Every node in a node tree provides a coordinate system to its children. After a child is added to the node tree, it is positioned inside its parent’s coordinate system by setting its position properties.
You also commented:
Im confused becouse 'origin' also is mention in SKScene docs, and its different than frames origin
SKScene
is a subclass of SKNode
, and so it's also the case that every scene provides a coordinate system. This isn't surprising -- a scene is just the root node in a tree of nodes.
Don't confuse the origin
of a node's frame
with the origin of the node's own coordinate system. A CGRect
is defined by two things: a CGPoint called origin
, and a CGSize called size
. A node's frame
is the rectangle that defines the node's bounds in the coordinate system of the parent node. The node's origin might happen to be at the same place as it's frame's origin
, but they're not the same thing. For example, the origin of a scene is at it's anchorPoint
-- that is, the anchorPoint
property of a scene indicates some point in the view that contains the scene, and that point has coordinates (0, 0) in the scene. Neither of these have anything to do with the frame
or frame.origin
.
Origin is normally a point. However, it is slightly confusing to speak of a SKNode's origin, because that is not a property of the SKNode in the same sense that it is a property of the SKNode's frame. If you do a keyword search in apples' sknode docs for the word 'origin' you will find it zero times. However, I agree with the consensus below that despite this lack of mention in the SKNode's docs, the origin of a node is more likely to refer to its position than to its frame's origin. So while you would get the SKNode's frame's origin's x and y values like this:
node.frame.origin.x
node.frame.origin.y
That does not necessarily describe the node's origin. I hope I have made this answer more accurate and less confusing :)