Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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);
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.