Implementing Weapon Power-Ups with Actions

To finish out this chapter, we’ll give the player a power-up advantage to help him clear a path through the obstacles. If the player collects the power-up, the ship shoots faster for a short time. Collect more power-ups, and the timer keeps resetting to give more time. Sprite Kit’s code-block actions make this sequence of steps easy to do.

First, we need our power-up sprite texture, so drag powerup.png into the Xcode sidebar and make sure it is added to the target, as you did in Figure 7, Dragging and dropping files into the Xcode project.

Next, we need to create a property that we will use to keep track of the current firing rate.

02-Actions/step07/SpaceRun/RCWMyScene.m
 
@interface​ RCWMyScene ...

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.