4

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.

Maq
  • 369
  • 3
  • 13

2 Answers2

4

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.

Caleb
  • 124,013
  • 19
  • 183
  • 272
  • so accumulationg all together: node's origin is the point in its parent's coordinate system, and its (0,0) in node's own coordinate system. It happens that node's position is the same point, but its nowhere written in docs for SKNode, SKSpriteNode. – Maq Mar 17 '14 at 20:16
1

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 :)

zeeple
  • 5,509
  • 12
  • 43
  • 71
  • Im confused becouse 'origin' also is mention in SKScene docs, and its different than frames origin: https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Nodes/Nodes.html – Maq Mar 14 '14 at 22:24
  • It looks like for SKScene:SKnode, origin coresponds to anchor point which can be different then frames origin. – Maq Mar 14 '14 at 22:29
  • 2
    nope, origin is simply the node's position. Note that anchorpoint is merely a texture drawing offset, and only 3 nodes have an anchorPoint (scene, sprite, video) – CodeSmile Mar 14 '14 at 22:38