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

Cross-Platform SpriteKit

Cross-Platform SpriteKit

Mobile Era 2016 in Oslo, Norway

Alexsander Akers

November 04, 2016

More Decks by Alexsander Akers

Other Decks in Technology


  1. What is SpriteKit? SpriteKit provides a graphics rendering and animation

    infrastructure that you can use to animate arbitrary textured images, or sprites. — Apple documentation
  2. What’s Supported? • Sprites, path-based shapes, text, and video •

    Actions and animations • Special effects • Physics, forces, and fields
  3. What’s in a Node? • Nodes can act like views,

    but sometimes have no content • Use parent / children instead of superview / subviews • Subclasses of SKNode provide more concrete functionality • Use position to change location • Nodes can be rotated and scaled • The frame property is read-only!
  4. Actions • Actions: Move, rotate, resize, scale, fade in/out, change

    texture, play sound, colorize, adjust field properties, follow path, modify node speed, reverse kinematic reach, perform selector/block • Control: Sequence, group, repeat, wait • Running: run(_:), run(_:completion:), run(_:withKey:)
  5. SKFieldNode • Domain: SKRegion (path, circle with radius, rect) •

    Types: Drag, vortex, gravity, velocity, noise, turbulence, spring, electric, magnetic, custom • Custom Forces: (pos, vel, mass, charge, dt) -> force • Position, velocity, and force use vector_float3 • Strength: Float
  6. Onto the Screen • Nodes are contained in a scene

    (SKScene). • A scene is presented by a native element (SKView or WKInterfaceSKScene).
  7. Interacting • If there is anything we've learned from cross-platform

    development is that there is no one-size-fits-all solution! • Different input sources • Screen sizes • Touch accuracy • Proximity to device • Direct interaction with device
  8. watchOS • Use WKGestureRecognizer: long press, pan, swipe, tap •

    Must include in Storyboard • state / locationInBounds() / objectBounds()
  9. SpriteKit: What is it good for? • Games • Small

    UI elements, especially with animations, on watchOS • Flappy Swift • Keep accessibility in mind • Limited on watchOS to the scene interface object • Better on macOS, tvOS, and iOS