6

I have an SKSpriteNode that is parented to (i.e. a child of) a scrolling background. The SKSpriteNode does not move itself, it just moves along with the scrolling background. What is the best way to find the absolute position of the SKSpriteNode as the background moves.

4

1 回答 1

13
CGPoint positionInScene = [self.scene convertPoint:self.position 
                                                  fromNode:self.parent];

但是,convertPoint:fromNode:它非常昂贵,特别是如果您在update方法中使用它。我宁愿将childNode'x位置添加到parentNode'x位置:

CGFloat xPosition = self.position.x + self.parent.position.x;
于 2014-02-18T12:07:07.403 回答