Hi, I'm not sure I understand how this works. The api states that it converts local coordinate to world space.
Let' say I have three sprites. spriteA added to scene , and spriteB added to spriteA. And spriteC added to spriteB.
- Scene
- spriteA
- spriteB
- spriteC
And I want to convert spriteC origin to world
If I do: [self convertToWorldSpace:[spriteC CGPointZero]];
or this: [spriteA convertToWorldSpace:[spriteC CGPointZero]];
or this: [spriteB convertToWorldSpace:[spriteC CGPointZero]];
or even [spriteC convertToWorldSpace:[spriteC CGPointZero]];
Shouldn't they all give the same answer since they are all transformed to world coordinates? Or do I go from one node space to parent node space ...until I get to world space.
what is the correct answer to see spriteC position in world coordinates?
To find the world space origin on spriteC
, you take the sprites parent, in this case spriteB
and ask for the world space of its child:
[spriteB convertToWorldSpace:[spriteC CGPointZero]];
[spriteC convertToWorldSpace:CGPointZero];
As Kazuki answer but CGPointZero is a global.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With