O'Reilly logo

Build iOS Games with Sprite Kit by Josh Smith, Jonathan Penn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required