what’s new in spritekit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix...

148
© 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. #WWDC14 What’s New in SpriteKit Session 606 Norman Wang Game Technologies Graphics and Games

Upload: others

Post on 21-Jan-2021

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

© 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

#WWDC14

What’s New in SpriteKit

Session 606 Norman Wang Game Technologies

Graphics and Games

Page 2: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SpriteKit

Page 3: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shaders

Lighting and Shadows

New Physics

Tools

Improvements

Integration with SceneKit

Page 4: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shaders

Lighting and Shadows

New Physics

Tools

Improvements

Integration with SceneKit

Page 5: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ShadersIntroduction

Page 6: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ShadersIntroduction

Page 7: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ShadersOverview

Shaders customize the way things are drawn in a game

Programmed using a C-like language

Powerful tools that can produce a wide variety of effects

Useful to add new effects to existing games

Page 8: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ShadersSKShaders object

Holds a custom OpenGL ES fragment shader

Deploy to both OS X and iOS

Supported node types - SKSpriteNode

- SKShapeNode

- SKEmitterNode

- SKEffectNode

- SKScene

Built-in uniforms - u_texture, v_tex_coord, u_sprite_size …

Page 9: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shader

SKShader

Shader

Page 10: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Source Uniforms

Shader

SKShader

Shader

Page 11: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shader

SKShader

Page 12: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Sprite 1 Sprite 2 Sprite 3Sprite 1 Sprite 2 Sprite 3

Shader Scene

SKShader

Scene

Page 13: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Sprite 1 Sprite 2 Sprite 3

ShaderScene

SKShader

Page 14: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKShaderCreation

Source code for a fragment shader !

shader = [SKShader shaderWithFileNamed:@“blur.fsh"]; !

!

!

Setting uniforms !

shader.uniforms = @[[SKUniform uniformWithName:@"u_red" float:1], [SKUniform uniformWithName:@"u_myTex" texture:nil]];

vec3 noiseinput = vpos * stretch;

float f = noise3 (noiseinput).x;

f = abs (f) + 0.8;

color = mix (color_a, color_b, f);

gl_FragColor = vec4 (color, 1);

Page 15: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKShaderPredefined shader symbols

Uniform

FunctionVaryingUniform

u_texture u_sprite_size u_time u_path_length

v_tex_coord v_color_mix v_path_distance

SKDefaultShadingsampler2D vec2 float float

vec2 vec4 float

vec4

Page 16: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ShadersBest practices

Make use of built-in uniforms - Avoid changing the shader’s source

- Avoid adding/removing uniforms

Share shader objects whenever possible - Initialize shader objects at load time

- Initialize shader using file than string

!

Page 17: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ShadersSummary

Shaders allows custom rendering

Provides access to sprites properties

Add cool and unique effects

Page 18: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shaders

Lighting and Shadows

New Physics

Tools

Improvements

Integration with SceneKit

Page 19: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shaders

Lighting and Shadows

New Physics

Tools

Improvements

Integration with SceneKit

Page 20: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsIntroduction

Page 21: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsIntroduction

Page 22: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsSKLightNode

Position lights in your scene

Light existing sprites

Supports color, shadows, and falloff

Up to eight different lights per sprite

Page 23: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsSKLightNode

Position lights in your scene

Light existing sprites

Supports color, shadows, and falloff

Up to eight different lights per sprite

Just another SKNode

Page 24: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsSKLightNode

Page 25: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsSKLightNode

lightColor

Page 26: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsSKLightNode

lightColor

Page 27: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsSKLightNode

lightColor

shadowColor

Page 28: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsSKLightNode

lightColor

shadowColor

Page 29: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsSKLightNode

lightColor

shadowColor

ambientColor

Page 30: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsSKLightNode

lightColor

shadowColor

ambientColor

Page 31: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsSKLightNode

falloff - Does not effect ambient

!

categoryBitMask - SKSpriteNode.lightingBitMask - SKSpriteNode.shadowCastBitMask - SKSpriteNode.shadowedBitMask

Page 32: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsSKSpriteNode

normalTexture

!

!

!

!

!

!

Page 33: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsNormal map

+ =

!

!

!

!

!

!

!

!

sprite.normalTexture = [SKTexture textureWithImageNamed:@“normal”];

Page 34: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsAutomatic normal map

!

!

!

!

!

!

!

!

sprite.normalTexture = [myTex textureByGeneratingNormalMap];

=

Page 35: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsAutomatic normal map

Tuning automatic normal map - Smoothness

- Contrast

-(instancetype)textureByGeneratingNormalMapWithSmoothness:(CGFloat)smoothness contrast:(CGFloat)contrast

Page 36: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsAutomatic normal map

Tuning automatic normal map - Smoothness

- Contrast

-(instancetype)textureByGeneratingNormalMapWithSmoothness:(CGFloat)smoothness contrast:(CGFloat)contrast

Page 37: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Lighting and ShadowsSummary

Lights are very easy to use

Automatic normal map provides dynamic look

!

Performance best practice - Number of lights on the same sprite

Page 38: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shaders

Lighting and Shadows

New Physics

Tools

Improvements

Integration with SceneKit

Page 39: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shaders

Lighting and Shadows

New Physics

Tools

Improvements

Integration with SceneKit

Page 40: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

New Physics

Per-pixel physics

Constraints

Inverse kinematics

Physics fields

Page 41: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Per-Pixel Physics

Page 42: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Per-Pixel PhysicsIntroduction

>

Page 43: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKPhysicsBodyInitialization

hammer.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:hammer.size];

Page 44: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKPhysicsBodyPer-pixel physics initialization

hammer.physicsBody = [SKPhysicsBody bodyWithTexture:hammer.texture size:hammer.size];

Page 45: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKPhysicsBodyInitialization

+ (SKPhysicsBody *)bodyWithTexture:(SKTexture *)texture alphaThreshold:(float)alphaThreshold size:(CGSize)size

!

alphaThreshold the alpha value above which a pixel is interpreted as opaque

Page 46: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Per-Pixel PhysicsSummary

Easy creation

Accurate representation

!

Performance - Provides a good balance between performance and accuracy

- Texture size matters

- Limit the number of per-pixel physics bodies

Page 47: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Constraints

Page 48: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ConstraintsIntroduction

Remove boilerplate logic in game code

Applied after physics update

Interactions of constraints - Cannon

- Runway

- Health indication

Page 49: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ConstraintsIntroduction

Remove boilerplate logic in game code

Applied after physics update

Interactions of constraints - Cannon

- Runway

- Health indication

Page 50: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ConstraintsIn the loop

Each frame-update:

SKviewrenders the scene

-didSimulatePhysics

SKScenesimulates physics

-didEvaluateActions

SKSceneevaluates actions

Page 51: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ConstraintsIn the loop

Each frame-update:

SKviewrenders the scene

SKSceneapplies constraints

-didSimulatePhysics

SKScenesimulates physics

-didEvaluateActions

SKSceneevaluates actions

Page 52: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ConstraintsIn the loop

Each frame-update:

SKviewrenders the scene

-didApplyConstraints

SKSceneapplies constraints

-didSimulatePhysics

SKScenesimulates physics

-didEvaluateActions

SKSceneevaluates actions

Page 53: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ConstraintsBasics

New object—SKConstraint

Defines a mathematical constraint on one property of a node

Constraints are attached to nodes

Scene applies constraints attached to nodes

Page 54: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ConstraintsProperties

Position

Orientation

Distance

Enable/Disable

Page 55: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ExampleOrient to node

SKRange* range = [SKRange rangeWithConstantValue:0.0f]; !SKConstraint* orientConstraint = [SKConstraint orientToNode:targetNode offset:range]; ]; node.constraints = @[orientConstraint];

Page 56: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ExampleOrient to node

SKRange* range = [SKRange rangeWithConstantValue:0.0f]; !SKConstraint* orientConstraint = [SKConstraint orientToNode:targetNode offset:range]; ]; node.constraints = @[orientConstraint];

Page 57: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ExamplePosition constraint

SKRange* range = [SKRange rangeWithLowerLimit:-100.0f upperLimit:100.0f]];

Page 58: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ExamplePosition constraint

SKRange* range = [SKRange rangeWithLowerLimit:-100.0f upperLimit:100.0f]];

SKConstraint* constraint1 = [SKConstraint positionX:range]; //X constraint

Page 59: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ExamplePosition constraint

SKRange* range = [SKRange rangeWithLowerLimit:-100.0f upperLimit:100.0f]];

SKConstraint* constraint2 = [SKConstraint positionY:range]; //Y constraint

Page 60: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Example

SKRange* range = [SKRange rangeWithLowerLimit:-100.0f upperLimit:100.0f]]; !

SKConstraint* constraintX = [SKConstraint positionX:range]; //X constraint SKConstraint* constraintY = [SKConstraint positionY:range]; //Y constraint !

node.constraints = @[constraintX,constraintY];

Position constraint

Page 61: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Example

SKRange* range = [SKRange rangeWithLowerLimit:-100.0f upperLimit:100.0f]]; !

SKConstraint* constraintX = [SKConstraint positionX:range]; //X constraint SKConstraint* constraintY = [SKConstraint positionY:range]; //Y constraint !

node.constraints = @[constraintX,constraintY];

Position constraint

Page 62: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

ConstraintsSummary

Removes boilerplate code in scene update

Evaluated in order list in the array

Offers a variety of constraints

Page 63: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse Kinematics

Page 64: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse KinematicsIntroduction

Page 65: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse KinematicsIntroduction

Page 66: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse KinematicsJoint hierarchy definition

Use sprites to represent joints - Anchor points

- DOF constraints

- Reach to point

Page 67: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse KinematicsJoint hierarchy definition

Use sprites to represent joints - Anchor points

- DOF constraints

- Reach to point

Page 68: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse KinematicsJoint hierarchy definition

Use sprites to represent joints - Anchor points

- DOF constraints

- Reach to point

Page 69: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse KinematicsJoint hierarchy definition

Use sprites to represent joints - Anchor points

- DOF constraints

- Reach to point

Page 70: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse Kinematics in SpriteKit

Joints defined by scene graph

Existing parent-child relationship

Defines IK constraints on each joint

Controls the minimum and maximum rotation

Joint rotates around its anchor point

Page 71: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKReachConstraints

@property (nonatomic, assign) CGFloat lowerAngleLimit; @property (nonatomic, assign) CGFloat upperAngleLimit;

!

To set the constraint on a node, use @property (nonatomic, copy) SKReachConstraints *reachConstraints;

Page 72: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse KinematicsDriving the joints

+ (SKAction *)reachTo:(CGPoint)position rootNode:(SKNode *)root duration:(NSTimeInterval)sec; !

+ (SKAction *)reachToNode:(SKNode *)node rootNode:(SKNode *)root duration:(NSTimeInterval)sec;

Page 73: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse KinematicsExample

[_endEffector runAction:[SKAction reachTo:p rootNode:_root duration:0.2]];

Page 74: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse KinematicsExample

[_endEffector runAction:[SKAction reachTo:p rootNode:_root duration:0.2]];

Page 75: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse Kinematics3D

Shared IK solver is also available in SceneKit SCNIKConstraint SCNNode.constraints SCNNode.influenceFactor

Page 76: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse Kinematics3D

Shared IK solver is also available in SceneKit SCNIKConstraint SCNNode.constraints SCNNode.influenceFactor

Page 77: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse Kinematics3D

Shared IK solver is also available in SceneKit SCNIKConstraint SCNNode.constraints SCNNode.influenceFactor

Page 78: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse Kinematics3D

Shared IK solver is also available in SceneKit SCNIKConstraint SCNNode.constraints SCNNode.influenceFactor

Page 79: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Inverse KinematicsSummary

Uses existing scene graph to represent hierarchy

Constraints can be set on each joint

Easy to use action to reach for position or node

Page 80: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics Fields

Page 81: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsIntroduction

Page 82: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsIntroduction

Page 83: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsOverview

Fields simulate physical forces

Fields affect physics bodies in a region

Variety of field types - Drag field, vortex field, radial gravity field, linear gravity field, velocity field, noise field,

turbulence field, spring field, electric field, magnetic field

Page 84: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsField updates

The field node is in the scene’s node tree

Physics bodies exist in the scene’s node tree

Physics bodies are located inside the field node’s region

Field’s categoryBitMask property and the physics body’s fieldBitMask

Page 85: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsField node

SKFieldNode - region - strength - minRadius - falloff - categoryBitMask

SKPhysicsBody - fieldBitMask

Page 86: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsField node

SKFieldNode - region - strength - minRadius - falloff - categoryBitMask

SKPhysicsBody - fieldBitMask

Page 87: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsRegion

New object—SKRegion

Regions define a 2D space

Can be infinite, rectangle, circle, CGPath

Can invert, subtract, union, intersect regions

Page 88: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsParticle interactions

Particle interactions - fieldBitMask property

Page 89: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsParticle interactions

Particle interactions - fieldBitMask property

Page 90: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsLinear gravity field

Applies force in a given direction

Page 91: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsLinear gravity field

Applies force in a given direction

Page 92: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsRadial gravity field

Applies force toward field origin

Page 93: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsRadial gravity field

Applies force toward field origin

Page 94: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsSpring field

Applies force toward field origin with spring oscillation

Page 95: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsSpring field

Applies force toward field origin with spring oscillation

Page 96: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsNoise field

Applies a noisy, random force

Page 97: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsNoise field

Applies a noisy, random force

Page 98: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsElectric field

Applies a force proportional an object’s charge

Page 99: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsElectric field

Applies a force proportional an object’s charge

Page 100: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics fields are provided as building blocks

Objects can interact with multiple fields

!

Lorenz system

Physics FieldsInteractions

Page 101: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics fields are provided as building blocks

Objects can interact with multiple fields

!

Lorenz system

Physics FieldsInteractions

Page 102: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics FieldsSummary

Fields are fast and efficient

Interact with physics bodies and particles

Interact with other physics fields

Page 103: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shaders

Lighting and Shadows

New Physics

Tools

Improvements

Integration with SceneKit

Page 104: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shaders

Lighting and Shadows

New Physics

Tools

Improvements

Integration with SceneKit

Page 105: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SpriteKit and SceneKitIntroduction

Page 106: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SpriteKit and SceneKitIntroduction

Page 107: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SceneKit Integration

Include 3D content in SpriteKit games

Control 3D objects like regular SKNodes

Renders as part of SpriteKit scene graph

!

Loosely coupled, deeply integrated

Page 108: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SK3DNodeOverview

Incorporate 3D content into a SpriteKit-based game

Attaches an SCNScene to a SKNode - Renders 3D content directly inside SpriteKit GL context

Add existing .dae or .abc file to SKScene

Use the scnScene to specify the 3D scene to be rendered

Page 109: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SK3DNodeCreation

scnNodeWithViewportSize - Creates and initializes a new 3D node

!

!

@property SCNScene *scnScene @property CGSize viewportSize @property(nonatomic, retain) SCNNode *pointOfView @property(nonatomic) BOOL autoenablesDefaultLighting

Page 110: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SK3DNodeExample

SK3DNode *alien3D = [[SK3DNode alloc] initWithViewportSize:CGSizeMake(200, 200)]; SCNScene *alienSCN = [SCNScene sceneNamed:@"alien.dae"]; alien3D.scnScene = alienSCN; [self addChild:alien3D];

Page 111: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SceneKit IntegrationTextures and sounds

Use SKTexture with SceneKit objects - SKTextureAtlas and generation tool

- Automatic normal map generation

Shared auto playback interface

Page 112: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SceneKit IntegrationSummary

Page 113: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SceneKit IntegrationSummary

Page 114: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shaders

Lighting and Shadows

New Physics

Tools

Improvements

Integration with SceneKit

Page 115: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shaders

Lighting and Shadows

New Physics

Tools

Improvements

Integration with SceneKit

Page 116: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SpriteKit EditorIntroduction

Page 117: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SpriteKit EditorOverview

Provides various editors integrated inside of Xcode

Data drive your game

Updated and simplified game project templates

Exported content can be deployed on OS X and iOS

!

Debug and edit existing scenes [NSKeyedArchiver archiveRootObject:self toFile:@"snapshot.sks"];

Page 118: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SpriteKit EditorFeatures

Object manipulation and placement

Physics bodies set-up

3D node

Shading and lighting

Inverse kinematic

Shader editor

Page 119: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Demo

Page 120: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shaders

Lighting and Shadows

New Physics

Tools

Improvements

Integration with SceneKit

Page 121: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Shaders

Lighting and Shadows

New Physics

Tools

Improvements

Integration with SceneKit

Page 122: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKScene

Each frame-update:

SKViewrenders the scene

-didFinishUpdate

-didApplyConstraints

SKSceneapplies constraints

-didSimulatePhysics

SKScenesimulates physics

-didEvaluateActions

SKSceneevaluates actions

Page 123: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKScene

Each frame-update:

SKViewrenders the scene

-didFinishUpdate

-didApplyConstraints

SKSceneapplies constraints

-didSimulatePhysics

SKScenesimulates physics

-didEvaluateActions

SKSceneevaluates actions

Page 124: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKScene

Each frame-update:

SKViewrenders the scene

-didFinishUpdate

-didApplyConstraints

SKSceneapplies constraints

-didSimulatePhysics

SKScenesimulates physics

-didEvaluateActions

SKSceneevaluates actions

Page 125: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKScene

Each frame-update:

SKViewrenders the scene

-didFinishUpdate

-didApplyConstraints

SKSceneapplies constraints

-didSimulatePhysics

SKScenesimulates physics

-didEvaluateActions

SKSceneevaluates actions

Page 126: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKScene

Each frame-update:

SKViewrenders the scene

-didFinishUpdate

-didApplyConstraints

SKSceneapplies constraints

-didSimulatePhysics

SKScenesimulates physics

-didEvaluateActions

SKSceneevaluates actions

Page 127: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKScene

Each frame-update:

SKViewrenders the scene

-didFinishUpdate

-didApplyConstraints

SKSceneapplies constraints

-didSimulatePhysics

SKScenesimulates physics

-didEvaluateActions

SKSceneevaluates actions

Page 128: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKScene

Each frame-update:

SKViewrenders the scene

-didFinishUpdate

-didApplyConstraints

SKSceneapplies constraints

-didSimulatePhysics

SKScenesimulates physics

-didEvaluateActions

SKSceneevaluates actions

Page 129: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKScene

Each frame-update:

SKViewrenders the scene

-didFinishUpdate

-didApplyConstraints

SKSceneapplies constraints

-didSimulatePhysics

SKScenesimulates physics

-didEvaluateActions

SKSceneevaluates actions

Page 130: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKScene

Each frame-update:

SKViewrenders the scene

-didFinishUpdate

-didApplyConstraints

SKSceneapplies constraints

-didSimulatePhysics

SKScenesimulates physics

-didEvaluateActions

SKSceneevaluates actions

Page 131: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKScene

Each frame-update:

SKViewrenders the scene

-didFinishUpdate

-didApplyConstraints

SKSceneapplies constraints

-didSimulatePhysics

SKScenesimulates physics

-didEvaluateActions

SKSceneevaluates actions

Page 132: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKMutableTexture

Create from data and can be modified efficiently

Provide code block to access raw pixel data

!

[tex modifyPixelDataWithBlock:^(void *pixelData, size_t lengthInBytes) { ... }];

SKTextureMutable texture

Page 133: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKMutableTexture

Create from data and can be modified efficiently

Provide code block to access raw pixel data

!

[tex modifyPixelDataWithBlock:^(void *pixelData, size_t lengthInBytes) { ... }];

SKTextureMutable texture

Page 134: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKTextureNoise texture

Generates coherent noise, or noise vector on a sphere

Supports grayscale and color output

Controls noise texture smoothness texture = [SKTexture textureNoiseWithSmoothness:0 size:CGSizeMake(s, s) grayscale:NO];

Page 135: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

SKShapeNode

Convenient constructors for common shapes - Rectangle, circle, ellipse, and spline

Simple joints for non-continuous shapes

Set texture and shaders on the shape’s stroke and fill

Interacting with physics - path property

Page 136: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics UpdatesCreate pin joint

bigGear.physicsBody.pinned = YES;

Page 137: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics UpdatesCreate pin joint

bigGear.physicsBody.pinned = YES;

Page 138: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

smallGear.physicsBody.pinned = YES; smallGear.physicsBody.allowsRotation = NO;

Physics UpdateCreate weld joint

Page 139: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

smallGear.physicsBody.pinned = YES; smallGear.physicsBody.allowsRotation = NO;

Physics UpdateCreate weld joint

Page 140: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Physics UpdateCreate compound bodies

+ (SKPhysicsBody *)bodyWithBodies:(NSArray *)bodies;

Page 141: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Texture AtlasGeneration

Supports SpriteKit and SceneKit

Supports Retina and non-Retina resolution

Supports 16-bit and 32-bit formats - RGBA8888, RGBA4444, RGBA565, and RGBA5551

Supports up to 4096x4096 resolution

!

Page 142: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Texture AtlasGeneration

Supports SpriteKit and SceneKit

Supports Retina and non-Retina resolution

Supports 16-bit and 32-bit formats - RGBA8888, RGBA4444, RGBA565, and RGBA5551

Supports up to 4096x4096 resolution

!

Page 143: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Texture AtlasRuntime generation

SKTextureAtlas *atlas = [SKTextureAtlas atlasWithDictionary:@{ @“ship.png” : image1, @“alien.png” : image2 }];

Page 144: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Summary

Page 145: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

More Information

Allan Schaffer Graphics and Game Technologies Evangelist [email protected]

Filip Iliescu Graphics and Game Technologies Evangelist [email protected]

Documentation SpriteKit Programming Guide http://developer.apple.com/library

Apple Developer Forums http://devforums.apple.com

Page 146: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Related Sessions

• Best Practices for Building SpriteKit Games Pacific Heights Wednesday 3:15PM

• What's New in SceneKit Pacific Heights Thursday 10:15AM

• Building a Game with SceneKit Pacific Heights Thursday 11:30AM

• Media Location Sunday 0:00PM

• Graphics and Games Location Sunday 0:00PM

• Core OS Location Sunday 0:00PM

• Special Events Location Sunday 0:00PM

Page 147: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best

Labs

• SpriteKit Lab Lab B Thursday 12:45PM

• Services Location Sunday 0:00PM

• Tools Location Sunday 0:00PM

• Media Location Sunday 0:00PM

• Graphics and Games Location Sunday 0:00PM

• Core OS Location Sunday 0:00PM

• Special Events Location Sunday 0:00PM

Page 148: What’s New in SpriteKit...u_sprite_size u_time u_path_length v_tex_coord v_color_mix v_path_distance sampler2D SKDefaultShading vec2 float float vec2 vec4 float vec4. Shaders Best