Wrap up
Wrap up 관련
That's it! We just made a game in 20 minutes or so, which shows you just how fast SpriteKit is. I even showed you how per-pixel collision detection works (it's so easy!), how to advance particle systems so they start life with some history behind them, how to run code repeatedly using Timer
, and how to adjust linear and angular damping so that objects don't slow down over time.
Review what you learned
Anyone can sit through a tutorial, but it takes actual work to remember what was taught. It’s my job to make sure you take as much from these tutorials as possible, so I’ve prepared a short review to help you check your learning.
Challenge
One of the best ways to learn is to write your own code as often as possible, so here are three ways you should try your new knowledge to make sure you fully understand what’s going on:
- Stop the player from cheating by lifting their finger and tapping elsewhere – try implementing
touchesEnded()
to make it work. - Make the timer start at one second, but then after 20 enemies have been made subtract 0.1 seconds from it so it’s triggered every 0.9 seconds. After making 20 more, subtract another 0.1, and so on. Note: you should call
invalidate()
ongameTimer
before giving it a new value, otherwise you end up with multiple timers. - Stop creating space debris after the player has died.