Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Game with Sprite Kit Physics and Collision World Setup and Physics Bodies

Shaun Kelly
Shaun Kelly
5,648 Points

He hasn't explained about the position in the ground node class???

He hasn't explained about the divide by 2 in the CGPointMake why do we have to but the /2 in and what does it mean ???

ground.position = CGPointMake(size.width/2,size.height/2);
J R
J R
2,037 Points

For what I understand this is because the anchorPoint of the ground has the default value of (0.5, 0.5) so without changing the position as he did, the default position of the ground would be (0,0) in your XY and because the anchorPoint being in the middle, the ground won't appear fully in your screen. Try commenting that line and you will see where the ground appears. Also, if you comment that line above and add this below, it will have the same results as dividing by 2.

ground.anchorPoint = CGPointMake(0,0)
ground.position = CGPointMake (0,0);

What I don't understand is, what is the benefit of doing it the way he did or adding two lines of code more, can someone explain a bit more, Thanks.