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 Actions and Animations Shooting Projectiles using SKAction: Part 2

Shaun Kelly
Shaun Kelly
5,648 Points

Questions about self.position and calculating Y coordinates

Question One. Is there an easier way to understand and break down how to calculate the Y coordinates mentioned at 4:02 ?


float offscreenY = slope * offscreenX - slope * self.position.x + self.position.y;

Question Two. Is the self.position.x and self.position.y the position where the user touches the screen ? aka the red point.?

1 Answer

Russell Warwick
Russell Warwick
1,601 Points

It does seem abit complex I admit but try and draw it out on paper to get a better understanding for it. Its basically finding the gradient of the point where it start and the place where you touched the screen.