-1

I am currently working at a 2D endless runner in SpriteKit. I create new Level sequences using the Scene Editor and then add them as a SKReferenceNode to the main scene.

The problem is, that I need to get the position of the single nodes inside of the SKReferenceNode, but the ones I get, are relative to the SKReferenceNodes coordinate system and not the main one.

How can I get the position of the nodes relative to the main scene?

1 Answers1

1

you'll want to use the convert func

func convert(_ point: CGPoint, to node: SKNode) -> CGPoint

Description
Converts a point in this node’s coordinate system to the coordinate system of another node in the node tree.

Parameters
point - A point in this node’s coordinate system.

node - Another node in the same node tree as this node.

Returns
The same point converted to the other node’s coordinate system.

Ron Myschuk
  • 6,011
  • 2
  • 20
  • 32
  • this is the correct answer. are you going to mark it as correct? at least so others can benefit from this question – Ron Myschuk Feb 01 '18 at 17:15
  • It actually was not the answer for my problem, but I found another way to work around mine. I marked it as correct anyways, because it would definitely work in other cases. – Christian Schmidt Feb 01 '18 at 20:34
  • As i pointed out in another question of yours, you really need to work with and respond to people who are freely donating their time to help you in a timely manner. And if you make erroneous claims like the claim above of about the func returning a CGFloat correct yourself so that others that are wanting to be an active part of this community can benefit! – Ron Myschuk Feb 01 '18 at 21:06
  • Yeah I am sorry, the comment above was a mixup, I wanted to say it returns a CGPoint but I NEED CGFloat, my mistake. And about the responding... I am really sorry, but I don't do this full time. I am happy, if I can find 2 hours a day to do anything at all and of course I want to work at my app as much as possible. I try to look on this site as often as possible, but sometimes I forget or don't have the time in the first place. – Christian Schmidt Feb 02 '18 at 16:43