Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sprite Kit

Sprite Kit

Sing Jie Lee

October 07, 2016
Tweet

More Decks by Sing Jie Lee

Other Decks in Technology

Transcript

  1. Classes SKNode Parent class of all nodes SKScene Root of

    the scene graph SKSpriteNode Renders a textured sprite SKEmitterNode Generates and renders particles SKLabelNode Renders a text string SKVideoNode Plays video content SKShapeNode Renders a shape SKEffectNode Applies a Core Image filter to its children SKCropNode Crops its children using a mask
  2. SKScene SKScene SKScene Classes Structure Main Menu Game Game Over

    SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode SKNode ViewController
  3. Actions [node runAction:[SKAction rotateByAngle:M_PI duration:0.2]]; • Very easy to use

    • One line creation • Chainable • Removed on completion
  4. Basic Actions [node runAction:[SKAction moveTo:point duration:0.2]]; [node runAction:[SKAction fadeAlphaTo:0.8 duration:0.2]];

    [node runAction:[SKAction scaleBy:2.0 duration:0.2]]; [node runAction:[SKAction scaleXBy:1.0 duration:0.2]]; [node runAction:[SKAction rotateByAngle:M_PI duration:0.2]]; [node runAction:[SKAction moveBy:vector duration:0.2]];
  5. Compound Actions Repeat SKAction *group = [SKAction group:@[action1, action2, action3]];

    [node runAction:[SKAction repeatActionForever:group]]; action1 action2 action3 SKAction Group + Repeat
  6. Physics Engine • Uses Box2D under the hood • open

    source physics engine • Objective-C API • Fully integrated into Sprite Kit
  7. Physics Engine PhysicsBody CategoryBitMask CollisionBitMask ContactBitMask properties kBitMaskUser typedef NS_OPTIONS(NSUInteger,

    kBitMask) { kBitMaskFloor = (1 << 0), kBitMaskUser = (1 << 1), kBitMaskObstacle = (1 << 2), kBitMaskCoins = (1 << 3), }; CategoryBitMask kBitMaskUser CollisionBitMask ContactBitMask
  8. Physics Engine PhysicsBody CategoryBitMask CollisionBitMask ContactBitMask properties typedef NS_OPTIONS(NSUInteger, kBitMask)

    { kBitMaskFloor = (1 << 0), kBitMaskUser = (1 << 1), kBitMaskObstacle = (1 << 2), kBitMaskCoins = (1 << 3), }; kBitMaskFloor|kBitMaskObstacle CategoryBitMask kBitMaskUser CollisionBitMask kBitMaskFloor | kBitMaskObstacle ContactBitMask
  9. Physics Engine PhysicsBody CategoryBitMask CollisionBitMask ContactBitMask properties typedef NS_OPTIONS(NSUInteger, kBitMask)

    { kBitMaskFloor = (1 << 0), kBitMaskUser = (1 << 1), kBitMaskObstacle = (1 << 2), kBitMaskCoins = (1 << 3), }; kBitMaskCoins CategoryBitMask kBitMaskUser CollisionBitMask kBitMaskFloor | kBitMaskObstacle ContactBitMask kBitMaskCoins
  10. Except • No Multiplayer • No cute characters • No

    power-ups • No walls • No auto-run
  11. Q&A