O'Reilly logo

iOS® 8 for Programmers: An App-Driven Approach with Swift™, Third Edition by Abbey Deitel, Harvey M. Deitel, Paul J. Deitel

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

6.6.2 Blocker Initializers

Figure 6.8 presents class Blocker’s initializers. The initializer at lines 20–39 receives two parameters—the scene’s size (a GCSize) and the BlockerSize. Line 21 initializes the blockerSize property. Lines 22–27 invoke superclass SKSpriteNode’s initializer that receives:

• an SKTexture representing the nodes sprite image (in this case, the "blocker"),

• an SKColor that can be used to tint the sprite (in this case nil to indicate that the sprite will not be tinted), and

• a CGSize specifying the node’s width and height.

  19       // initializes the Cannon, sizing it based on the scene's size  20       init(sceneSize: CGSize, blockerSize: BlockerSize) {  21           self.blockerSize = ...

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