Okay, well in summary, you saw how real development goes.
What we did was we created a game template,
we worked with the game scene controller, and we built some basic controls out,
we had some trouble by option controlling the left paddle, just renaming it right
paddle, we needed to actually create it fresh in order for it to be found.
And then within our game scene code, we did a couple things.
In the beginning, we set the background color to a color.
We scaled the world.
We created a physics body that wasn't present in our scene,
what you see is what you get scene editor.
We gave our ball some initial angular velocity, and then we handled touches.
We handled touches by picking out a touch that would be the thing that moves
the left paddle.
Be picking out a touch that would be the thing that moves the right paddle.
And if we didn't find one of those, we change the velocity of the ball.
And then we said hey,
go update our paddles according to the touches that we just found.
If the touchesMoved, then we don't look for a new touch,
we just take the existing touches that have moved, and
whose touches have changed position, and updated the animations.
If the touchesEnded, meaning the touches are no longer active,
then we went through.
And if we found out that one of our touches had ended,
we would set our left-motivating touch to nil and
our right-motivating touch to nil if that one was found.
Finally, we did the same thing if one of our touches was cancelled.
We're not doing anything on a frame-by-frame basis for this example.
And then our code where we track our paddles to meet to our
motivating touches involves creating a dictionary that we can treat abstractly.
We create a node and a touch, and down here in our dictionary, we pull out our
node and our touch without knowing whether that is a paddle, or a spaceship, or
a ball, or without knowing if it's a motivating touch or whatever it is.
But if it's not null, then we adjust the y position of our object according to
the touch's position in our window.
We decide how long we want that to take to move the paddle.
And then we go ahead and create an action which tells Sprite Kit to move it for us,
and then we say, move it.
And Sprite Kite takes care of managing the movement.
And so that ends up here.
Let's slow down our tracking a little bit.
Let's make the paddles move half as fast.
And we'll close with this, so in summary, Pong is the hello world of games.
Doesn't always work smoothly, but
you can see a little bit how I debugged the situation.
Now if I click, it takes a little more time for
the paddle to get to where it needs to go.
Great, thanks for your attention.
Let's dig in deeper and do a different case study with another game that might be
kind of fun to see some physics work with.
All right, thank you for your attention.
[MUSIC]