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

Moving the Plunger with a Touch

Now that we have two dedicated node instances—one for the ball and one for the plunger—we can start imagining how we want to control them with the player’s finger. We’ll use the same kind of mechanism we did back in Following the Finger Around, for Space Run. We need to add a dedicated property to remember the touch object when the finger is down at the top of the RCWMyScene.m file.

06-Physics/step10/PhysicsBall/RCWMyScene.m
 
@interface​ RCWMyScene ()
 
@property​ (nonatomic, weak) UITouch *plungerTouch;
 
@end

We’re declaring the property as weak because we don’t want to hold a strong reference to the touch. Since the touch-management system takes care of the touch objects, it will release them when the ...

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