Slide 1

Slide 1 text

Cross-Platform SpriteKit Alexsander Akers - @a2 Mobile Era - 04.11.2016

Slide 2

Slide 2 text

What is SpriteKit? SpriteKit provides a graphics rendering and animation infrastructure that you can use to animate arbitrary textured images, or sprites. — Apple documentation

Slide 3

Slide 3 text

What’s Supported? • Sprites, path-based shapes, text, and video • Actions and animations • Special effects • Physics, forces, and fields

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

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!

Slide 6

Slide 6 text

Node Subclasses • SKSpriteNode • SKVideoNode • SKLabelNode • SKShapeNode • SKEmitterNode • SKCropNode

Slide 7

Slide 7 text

Node Subclasses • SKEffectNode • SKLightNode • SKFieldNode • SKCameraNode • SKAudioNode • SKReferenceNode • SK3DNode

Slide 8

Slide 8 text

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:)

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

Onto the Screen • Nodes are contained in a scene (SKScene). • A scene is presented by a native element (SKView or WKInterfaceSKScene).

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

watchOS • Use WKGestureRecognizer: long press, pan, swipe, tap • Must include in Storyboard • state / locationInBounds() / objectBounds()

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

iOS & tvOS • SKNode inherits from UIResponder • Touches, presses, motion

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

macOS • SKNode inherits from NSResponder • Mouse, keyboard, tablet, gestures

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

Cross-Platform SpriteKit Alexsander Akers - @a2 Mobile Era - 04.11.2016