Search code examples
sprite-kitskspritenode

Should I manually position Node or make it a child of a parent


I have a person SKSpriteNode sprite. He is picking up an apple with his hands which is roughly half of his height(middle-right edge of sprite). Should I make this apple a child of the sprite or should I just calculate the position manually on each update?


Solution

  • If the apple sprite must move according to the hand sprite then make the apple child of the hand and let SpriteKit do the work for you.

    Also other geometrical transformations (like rotation and scaling) are automatically reflected from the parent to the child as well.

    As a rule of thumb try to write the less possible code into the update method.