Moving Nodes on a Path
Unlike the asteroids, the enemy ships should appear to be flying around. What we want is a way to specify a path the enemy ship nodes follow as they zigzag and loop around on their way past the player’s ship. Thankfully, Sprite Kit makes that easy to do.
First, we need to add the enemy.png image to our Xcode project so we can use it in our sprite node. Drag it into the sidebar and set the options like we did before in Figure 7, Dragging and dropping files into the Xcode project.
Next, we need to decide when to send the enemy ships toward the player. We’ve already established a nice random timing mechanism when dropping asteroids on the scene. Let’s expand it by changing the section of our ‑update: method to call ...
Get Build iOS Games with Sprite Kit now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.