spritekit

package
v0.6.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package spritekit provides Go bindings for the SpriteKit framework.

Add high-performance 2D content with smooth animations to your app, or create a game with a high-level set of 2D game-based tools.

SpriteKit is a general-purpose framework for drawing shapes, particles, text, images, and video in two dimensions. It leverages Metal to achieve high-performance rendering, while offering a simple programming interface to make it easy to create games and other graphics-intensive apps. Using a rich set of animations and physics behaviors, you can quickly add life to your visual elements and gracefully transition between screens.

Essentials

Scene Renderers

Textures

Animation

Constraints

  • SKConstraint: A specification for constraining a node’s position or rotation.
  • SKReachConstraints: A specification of the degree of freedom when solving inverse kinematics.

Mathematical Tools

Physics Simulation

Physics Joints

Tiling

Shaders

Warping

  • SKWarpGeometry: A definition for a deformation of nodes that conform to .
  • SKWarpGeometryGrid: A definition for a grid-based deformation of nodes that conform to .
  • SKWarpable: A protocol for objects that can be warped and animated by an .//

Key Types

  • SKNode - The base class of all SpriteKit nodes.
  • SKEmitterNode - A source of various particle effects.
  • SKPhysicsBody - An object that adds physics simulation to a node.
  • SKShapeNode - A mathematical shape that can be stroked or filled.
  • SKSpriteNode - An image or solid color.
  • SKScene - An object that organizes all of the active SpriteKit content.
  • SKFieldNode - A node that applies physics effects to nearby nodes.
  • SKTileMapNode - A two-dimensional array of images.
  • SKView - A view subclass that renders a SpriteKit scene.
  • SKLabelNode - A graphical element that draws text.

Code generated from Apple documentation. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFloat32Float32Block

func NewFloat32Float32Block(handler Float32Float32Handler) (objc.ID, func())

NewFloat32Float32Block wraps a Go Float32Float32Handler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [SKFieldNode.CustomFieldWithEvaluationBlock]

func NewSKActionTimingFunctionBlock

func NewSKActionTimingFunctionBlock(handler SKActionTimingFunction) (objc.ID, func())

NewSKActionTimingFunctionBlock wraps a Go SKActionTimingFunction as an Objective-C block. The caller must defer the returned cleanup function.

func NewSKNodeBoolBlock

func NewSKNodeBoolBlock(handler SKNodeBoolHandler) (objc.ID, func())

NewSKNodeBoolBlock wraps a Go SKNodeBoolHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewSKPhysicsBodyBoolBlock

func NewSKPhysicsBodyBoolBlock(handler SKPhysicsBodyBoolHandler) (objc.ID, func())

NewSKPhysicsBodyBoolBlock wraps a Go SKPhysicsBodyBoolHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewSKPhysicsBodyCGPointCGVectorBoolBlock

func NewSKPhysicsBodyCGPointCGVectorBoolBlock(handler SKPhysicsBodyCGPointCGVectorBoolHandler) (objc.ID, func())

NewSKPhysicsBodyCGPointCGVectorBoolBlock wraps a Go SKPhysicsBodyCGPointCGVectorBoolHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewSKTextureAtlasArrayErrorBlock

func NewSKTextureAtlasArrayErrorBlock(handler SKTextureAtlasArrayErrorHandler) (objc.ID, func())

NewSKTextureAtlasArrayErrorBlock wraps a Go SKTextureAtlasArrayErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [SKTextureAtlas.PreloadTextureAtlasesNamedWithCompletionHandler]

func NewUnsafePointerUintptrBlock

func NewUnsafePointerUintptrBlock(handler UnsafePointerUintptrHandler) (objc.ID, func())

NewUnsafePointerUintptrBlock wraps a Go UnsafePointerUintptrHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewVoidBlock

func NewVoidBlock(handler VoidHandler) (objc.ID, func())

NewVoidBlock wraps a Go VoidHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

Types

type Float32Float32Handler

type Float32Float32Handler = func(float32, float32, float32, float32, float64) float32

Float32Float32Handler handles A custom block to be executed when a physics body is affected by the field.

Used by:

  • [SKFieldNode.CustomFieldWithEvaluationBlock]

type ISKAction

type ISKAction interface {
	objectivec.IObject

	// The duration required to complete an action.
	Duration() foundation.NSTimeInterval
	SetDuration(value foundation.NSTimeInterval)
	// A setting that controls the speed curve of an animation.
	TimingMode() SKActionTimingMode
	SetTimingMode(value SKActionTimingMode)
	// A block used to customize the timing function.
	TimingFunction() Float32Float32Handler
	SetTimingFunction(value Float32Float32Handler)
	// A speed factor that modifies how fast an action runs.
	Speed() float64
	SetSpeed(value float64)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKAction class.

Controlling Action Timing

See: https://developer.apple.com/documentation/SpriteKit/SKAction

type ISKAttribute

type ISKAttribute interface {
	objectivec.IObject

	// Creates and initializes a new attribute object of a specified type with a name that can be referenced within the shader.
	InitWithNameType(name string, type_ SKAttributeType) SKAttribute

	// The receiver’s name
	Name() string
	// The data type of the attribute’s value.
	Type() SKAttributeType

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKAttribute class.

Initializers

  • ISKAttribute.InitWithNameType: Creates and initializes a new attribute object of a specified type with a name that can be referenced within the shader.

Instance Properties

See: https://developer.apple.com/documentation/SpriteKit/SKAttribute

type ISKAttributeValue

type ISKAttributeValue interface {
	objectivec.IObject

	// The receiver’s floating point value.
	FloatValue() float32
	SetFloatValue(value float32)
	// The receiver’s value as a vector of two floating-point numbers.
	VectorFloat2Value() [2]float32
	SetVectorFloat2Value(value [2]float32)
	// The receiver’s value as a vector of three floating point numbers.
	VectorFloat3Value() Vector_float3
	SetVectorFloat3Value(value Vector_float3)
	// The receiver’s value as a vector of four floating point numbers.
	VectorFloat4Value() [4]float32
	SetVectorFloat4Value(value [4]float32)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKAttributeValue class.

Instance Properties

See: https://developer.apple.com/documentation/SpriteKit/SKAttributeValue

type ISKAudioNode

type ISKAudioNode interface {
	ISKNode

	// Initializes an audio node from an AVFoundation audio node.
	InitWithAVAudioNode(node avfaudio.AVAudioNode) SKAudioNode
	// Initializes an audio node from an audio asset with the specified filename.
	InitWithFileNamed(name string) SKAudioNode
	// Initializes an audio node from an audio asset with the specified URL.
	InitWithURL(url foundation.NSURL) SKAudioNode

	// The audio node’s current audio asset.
	AvAudioNode() avfaudio.AVAudioNode
	SetAvAudioNode(value avfaudio.AVAudioNode)
	// A Boolean property that indicates whether the node’s audio is altered based on the position of the node.
	IsPositional() bool
	SetPositional(value bool)
	// A Boolean value that indicates whether the audio should play in a loop when the node is added to the scene.
	AutoplayLooped() bool
	SetAutoplayLooped(value bool)
}

An interface definition for the SKAudioNode class.

Initializing Audio Nodes

Configuring Audio Nodes

See: https://developer.apple.com/documentation/SpriteKit/SKAudioNode

type ISKCameraNode

type ISKCameraNode interface {
	ISKNode

	// Finds nodes that are visible in the camera’s viewport.
	ContainedNodeSet() foundation.INSSet
	// Checks to see if a node is visible in the camera’s viewport.
	ContainsNode(node ISKNode) bool
}

An interface definition for the SKCameraNode class.

Node Visibility

See: https://developer.apple.com/documentation/SpriteKit/SKCameraNode

type ISKConstraint

type ISKConstraint interface {
	objectivec.IObject

	// The node whose coordinate system should be used to apply the constraint.
	ReferenceNode() ISKNode
	SetReferenceNode(value ISKNode)

	// A Boolean value that specifies whether the constraint is applied.
	Enabled() bool
	SetEnabled(value bool)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKConstraint class.

Controlling the Coordinate System Where a Constraint is Applied

Enabling and Disabling a Constraint

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint

type ISKCropNode

type ISKCropNode interface {
	ISKNode

	// The node used to determine the crop node’s mask.
	MaskNode() ISKNode
	SetMaskNode(value ISKNode)
}

An interface definition for the SKCropNode class.

Setting the Mask Filter

See: https://developer.apple.com/documentation/SpriteKit/SKCropNode

type ISKEffectNode

type ISKEffectNode interface {
	ISKNode

	// The Core Image filter to apply.
	Filter() coreimage.CIFilter
	SetFilter(value coreimage.CIFilter)
	// A Boolean value that determines whether the effect node applies the filter to its children as they are drawn.
	ShouldEnableEffects() bool
	SetShouldEnableEffects(value bool)
	// A Boolean value that determines whether the effect node automatically sets the filter’s image center.
	ShouldCenterFilter() bool
	SetShouldCenterFilter(value bool)

	// A custom shader that is called when the effect node is blended into the parent’s framebuffer.
	Shader() ISKShader
	SetShader(value ISKShader)
	// The values of each attribute associated with the node’s attached shader.
	AttributeValues() foundation.INSDictionary
	SetAttributeValues(value foundation.INSDictionary)
	// Sets an attribute value for an attached shader.
	SetValueForAttributeNamed(value ISKAttributeValue, key string)
	// Gets the value of a shader attribute.
	ValueForAttributeNamed(key string) ISKAttributeValue

	// A Boolean value that indicates whether the results of rendering the child nodes should be cached.
	ShouldRasterize() bool
	SetShouldRasterize(value bool)

	// The blend mode used to draw the node’s contents into its parent’s framebuffer.
	BlendMode() SKBlendMode
	SetBlendMode(value SKBlendMode)

	// The maximum number of subdivision iterations used to generate the final vertices.
	SubdivisionLevels() int
	// The warp geometry used to define the distortion.
	WarpGeometry() ISKWarpGeometry
}

An interface definition for the SKEffectNode class.

Applying Core Image Filters with an Effect Node

Applying a Shader with an Effect Node

Flattening an Effect Node’s Child Tree for Performance Improvement

Configuring Alpha Blending

See: https://developer.apple.com/documentation/SpriteKit/SKEffectNode

type ISKEmitterNode

type ISKEmitterNode interface {
	ISKNode

	// The target node that renders the emitter’s particles.
	TargetNode() ISKNode
	SetTargetNode(value ISKNode)

	// Advances the emitter particle simulation.
	AdvanceSimulationTime(sec foundation.NSTimeInterval)
	// Removes all existing particles and restarts the simulation.
	ResetSimulation()
	// The rate at which new particles are created.
	ParticleBirthRate() float64
	SetParticleBirthRate(value float64)
	// The number of particles the emitter should emit before stopping.
	NumParticlesToEmit() uint
	SetNumParticlesToEmit(value uint)

	// The order in which the emitter’s particles are rendered.
	ParticleRenderOrder() SKParticleRenderOrder
	SetParticleRenderOrder(value SKParticleRenderOrder)

	// The average lifetime of a particle, in seconds.
	ParticleLifetime() float64
	SetParticleLifetime(value float64)
	// The range of allowed random values for a particle’s lifetime.
	ParticleLifetimeRange() float64
	SetParticleLifetimeRange(value float64)

	// The average starting position for a particle.
	ParticlePosition() corefoundation.CGPoint
	SetParticlePosition(value corefoundation.CGPoint)
	// The range of allowed random values for a particle’s position.
	ParticlePositionRange() corefoundation.CGVector
	SetParticlePositionRange(value corefoundation.CGVector)
	// The average starting depth of a particle.
	ParticleZPosition() float64
	SetParticleZPosition(value float64)

	// The average initial speed of a new particle, in points per second.
	ParticleSpeed() float64
	SetParticleSpeed(value float64)
	// The range of allowed random values for a particle’s initial speed.
	ParticleSpeedRange() float64
	SetParticleSpeedRange(value float64)
	// The average initial direction of a particle, expressed as an angle in radians.
	EmissionAngle() float64
	SetEmissionAngle(value float64)
	// The range of allowed random values for a particle’s initial direction, expressed as an angle in radians.
	EmissionAngleRange() float64
	SetEmissionAngleRange(value float64)
	// The acceleration to apply to a particle’s horizontal velocity.
	XAcceleration() float64
	SetXAcceleration(value float64)
	// The acceleration to apply to a particle’s vertical velocity.
	YAcceleration() float64
	SetYAcceleration(value float64)

	// The average initial rotation of a particle, expressed as an angle in radians.
	ParticleRotation() float64
	SetParticleRotation(value float64)
	// The range of allowed random values for a particle’s initial rotation, expressed as an angle in radians.
	ParticleRotationRange() float64
	SetParticleRotationRange(value float64)
	// The speed at which a particle rotates, expressed in radians per second.
	ParticleRotationSpeed() float64
	SetParticleRotationSpeed(value float64)

	// The average initial scale factor of a particle.
	ParticleScale() float64
	SetParticleScale(value float64)
	// The range of allowed random values for a particle’s initial scale.
	ParticleScaleRange() float64
	SetParticleScaleRange(value float64)
	// The rate at which a particle’s scale factor changes per second.
	ParticleScaleSpeed() float64
	SetParticleScaleSpeed(value float64)
	// The sequence used to specify the scale factor of a particle over its lifetime.
	ParticleScaleSequence() ISKKeyframeSequence
	SetParticleScaleSequence(value ISKKeyframeSequence)

	// The texture to use to render a particle.
	ParticleTexture() ISKTexture
	SetParticleTexture(value ISKTexture)
	// The starting size of each particle.
	ParticleSize() corefoundation.CGSize
	SetParticleSize(value corefoundation.CGSize)

	// The sequence used to specify the color components of a particle over its lifetime.
	ParticleColorSequence() ISKKeyframeSequence
	SetParticleColorSequence(value ISKKeyframeSequence)
	// The average initial color for a particle.
	ParticleColor() appkit.NSColor
	SetParticleColor(value appkit.NSColor)
	// The range of allowed random values for the alpha component of a particle’s initial color.
	ParticleColorAlphaRange() float64
	SetParticleColorAlphaRange(value float64)
	// The range of allowed random values for the blue component of a particle’s initial color.
	ParticleColorBlueRange() float64
	SetParticleColorBlueRange(value float64)
	// The range of allowed random values for the green component of a particle’s initial color.
	ParticleColorGreenRange() float64
	SetParticleColorGreenRange(value float64)
	// The range of allowed random values for the red component of a particle’s initial color.
	ParticleColorRedRange() float64
	SetParticleColorRedRange(value float64)
	// The rate at which the alpha component of a particle’s color changes per second.
	ParticleColorAlphaSpeed() float64
	SetParticleColorAlphaSpeed(value float64)
	// The rate at which the blue component of a particle’s color changes per second.
	ParticleColorBlueSpeed() float64
	SetParticleColorBlueSpeed(value float64)
	// The rate at which the green component of a particle’s color changes per second.
	ParticleColorGreenSpeed() float64
	SetParticleColorGreenSpeed(value float64)
	// The rate at which the red component of a particle’s color changes per second.
	ParticleColorRedSpeed() float64
	SetParticleColorRedSpeed(value float64)

	// The sequence used to specify the color blend factor of a particle over its lifetime.
	ParticleColorBlendFactorSequence() ISKKeyframeSequence
	SetParticleColorBlendFactorSequence(value ISKKeyframeSequence)
	// The average starting value for the color blend factor.
	ParticleColorBlendFactor() float64
	SetParticleColorBlendFactor(value float64)
	// The range of allowed random values for a particle’s starting color blend factor.
	ParticleColorBlendFactorRange() float64
	SetParticleColorBlendFactorRange(value float64)
	// The rate at which the color blend factor changes per second.
	ParticleColorBlendFactorSpeed() float64
	SetParticleColorBlendFactorSpeed(value float64)

	// The blending mode used to blend particles into the framebuffer.
	ParticleBlendMode() SKBlendMode
	SetParticleBlendMode(value SKBlendMode)
	// The sequence used to specify the alpha value of a particle over its lifetime.
	ParticleAlphaSequence() ISKKeyframeSequence
	SetParticleAlphaSequence(value ISKKeyframeSequence)
	// The average starting alpha value for a particle.
	ParticleAlpha() float64
	SetParticleAlpha(value float64)
	// The range of allowed random values for a particle’s starting alpha value.
	ParticleAlphaRange() float64
	SetParticleAlphaRange(value float64)
	// The rate at which the alpha value of a particle changes per second.
	ParticleAlphaSpeed() float64
	SetParticleAlphaSpeed(value float64)

	// An action executed by new particles.
	ParticleAction() ISKAction
	SetParticleAction(value ISKAction)

	// A mask that defines which categories of physics fields can exert forces on the particles.
	FieldBitMask() uint32
	SetFieldBitMask(value uint32)

	// A custom shader used to determine how particles are rendered.
	Shader() ISKShader
	SetShader(value ISKShader)
	// The values of each attribute associated with the node’s attached shader.
	AttributeValues() foundation.INSDictionary
	SetAttributeValues(value foundation.INSDictionary)
	// Sets an attribute value for an attached shader.
	SetValueForAttributeNamed(value ISKAttributeValue, key string)
	// Gets the value of a shader attribute.
	ValueForAttributeNamed(key string) ISKAttributeValue
}

An interface definition for the SKEmitterNode class.

Choosing Which Node in the Scene Emits Particles

Controlling When Particles Are Created

Controlling the Rendering Order of an Emitter’s Particles

Controlling Particle Lifetime

Controlling Particle Position

Controlling Particle Velocity and Acceleration

Adjusting a Particle’s Rotation

Scaling Particles by a Factor

Changing a Particle’s Source Image and Size

Configuring Particle Color

Controlling How the Texture is Blended with Particle Color

Blending Particles with the Framebuffer

Animating Particles

Applying Physics Fields to the Particles

Taking Full Control of Particle Drawing with a Shader

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode

type ISKFieldNode

type ISKFieldNode interface {
	ISKNode

	// A Boolean value that indicates whether the field is active.
	IsEnabled() bool
	SetEnabled(value bool)
	// A Boolean value that indicates whether the field node should override all other field nodes that might otherwise affect physics bodies.
	IsExclusive() bool
	SetExclusive(value bool)
	// The area (relative to the node’s origin) that the field affects.
	Region() ISKRegion
	SetRegion(value ISKRegion)
	// The minimum value for distance-based effects.
	MinimumRadius() float32
	SetMinimumRadius(value float32)
	// A mask that defines which categories this field belongs to.
	CategoryBitMask() uint32
	SetCategoryBitMask(value uint32)

	// The strength of the field.
	Strength() float32
	SetStrength(value float32)
	// The exponent that defines the rate of decay for the strength of the field as the distance increases between the node and the physics body being affected.
	Falloff() float32
	SetFalloff(value float32)

	// The rate at which a noise or turbulence field node changes.
	AnimationSpeed() float32
	SetAnimationSpeed(value float32)
	// The smoothness of the noise used to generate the forces.
	Smoothness() float32
	SetSmoothness(value float32)
	// The direction of a velocity field node.
	Direction() Vector_float3
	SetDirection(value Vector_float3)
	// A normal texture that specifies the velocities at different points in a velocity field node.
	Texture() ISKTexture
	SetTexture(value ISKTexture)
}

An interface definition for the SKFieldNode class.

Determining Which Physics Bodies Are Affected by the Field

Configuring the Strength of the Field

Configuring Other Field Properties

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode

type ISKKeyframeSequence

type ISKKeyframeSequence interface {
	objectivec.IObject

	// Initializes a keyframe sequence with an initial set of values and times.
	InitWithKeyframeValuesTimes(values foundation.INSArray, times []foundation.NSNumber) SKKeyframeSequence
	// Initializes a new keyframe sequence.
	InitWithCapacity(numItems uint) SKKeyframeSequence
	InitWithCoder(aDecoder foundation.INSCoder) SKKeyframeSequence

	// Adds a keyframe to the sequence.
	AddKeyframeValueTime(value objectivec.IObject, time float64)
	// Removes a keyframe from the sequence.
	RemoveKeyframeAtIndex(index uint)
	// Removes the last value in the sequence.
	RemoveLastKeyframe()
	// Changes the time for a specific keyframe.
	SetKeyframeTimeForIndex(time float64, index uint)
	// Changes the value for a specific keyframe.
	SetKeyframeValueForIndex(value objectivec.IObject, index uint)
	// Replaces a keyframe in the sequence with a new keyframe.
	SetKeyframeValueTimeForIndex(value objectivec.IObject, time float64, index uint)

	// Calculates the sample at a particular time.
	SampleAtTime(time float64) objectivec.IObject

	// The number of keyframes in the sequence.
	Count() uint
	// Gets the time for a keyframe in the sequence.
	GetKeyframeTimeForIndex(index uint) float64
	// Gets the value for a keyframe in the sequence.
	GetKeyframeValueForIndex(index uint) objectivec.IObject

	// The mode used to determine how values for times between the keyframes are calculated.
	InterpolationMode() SKInterpolationMode
	SetInterpolationMode(value SKInterpolationMode)
	// The mode used to determine how the keyframe sequence repeats.
	RepeatMode() SKRepeatMode
	SetRepeatMode(value SKRepeatMode)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKKeyframeSequence class.

First Steps

Sequence Building

Sequence Running

Sequence Information

Interpolation Modifiers

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence

type ISKLabelNode

type ISKLabelNode interface {
	ISKNode

	// Initializes a new label object with a specified font.
	InitWithFontNamed(fontName string) SKLabelNode

	// The string that the label node displays.
	Text() string
	SetText(value string)
	// The attributed string displayed by the label.
	AttributedText() foundation.NSAttributedString
	SetAttributedText(value foundation.NSAttributedString)

	// The color of the label.
	FontColor() appkit.NSColor
	SetFontColor(value appkit.NSColor)
	// The font used for the text in the label.
	FontName() string
	SetFontName(value string)
	// The size of the font used in the label.
	FontSize() float64
	SetFontSize(value float64)

	// The vertical position of the text within the node.
	VerticalAlignmentMode() SKLabelVerticalAlignmentMode
	SetVerticalAlignmentMode(value SKLabelVerticalAlignmentMode)
	// The horizontal position of the text within the node.
	HorizontalAlignmentMode() SKLabelHorizontalAlignmentMode
	SetHorizontalAlignmentMode(value SKLabelHorizontalAlignmentMode)

	// The width, in screen points, after which line-break mode should be applied.
	PreferredMaxLayoutWidth() float64
	SetPreferredMaxLayoutWidth(value float64)
	// Determines the line-break mode for multiple lines.
	LineBreakMode() appkit.NSLineBreakMode
	SetLineBreakMode(value appkit.NSLineBreakMode)
	// Determines the number of lines to draw.
	NumberOfLines() int
	SetNumberOfLines(value int)

	// An alternative to the font color that can be used for animations.
	Color() appkit.NSColor
	SetColor(value appkit.NSColor)
	// A floating-point value that describes how the color is blended with the font color.
	ColorBlendFactor() float64
	SetColorBlendFactor(value float64)

	// The blend mode used to draw the label into the parent’s framebuffer.
	BlendMode() SKBlendMode
	SetBlendMode(value SKBlendMode)
}

An interface definition for the SKLabelNode class.

Creating a Label

Setting a Label’s Text

Specifying a Label’s Font

Controlling a Label’s Alignment

Defining a Label’s Line-Breaking Behavior

Colorizing a Label

Configuring Alpha Blending

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode

type ISKLightNode

type ISKLightNode interface {
	ISKNode

	// A Boolean value that indicates whether the node is casting light.
	IsEnabled() bool
	SetEnabled(value bool)
	// A mask that defines which categories this light belongs to.
	CategoryBitMask() uint32
	SetCategoryBitMask(value uint32)

	// The ambient color of the light.
	AmbientColor() appkit.NSColor
	SetAmbientColor(value appkit.NSColor)
	// The diffuse and specular color of the light source.
	LightColor() appkit.NSColor
	SetLightColor(value appkit.NSColor)
	// The color of any shadow cast by a sprite.
	ShadowColor() appkit.NSColor
	SetShadowColor(value appkit.NSColor)
	// The exponent for the rate of decay of the light source.
	Falloff() float64
	SetFalloff(value float64)
}

An interface definition for the SKLightNode class.

Determining Whether a Light Node Is Active

Configuring the Lighting Properties

See: https://developer.apple.com/documentation/SpriteKit/SKLightNode

type ISKMutableTexture

type ISKMutableTexture interface {
	ISKTexture

	// Initializes an empty texture with a specific size and format.
	InitWithSizePixelFormat(size corefoundation.CGSize, format int32) SKMutableTexture
	// Initializes an empty texture with a specific size.
	InitWithSize(size corefoundation.CGSize) SKMutableTexture

	// Modifies the contents of a mutable texture.
	ModifyPixelDataWithBlock(block UnsafePointerUintptrHandler)
}

An interface definition for the SKMutableTexture class.

Creating an Empty Mutable Texture

Modifying a Mutable Texture’s Contents

See: https://developer.apple.com/documentation/SpriteKit/SKMutableTexture

type ISKNode

type ISKNode interface {
	objectivec.IObject

	// Called when a node is initialized from an .sks file.
	InitWithCoder(aDecoder foundation.INSCoder) SKNode

	// The position of the node in its parent’s coordinate system.
	Position() corefoundation.CGPoint
	SetPosition(value corefoundation.CGPoint)

	// A rectangle in the parent’s coordinate system that contains the node’s content, ignoring the node’s children.
	Frame() corefoundation.CGRect
	// Returns a rectangle in the parent’s coordinate system that contains the position and size of itself and all child nodes.
	CalculateAccumulatedFrame() corefoundation.CGRect

	// The height of the node relative to its parent.
	ZPosition() float64
	SetZPosition(value float64)

	// The Euler rotation about the z axis (in radians).
	ZRotation() float64
	SetZRotation(value float64)
	// Sets the [xScale](<https://developer.apple.com/documentation/SpriteKit/SKNode/xScale>) and [yScale](<https://developer.apple.com/documentation/SpriteKit/SKNode/yScale>) properties of the node.
	SetScale(scale float64)
	// A scaling factor that multiplies the width of a node and its children.
	XScale() float64
	SetXScale(value float64)
	// A scaling factor that multiplies the height of a node and its children.
	YScale() float64
	SetYScale(value float64)

	// The scene node that contains this node.
	Scene() ISKScene
	// The node’s parent node.
	Parent() ISKNode
	// The node’s children.
	Children() []SKNode

	// Adds a node to the end of the receiver’s list of child nodes.
	AddChild(node ISKNode)
	// Inserts a node into a specific position in the receiver’s list of child nodes.
	InsertChildAtIndex(node ISKNode, index int)
	// Compares the parameter node to the receiving node.
	IsEqualToNode(node ISKNode) bool
	// Moves the node to a new parent node in the scene.
	MoveToParent(parent ISKNode)
	// Removes the receiving node from its parent.
	RemoveFromParent()
	// Removes all of the node’s children.
	RemoveAllChildren()
	// Removes a list of children from the receiving node.
	RemoveChildrenInArray(nodes []SKNode)
	// Returns a Boolean value that indicates whether the node is a descendant of the target node.
	InParentHierarchy(parent ISKNode) bool

	// The node’s assignable name.
	Name() string
	SetName(value string)
	// Searches the children of the receiving node for a node with a specific name.
	ChildNodeWithName(name string) ISKNode
	// Searches the children of the receiving node to perform processing for nodes that share a name.
	EnumerateChildNodesWithNameUsingBlock(name string, block SKNodeBoolHandler)
	// Returns an array of nodes that match the name parameter.
	ObjectForKeyedSubscript(name string) []SKNode

	// The transparency value applied to the node’s contents.
	Alpha() float64
	SetAlpha(value float64)
	// A Boolean value that determines whether a node and its descendants are rendered.
	IsHidden() bool
	SetHidden(value bool)

	// Adds an action to the list of actions executed by the node.
	RunAction(action ISKAction)
	// Adds an action to the list of actions executed by the node and schedules the argument block to be run upon completion of the action.
	RunActionCompletion(action ISKAction, block VoidHandler)
	// Adds an identifiable action to the list of actions executed by the node.
	RunActionWithKey(action ISKAction, key string)
	// A speed modifier applied to all actions executed by a node and its descendants.
	Speed() float64
	SetSpeed(value float64)
	// A Boolean value that determines whether actions on the node and its descendants are processed.
	IsPaused() bool
	SetPaused(value bool)
	// Returns an action associated with a specific key.
	ActionForKey(key string) ISKAction
	// Returns a Boolean value that indicates whether the node is executing actions.
	HasActions() bool
	// Ends and removes all actions from the node.
	RemoveAllActions()
	// Removes an action associated with a specific key.
	RemoveActionForKey(key string)

	// The physics body associated with the node.
	PhysicsBody() ISKPhysicsBody
	SetPhysicsBody(value ISKPhysicsBody)

	// A list of constraints to apply to the node.
	Constraints() []SKConstraint
	SetConstraints(value []SKConstraint)
	// The reach constraints to apply to the node when executing a reach action.
	ReachConstraints() ISKReachConstraints
	SetReachConstraints(value ISKReachConstraints)

	// Returns a Boolean value that indicates whether this node intersects the specified node.
	IntersectsNode(node ISKNode) bool

	// The GameplayKit entity this node represents.
	Entity() objectivec.IObject
	SetEntity(value objectivec.IObject)

	// A Boolean value that indicates whether the node receives touch events.
	IsUserInteractionEnabled() bool
	SetUserInteractionEnabled(value bool)

	// Returns a Boolean value that indicates whether a point lies inside the parent’s coordinate system.
	ContainsPoint(p corefoundation.CGPoint) bool
	// Returns the deepest visible descendant that intersects a point.
	NodeAtPoint(p corefoundation.CGPoint) ISKNode
	// Returns an array of all visible descendants that intersect a point.
	NodesAtPoint(p corefoundation.CGPoint) []SKNode

	// Converts a point from the coordinate system of another node in the node tree to the coordinate system of this node.
	ConvertPointFromNode(point corefoundation.CGPoint, node ISKNode) corefoundation.CGPoint
	// Converts a point in this node’s coordinate system to the coordinate system of another node in the node tree.
	ConvertPointToNode(point corefoundation.CGPoint, node ISKNode) corefoundation.CGPoint

	// A dictionary containing arbitrary data.
	UserData() foundation.INSDictionary
	SetUserData(value foundation.INSDictionary)

	// An array of user interface elements that represent children of this element.
	AccessibilityChildren() foundation.INSArray
	SetAccessibilityChildren(value foundation.INSArray)
	// The size of this user interface element, in screen points.
	AccessibilityFrame() corefoundation.CGRect
	SetAccessibilityFrame(value corefoundation.CGRect)
	// The help description of this user interface element; for example, the text shown in a tooltip.
	AccessibilityHelp() string
	SetAccessibilityHelp(value string)
	// A short description of this user interface element.
	AccessibilityLabel() string
	SetAccessibilityLabel(value string)
	// The user interface element that contains this element.
	AccessibilityParent() objectivec.IObject
	SetAccessibilityParent(value objectivec.IObject)
	// A string value describing the user interface element type; for example, a button.
	AccessibilityRole() string
	SetAccessibilityRole(value string)
	// A string value describing the user interface element name and type; for example, the Buy button.
	AccessibilityRoleDescription() string
	SetAccessibilityRoleDescription(value string)
	// A string that defines this user interface element’s subrole; for example, a full-screen button.
	AccessibilitySubrole() string
	SetAccessibilitySubrole(value string)
	// A toggle you implement to indicate to the system whether this user interface element should be exposed to the user.
	IsAccessibilityElement() bool
	SetAccessibilityElement(value bool)
	// A toggle you implement to indicate to the system whether this user interface element should respond to user input.
	IsAccessibilityEnabled() bool
	SetAccessibilityEnabled(value bool)
	// Returns the frontmost user interface element in the element hierarchy.
	AccessibilityHitTest(point corefoundation.CGPoint) objectivec.IObject

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKNode class.

First Steps

Positioning Content in a Scene

Querying the Content Size

  • ISKNode.Frame: A rectangle in the parent’s coordinate system that contains the node’s content, ignoring the node’s children.
  • ISKNode.CalculateAccumulatedFrame: Returns a rectangle in the parent’s coordinate system that contains the position and size of itself and all child nodes.

Configuring Draw Order

Scaling and Rotating

Modifying the Node Tree

Accessing Nodes by Name

Altering Node Visibility

Running Actions

Adding Physics Behaviors

Constraining Node Position or Rotation

Detecting Collisions Manually

  • ISKNode.IntersectsNode: Returns a Boolean value that indicates whether this node intersects the specified node.

Adding GameplayKit Behaviors

Handling User Input

Hit Testing

  • ISKNode.ContainsPoint: Returns a Boolean value that indicates whether a point lies inside the parent’s coordinate system.
  • ISKNode.NodeAtPoint: Returns the deepest visible descendant that intersects a point.
  • ISKNode.NodesAtPoint: Returns an array of all visible descendants that intersect a point.

Converting Between Coordinate Systems of Different Nodes

  • ISKNode.ConvertPointFromNode: Converts a point from the coordinate system of another node in the node tree to the coordinate system of this node.
  • ISKNode.ConvertPointToNode: Converts a point in this node’s coordinate system to the coordinate system of another node in the node tree.

Adding Custom Data Without Subclassing

Providing Accessibility

See: https://developer.apple.com/documentation/SpriteKit/SKNode

type ISKPhysicsBody

type ISKPhysicsBody interface {
	objectivec.IObject

	// A Boolean value that indicates whether this physics body is affected by the physics world’s gravity.
	AffectedByGravity() bool
	SetAffectedByGravity(value bool)
	// A Boolean value that indicates whether the physics body is affected by angular forces and impulses applied to it.
	AllowsRotation() bool
	SetAllowsRotation(value bool)
	// A Boolean value that indicates whether the physics body is moved by the physics simulation.
	IsDynamic() bool
	SetDynamic(value bool)

	// The mass of the body, in kilograms.
	Mass() float64
	SetMass(value float64)
	// The density of the object, in kilograms per square meter.
	Density() float64
	SetDensity(value float64)
	// The area covered by the body.
	Area() float64
	// The roughness of the surface of the physics body.
	Friction() float64
	SetFriction(value float64)
	// The bounciness of the physics body.
	Restitution() float64
	SetRestitution(value float64)
	// A property that reduces the body’s linear velocity.
	LinearDamping() float64
	SetLinearDamping(value float64)
	// A property that reduces the body’s rotational velocity.
	AngularDamping() float64
	SetAngularDamping(value float64)

	// A mask that defines which categories this physics body belongs to.
	CategoryBitMask() uint32
	SetCategoryBitMask(value uint32)
	// A mask that defines which categories of physics bodies can collide with this physics body.
	CollisionBitMask() uint32
	SetCollisionBitMask(value uint32)
	// A Boolean value that determines whether the physics world uses an iterative collision detection algorithm.
	UsesPreciseCollisionDetection() bool
	SetUsesPreciseCollisionDetection(value bool)
	// A mask that defines which categories of physics bodies cause intersection notifications with this physics body.
	ContactTestBitMask() uint32
	SetContactTestBitMask(value uint32)
	// The physics bodies that this physics body is in contact with.
	AllContactedBodies() []SKPhysicsBody

	// Applies a force to the center of gravity of a physics body.
	ApplyForce(force corefoundation.CGVector)
	// Applies torque to an object.
	ApplyTorque(torque float64)
	// Applies a force to a specific point of a physics body.
	ApplyForceAtPoint(force corefoundation.CGVector, point corefoundation.CGPoint)
	// Applies an impulse to the center of gravity of a physics body.
	ApplyImpulse(impulse corefoundation.CGVector)
	// Applies an impulse that imparts angular momentum to an object.
	ApplyAngularImpulse(impulse float64)
	// Applies an impulse to a specific point of a physics body.
	ApplyImpulseAtPoint(impulse corefoundation.CGVector, point corefoundation.CGPoint)

	// The physics body’s velocity vector, measured in meters per second.
	Velocity() corefoundation.CGVector
	SetVelocity(value corefoundation.CGVector)
	// The physics body’s angular speed.
	AngularVelocity() float64
	SetAngularVelocity(value float64)
	// A Boolean property that indicates whether the object is at rest within the physics simulation.
	IsResting() bool
	SetResting(value bool)

	// The node that this body is connected to.
	Node() ISKNode

	// The joints connected to this physics body.
	Joints() []SKPhysicsJoint

	// A mask that defines which categories of physics fields can exert forces on this physics body.
	FieldBitMask() uint32
	SetFieldBitMask(value uint32)
	// The electrical charge of the physics body.
	Charge() float64
	SetCharge(value float64)

	// A Boolean value that indicates whether the physics body’s node is pinned to its parent node.
	Pinned() bool
	SetPinned(value bool)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKPhysicsBody class.

Defining How Forces Affect a Physics Body

Defining a Physics Body’s Physical Properties

Working with Collisions and Contacts

Applying Forces and Impulses to a Physics Body

Inspecting a Physics Body’s Position and Velocity

Reading a Physics Body’s Node

Determining Which Joints Are Connected to a Physics Body

Interacting with Physics Fields

Pinning a Physics Body to a Node’s Parent

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody

type ISKPhysicsContact

type ISKPhysicsContact interface {
	objectivec.IObject

	// The first body in the contact.
	BodyA() ISKPhysicsBody
	// The second body in the contact.
	BodyB() ISKPhysicsBody
	// The contact point between the two physics bodies, in scene coordinates.
	ContactPoint() corefoundation.CGPoint
	// The impulse that specifies how hard these two bodies struck each other in Newton-seconds.
	CollisionImpulse() float64
	// The normal vector specifying the direction of the collision.
	ContactNormal() corefoundation.CGVector
}

An interface definition for the SKPhysicsContact class.

Inspecting the Contact Properties

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsContact

type ISKPhysicsJoint

type ISKPhysicsJoint interface {
	objectivec.IObject

	// The first body connected by the joint.
	BodyA() ISKPhysicsBody
	SetBodyA(value ISKPhysicsBody)
	// The second body connected by the joint.
	BodyB() ISKPhysicsBody
	SetBodyB(value ISKPhysicsBody)

	// The instantaneous reaction force, in newtons, currently being directed at the anchor point.
	ReactionForce() corefoundation.CGVector
	// Instantaneous reaction torque, in newton-meters,  currently being directed at the anchor point.
	ReactionTorque() float64

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKPhysicsJoint class.

Accessing or Setting a Joint’s Bodies

Reading the Stress and Speed that Are Currently Applied to a Joint

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJoint

type ISKPhysicsJointFixed

type ISKPhysicsJointFixed interface {
	ISKPhysicsJoint
}

An interface definition for the SKPhysicsJointFixed class.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointFixed

type ISKPhysicsJointLimit

type ISKPhysicsJointLimit interface {
	ISKPhysicsJoint

	// The maximum distance allowed between the two physics bodies connected by the limit joint.
	MaxLength() float64
	SetMaxLength(value float64)
}

An interface definition for the SKPhysicsJointLimit class.

Configuring a Limit Joint

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointLimit

type ISKPhysicsJointPin

type ISKPhysicsJointPin interface {
	ISKPhysicsJoint

	// The speed, in radians per second, at which the physics bodies are driven around the pin joint.
	RotationSpeed() float64
	SetRotationSpeed(value float64)
	// A Boolean value that indicates whether the pin joint’s rotation is limited to a specific range of values.
	ShouldEnableLimits() bool
	SetShouldEnableLimits(value bool)
	// The smallest angle allowed for the pin joint, in radians.
	LowerAngleLimit() float64
	SetLowerAngleLimit(value float64)
	// The largest angle allowed for the pin joint, in radians.
	UpperAngleLimit() float64
	SetUpperAngleLimit(value float64)
	// The resistance applied by the pin joint to spinning around the anchor point.
	FrictionTorque() float64
	SetFrictionTorque(value float64)
}

An interface definition for the SKPhysicsJointPin class.

Configuring a Pin Joint

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointPin

type ISKPhysicsJointSliding

type ISKPhysicsJointSliding interface {
	ISKPhysicsJoint

	// A Boolean value that indicates whether the sliding joint is restricted so that the objects may only slide a finite distance from the initial anchor point.
	ShouldEnableLimits() bool
	SetShouldEnableLimits(value bool)
	// The smallest distance allowed for the sliding joint.
	LowerDistanceLimit() float64
	SetLowerDistanceLimit(value float64)
	// The largest distance allowed for the sliding joint.
	UpperDistanceLimit() float64
	SetUpperDistanceLimit(value float64)
}

An interface definition for the SKPhysicsJointSliding class.

Configuring a Sliding Joint

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointSliding

type ISKPhysicsJointSpring

type ISKPhysicsJointSpring interface {
	ISKPhysicsJoint

	// Defines how the spring’s motion should be damped due to the forces of friction.
	Damping() float64
	SetDamping(value float64)
	// Defines the frequency or stiffness characteristics of the spring.
	Frequency() float64
	SetFrequency(value float64)
}

An interface definition for the SKPhysicsJointSpring class.

Configuring a Spring Joint

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointSpring

type ISKPhysicsWorld

type ISKPhysicsWorld interface {
	objectivec.IObject

	// A vector that specifies the gravitational acceleration applied to physics bodies in the physics world.
	Gravity() corefoundation.CGVector
	SetGravity(value corefoundation.CGVector)
	// The rate at which the simulation executes.
	Speed() float64
	SetSpeed(value float64)

	// Adds a joint to the physics world.
	AddJoint(joint ISKPhysicsJoint)
	// Removes all joints from the physics world.
	RemoveAllJoints()
	// Removes a specific joint from the physics world.
	RemoveJoint(joint ISKPhysicsJoint)

	// A delegate that is called when two physics bodies come in contact with each other.
	ContactDelegate() SKPhysicsContactDelegate
	SetContactDelegate(value SKPhysicsContactDelegate)

	// Searches for the first physics body that intersects a ray.
	BodyAlongRayStartEnd(start corefoundation.CGPoint, end corefoundation.CGPoint) ISKPhysicsBody
	// Searches for the first physics body that contains a point.
	BodyAtPoint(point corefoundation.CGPoint) ISKPhysicsBody
	// Searches for the first physics body that intersects the specified rectangle.
	BodyInRect(rect corefoundation.CGRect) ISKPhysicsBody
	// Enumerates all the physics bodies in the scene that intersect a ray.
	EnumerateBodiesAlongRayStartEndUsingBlock(start corefoundation.CGPoint, end corefoundation.CGPoint, block SKPhysicsBodyCGPointCGVectorBoolHandler)
	// Enumerates all the physics bodies in the scene that contain a point.
	EnumerateBodiesAtPointUsingBlock(point corefoundation.CGPoint, block SKPhysicsBodyBoolHandler)
	// Enumerates all the physics bodies in the scene that intersect the specified rectangle.
	EnumerateBodiesInRectUsingBlock(rect corefoundation.CGRect, block SKPhysicsBodyBoolHandler)

	// Samples all of the field nodes in the scene and returns the summation of their forces at that point.
	SampleFieldsAt(position Vector_float3) Vector_float3

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKPhysicsWorld class.

Configuring the Physics World

Joining Physics Bodies with Joints

Detecting Collisions

Searching the Scene for Physics Bodies

Sampling Physics Fields

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld

type ISKRange

type ISKRange interface {
	objectivec.IObject

	// Initializes a new range object.
	InitWithLowerLimitUpperLimit(lower float64, upper float64) SKRange

	// The minimum possible value.
	LowerLimit() float64
	SetLowerLimit(value float64)
	// The maximum possible value.
	UpperLimit() float64
	SetUpperLimit(value float64)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKRange class.

Creating a Range Object

Inspecting a Range Object’s Limits

See: https://developer.apple.com/documentation/SpriteKit/SKRange

type ISKReachConstraints

type ISKReachConstraints interface {
	objectivec.IObject

	// Initializes a new reach constraint object.
	InitWithLowerAngleLimitUpperAngleLimit(lowerAngleLimit float64, upperAngleLimit float64) SKReachConstraints
	// The minimum angle that the node can have after it is rotated by a reach event.
	LowerAngleLimit() float64
	SetLowerAngleLimit(value float64)
	// The maximum angle that the node can have after it is rotated by a reach event.
	UpperAngleLimit() float64
	SetUpperAngleLimit(value float64)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKReachConstraints class.

Working with Reach Constraints

See: https://developer.apple.com/documentation/SpriteKit/SKReachConstraints

type ISKReferenceNode

type ISKReferenceNode interface {
	ISKNode

	// Initializes a reference node from a URL.
	InitWithURL(url foundation.NSURL) SKReferenceNode
	// Initializes a reference node from a file in the app’s main bundle.
	InitWithFileNamed(fileName string) SKReferenceNode

	// Loads the reference node’s content and adds it as a new child node.
	ResolveReferenceNode()

	// A method called by SpriteKit after the reference node’s contents are loaded.
	DidLoadReferenceNode(node ISKNode)
}

An interface definition for the SKReferenceNode class.

Initializers

Regenerating

Loading Callback

See: https://developer.apple.com/documentation/SpriteKit/SKReferenceNode

type ISKRegion

type ISKRegion interface {
	objectivec.IObject

	// Initializes a new region with a rectangular area.
	InitWithSize(size corefoundation.CGSize) SKRegion
	// Initializes a new region with a circular area.
	InitWithRadius(radius float32) SKRegion
	// Initializes a new region using a Core Graphics path.
	InitWithPath(path coregraphics.CGPathRef) SKRegion
	// Returns a new region that is the mathematical inverse of an existing region.
	InverseRegion() ISKRegion
	// Returns a new region created by subtracting the contents of another region from this region.
	RegionByDifferenceFromRegion(region ISKRegion) ISKRegion
	// Returns a new region created by intersecting the contents of this region with another region.
	RegionByIntersectionWithRegion(region ISKRegion) ISKRegion
	// Returns a new region created by combining the contents of this region with another region.
	RegionByUnionWithRegion(region ISKRegion) ISKRegion

	// Returns a Core Graphics path that defines the region.
	Path() coregraphics.CGPathRef
	// Returns a Boolean value that indicates whether a particular point is contained in the region.
	ContainsPoint(point corefoundation.CGPoint) bool

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKRegion class.

Creating and Initializing Region Objects

Interacting with a Region

  • ISKRegion.Path: Returns a Core Graphics path that defines the region.
  • ISKRegion.ContainsPoint: Returns a Boolean value that indicates whether a particular point is contained in the region.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion

type ISKRenderer

type ISKRenderer interface {
	objectivec.IObject

	// The scene this renderer will draw into the Metal command buffer.
	Scene() ISKScene
	SetScene(value ISKScene)

	RenderWithViewportCommandBufferRenderPassDescriptor(viewport corefoundation.CGRect, commandBuffer metal.MTLCommandBuffer, renderPassDescriptor metal.MTLRenderPassDescriptor)
	RenderWithViewportRenderCommandEncoderRenderPassDescriptorCommandQueue(viewport corefoundation.CGRect, renderCommandEncoder metal.MTLRenderCommandEncoder, renderPassDescriptor metal.MTLRenderPassDescriptor, commandQueue metal.MTLCommandQueue)

	UpdateAtTime(currentTime foundation.NSTimeInterval)

	IgnoresSiblingOrder() bool
	SetIgnoresSiblingOrder(value bool)
	ShouldCullNonVisibleNodes() bool
	SetShouldCullNonVisibleNodes(value bool)

	// A Boolean value that indicates whether the view displays an overlay that shows physics bodies that are visible in the scene.
	ShowsNodeCount() bool
	SetShowsNodeCount(value bool)
	// A Boolean value that indicates whether the view displays the number of drawing passes it needed to render the view.
	ShowsDrawCount() bool
	SetShowsDrawCount(value bool)
	// A Boolean value that indicates whether the view displays the number of rectangles used to render the scene.
	ShowsQuadCount() bool
	SetShowsQuadCount(value bool)
	// A Boolean value that indicates whether the view displays physics-related debugging information.
	ShowsPhysics() bool
	SetShowsPhysics(value bool)
	// A Boolean value that indicates whether the view displays information about physics fields in the scene.
	ShowsFields() bool
	SetShowsFields(value bool)
}

An interface definition for the SKRenderer class.

First Steps

Rendering the Scene

Driving the Scene’s Update Cycle

Enabling Visual Statistics for Debugging

See: https://developer.apple.com/documentation/SpriteKit/SKRenderer

type ISKScene

type ISKScene interface {
	ISKEffectNode

	// Initializes a new scene object.
	InitWithSize(size corefoundation.CGSize) SKScene
	// The dimensions of the scene, in points.
	Size() corefoundation.CGSize
	SetSize(value corefoundation.CGSize)

	// A setting that defines how the scene is mapped to the view that presents it.
	ScaleMode() SKSceneScaleMode
	SetScaleMode(value SKSceneScaleMode)

	// The camera node in the scene that determines what part of the scene’s coordinate space is visible in the view.
	Camera() ISKCameraNode
	SetCamera(value ISKCameraNode)
	// The point in the view’s frame that corresponds to the scene’s origin.
	AnchorPoint() corefoundation.CGPoint
	SetAnchorPoint(value corefoundation.CGPoint)

	// Tells you when the scene is presented.
	SceneDidLoad()
	// Tells you when the scene’s size has changed.
	DidChangeSize(oldSize corefoundation.CGSize)
	// Tells you when the scene is about to be removed from a view.
	WillMoveFromView(view ISKView)
	// Tells you when the scene is presented by a view.
	DidMoveToView(view ISKView)

	// Tells your app to perform any app-specific logic to update your scene.
	Update(currentTime foundation.NSTimeInterval)
	// Tells your app to peform any necessary logic after scene actions are evaluated.
	DidEvaluateActions()
	// Tells your app to peform any necessary logic after physics simulations are performed.
	DidSimulatePhysics()
	// Tells your app to peform any necessary logic after constraints are applied.
	DidApplyConstraints()
	// Tells your app to peform any necessary logic after the scene has finished all of the steps required to process animations.
	DidFinishUpdate()

	// A delegate to be called during the animation loop.
	Delegate() SKSceneDelegate
	SetDelegate(value SKSceneDelegate)

	// The view that is currently presenting the scene.
	View() ISKView
	// The background color of the scene.
	BackgroundColor() appkit.NSColor
	SetBackgroundColor(value appkit.NSColor)

	// The physics simulation associated with the scene.
	PhysicsWorld() ISKPhysicsWorld

	// A node used to determine the position of the listener for positional audio in the scene.
	Listener() ISKNode
	SetListener(value ISKNode)
	// The AVFoundation audio engine used to play audio from audio nodes contained in the scene.
	AudioEngine() avfaudio.AVAudioEngine

	// Converts a point from view coordinates to scene coordinates.
	ConvertPointFromView(point corefoundation.CGPoint) corefoundation.CGPoint
	// Converts a point from scene coordinates to view coordinates.
	ConvertPointToView(point corefoundation.CGPoint) corefoundation.CGPoint
}

An interface definition for the SKScene class.

Creating a Scene Programmatically

Stretching Content to Fit the View

Configuring the Viewport

Responding to Loading and Resizing Events

Responding to Frame-Cycle Events

Configuring a Delegate

Setting the Background Appearance

Configuring Physics Properties

Adding Positional Audio

Converting Between Coordinate Systems

See: https://developer.apple.com/documentation/SpriteKit/SKScene

type ISKShader

type ISKShader interface {
	objectivec.IObject

	// Initializes a new shader object using the specified source and uniform data.
	InitWithSourceUniforms(source string, uniforms []SKUniform) SKShader
	// Initializes a new shader object using the specified source code.
	InitWithSource(source string) SKShader

	// Adds a uniform to the shader.
	AddUniform(uniform ISKUniform)
	// Removes a uniform from the shader.
	RemoveUniformNamed(name string)
	// The list of uniforms associated with the shader.
	Uniforms() []SKUniform
	SetUniforms(value []SKUniform)
	// Returns the uniform object corresponding to a particular uniform variable.
	UniformNamed(name string) ISKUniform

	// The list of attributes associated with the shader.
	Attributes() []SKAttribute
	SetAttributes(value []SKAttribute)

	// The source code for the shader.
	Source() string
	SetSource(value string)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKShader class.

Creating a Shader

Providing Uniform Data to a Shader

Providing Attribute Data to a Shader

Accessing or Setting a Shader’s Source Code

See: https://developer.apple.com/documentation/SpriteKit/SKShader

type ISKShapeNode

type ISKShapeNode interface {
	ISKNode

	// The path that defines the shape.
	Path() coregraphics.CGPathRef
	SetPath(value coregraphics.CGPathRef)

	// The color used to fill the shape.
	FillColor() appkit.NSColor
	SetFillColor(value appkit.NSColor)
	// The texture used to fill the shape.
	FillTexture() ISKTexture
	SetFillTexture(value ISKTexture)

	// The width used to stroke the path.
	LineWidth() float64
	SetLineWidth(value float64)
	// The color used to stroke the shape.
	StrokeColor() appkit.NSColor
	SetStrokeColor(value appkit.NSColor)
	// The texture used to stroke the shape.
	StrokeTexture() ISKTexture
	SetStrokeTexture(value ISKTexture)
	// A glow that extends outward from the stroked line.
	GlowWidth() float64
	SetGlowWidth(value float64)
	// The style used to render the endpoints of the stroked portion of the shape node.
	LineCap() int32
	SetLineCap(value int32)
	// The junction type used when the stroked portion of the shape node is rendered.
	LineJoin() int32
	SetLineJoin(value int32)
	// The miter limit to use when the line is stroked using a miter join style.
	MiterLimit() float64
	SetMiterLimit(value float64)
	// A Boolean value that determines whether the stroked path is smoothed when drawn.
	IsAntialiased() bool
	SetAntialiased(value bool)

	// The blend mode used to blend the shape into the parent’s framebuffer.
	BlendMode() SKBlendMode
	SetBlendMode(value SKBlendMode)

	// The length of the line defined by the shape node.
	LineLength() float64

	// A custom shader used to determine the color of the stroked portion of the shape node.
	StrokeShader() ISKShader
	SetStrokeShader(value ISKShader)
	// A custom shader used to determine the color of the filled portion of the shape node.
	FillShader() ISKShader
	SetFillShader(value ISKShader)
	// The values of each attribute associated with the node’s attached shader.
	AttributeValues() foundation.INSDictionary
	SetAttributeValues(value foundation.INSDictionary)
	// Sets an attribute value for an attached shader.
	SetValueForAttributeNamed(value ISKAttributeValue, key string)
	// The value of a shader attribute.
	ValueForAttributeNamed(key string) ISKAttributeValue
}

An interface definition for the SKShapeNode class.

Creating a Shape from a Path

Filling a Shape

Stroking a Shape

Configuring Alpha Blending

Controlling or Animating Sroke Length

Customizing Stroking or Fill Drawing

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode

type ISKSpriteNode

type ISKSpriteNode interface {
	ISKNode

	// Initializes a textured sprite using an image file.
	InitWithImageNamed(name string) SKSpriteNode

	// Initializes a textured sprite using an existing texture object.
	InitWithTexture(texture ISKTexture) SKSpriteNode
	// Initializes a textured sprite in color using an existing texture object.
	InitWithTextureColorSize(texture ISKTexture, color appkit.NSColor, size corefoundation.CGSize) SKSpriteNode
	// The texture used to draw the sprite.
	Texture() ISKTexture
	SetTexture(value ISKTexture)

	// Initializes a single-color sprite node.
	InitWithColorSize(color appkit.NSColor, size corefoundation.CGSize) SKSpriteNode

	// The dimensions of the sprite, in points.
	Size() corefoundation.CGSize
	SetSize(value corefoundation.CGSize)
	// Scales the sprite node to a specified size.
	ScaleToSize(size corefoundation.CGSize)
	// Defines the point in the sprite that corresponds to the node’s position.
	AnchorPoint() corefoundation.CGPoint
	SetAnchorPoint(value corefoundation.CGPoint)

	// Enable nine-part stretching of the sprite’s texture.
	CenterRect() corefoundation.CGRect
	SetCenterRect(value corefoundation.CGRect)

	// The sprite’s color.
	Color() appkit.NSColor
	SetColor(value appkit.NSColor)
	// A floating-point value that describes how the color is blended with the sprite’s texture.
	ColorBlendFactor() float64
	SetColorBlendFactor(value float64)

	// The blend mode used to draw the sprite into the parent’s framebuffer.
	BlendMode() SKBlendMode
	SetBlendMode(value SKBlendMode)

	// A mask that defines how this sprite is lit by light nodes in the scene.
	LightingBitMask() uint32
	SetLightingBitMask(value uint32)
	// A mask that defines which lights add shadows to the sprite.
	ShadowedBitMask() uint32
	SetShadowedBitMask(value uint32)
	// A mask that defines which lights are occluded by this sprite.
	ShadowCastBitMask() uint32
	SetShadowCastBitMask(value uint32)
	// A texture that specifies the normal map for the sprite.
	NormalTexture() ISKTexture
	SetNormalTexture(value ISKTexture)

	// A text file that defines code that does custom per-pixel drawing or colorization.
	Shader() ISKShader
	SetShader(value ISKShader)
	// The values of each attribute associated with the node’s attached shader.
	AttributeValues() foundation.INSDictionary
	SetAttributeValues(value foundation.INSDictionary)
	// Sets an attribute value for an attached shader.
	SetValueForAttributeNamed(value ISKAttributeValue, key string)
	// Sets the value of a shader attribute.
	ValueForAttributeNamed(key string) ISKAttributeValue

	// The maximum number of subdivision iterations used to generate the final vertices.
	SubdivisionLevels() int
	// The warp geometry used to define the distortion.
	WarpGeometry() ISKWarpGeometry
}

An interface definition for the SKSpriteNode class.

Creating a Sprite from an Image Filename

Creating a Sprite from a Texture

Creating a Solid-Color Sprite

Setting a Sprite’s Size and Position

Scaling a Sprite in Nine Parts

Tinting a Sprite

Configuring Alpha Blendling

Lighting a Sprite

Adding a Custom Shader to a Sprite

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode

type ISKTexture

type ISKTexture interface {
	objectivec.IObject

	// Gets the size of the texture.
	Size() corefoundation.CGSize
	// Gets a rectangle that defines the portion of the texture used to render its image.
	TextureRect() corefoundation.CGRect

	// The filtering mode used when the size of a sprite drawn with the texture is not drawn at the texture’s native size.
	FilteringMode() SKTextureFilteringMode
	SetFilteringMode(value SKTextureFilteringMode)
	// A Boolean value that indicates whether the texture attempts to generate mipmaps.
	UsesMipmaps() bool
	SetUsesMipmaps(value bool)

	// Returns the texture’s image data as a Quartz 2D image.
	CGImage() coregraphics.CGImageRef

	// Load texture data into memory, calling a completion handler after the task completes.
	PreloadWithCompletionHandler(completionHandler VoidHandler)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKTexture class.

Reading a Texture’s Size and Optional Source Location

Configuring a Texture’s Behavior for Scaling

Getting a Texture’s Underlying Image

Preloading a Texture for Performance

See: https://developer.apple.com/documentation/SpriteKit/SKTexture

type ISKTextureAtlas

type ISKTextureAtlas interface {
	objectivec.IObject

	// Creates a texture from data stored in the texture atlas.
	TextureNamed(name string) ISKTexture

	// Loads an atlas object’s textures into memory, calling a completion handler after the task completes.
	PreloadWithCompletionHandler(completionHandler VoidHandler)

	// The names of the texture images stored in the atlas.
	TextureNames() []string

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKTextureAtlas class.

Accessing Textures

Preloading Textures

Reading Source Image Filenames

See: https://developer.apple.com/documentation/SpriteKit/SKTextureAtlas

type ISKTileDefinition

type ISKTileDefinition interface {
	objectivec.IObject

	// Initializes a new tile definition with a single texture.
	InitWithTexture(texture ISKTexture) SKTileDefinition

	// Initializes a new tile definition with a single texture and separate normal texture for simulating 3D lighting.
	InitWithTextureNormalTextureSize(texture ISKTexture, normalTexture ISKTexture, size corefoundation.CGSize) SKTileDefinition

	// Initializes a new tile definition of a specified size with a single texture.
	InitWithTextureSize(texture ISKTexture, size corefoundation.CGSize) SKTileDefinition

	// Initializes a new tile definition with arrays of textures and normal textures for animation.
	InitWithTexturesNormalTexturesSizeTimePerFrame(textures []SKTexture, normalTextures []SKTexture, size corefoundation.CGSize, timePerFrame float64) SKTileDefinition
	// Initializes a new tile definition with an array of textures for animation.
	InitWithTexturesSizeTimePerFrame(textures []SKTexture, size corefoundation.CGSize, timePerFrame float64) SKTileDefinition

	// A Boolean that flips the definition’s image vertically.
	FlipHorizontally() bool
	SetFlipHorizontally(value bool)
	// A Boolean that flips the definition’s image horizontally.
	FlipVertically() bool
	SetFlipVertically(value bool)

	// The rotation of the tile definition in 90˚ increments.
	Rotation() SKTileDefinitionRotation
	SetRotation(value SKTileDefinitionRotation)

	// An array of [SKTexture](<https://developer.apple.com/documentation/SpriteKit/SKTexture>) objects that defines the tile definition object’s content.
	Textures() []SKTexture
	SetTextures(value []SKTexture)
	// An array of [SKTexture](<https://developer.apple.com/documentation/SpriteKit/SKTexture>) objects used to generate the normals for the tile to simulate 3D lighting.
	NormalTextures() []SKTexture
	SetNormalTextures(value []SKTexture)
	// The duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence.
	TimePerFrame() float64
	SetTimePerFrame(value float64)

	// A dictionary containing arbitrary data.
	UserData() foundation.INSDictionary
	SetUserData(value foundation.INSDictionary)

	// A name associated with the tile definition.
	Name() string
	SetName(value string)
	// The placement weight of the tile definition.
	PlacementWeight() uint
	SetPlacementWeight(value uint)
	// The size of the tile definition in points.
	Size() corefoundation.CGSize
	SetSize(value corefoundation.CGSize)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKTileDefinition class.

Creating a Tile with a Texture

Creating a Tile with a Normal Texture

Creating a Tile with a Size

Creating an Animated Tile

Flipping a Tile Vertically or Horizontally

Rotating a Tile

Configure Animated Tile Properties

Reading or Adding a Tile’s Custom Data

Reading or Adjusting a Tile’s Instance Properties

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition

type ISKTileGroup

type ISKTileGroup interface {
	objectivec.IObject

	// Creates and initializes a simple tile group with a single tile definition.
	InitWithTileDefinition(tileDefinition ISKTileDefinition) SKTileGroup
	// Creates and initializes a tile group with the specified tile group rules.
	InitWithRules(rules []SKTileGroupRule) SKTileGroup

	// The receiver’s name.
	Name() string
	SetName(value string)
	// An array of [SKTileGroupRule](<https://developer.apple.com/documentation/SpriteKit/SKTileGroupRule>) objects that the tile group uses to determine tile placement.
	Rules() []SKTileGroupRule
	SetRules(value []SKTileGroupRule)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKTileGroup class.

Creating Tile Groups

Accessing or Setting a Tile Group’s Properties

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroup

type ISKTileGroupRule

type ISKTileGroupRule interface {
	objectivec.IObject

	// Initializes a new tile group rule with adjacency rules and tile definitions.
	InitWithAdjacencyTileDefinitions(adjacency SKTileAdjacencyMask, tileDefinitions []SKTileDefinition) SKTileGroupRule

	// The adjacency requirement for this rule.
	Adjacency() SKTileAdjacencyMask
	SetAdjacency(value SKTileAdjacencyMask)
	// A name associated with the tile group rule.
	Name() string
	SetName(value string)
	// The tile definitions used for this rule.
	TileDefinitions() []SKTileDefinition
	SetTileDefinitions(value []SKTileDefinition)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKTileGroupRule class.

Creating a Tile Group Rule

Accessing or Setting Tile Group Rule Properties

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroupRule

type ISKTileMapNode

type ISKTileMapNode interface {
	ISKNode

	// Defines the point in the tile map that corresponds to its [position](<https://developer.apple.com/documentation/SpriteKit/SKNode/position>).
	AnchorPoint() corefoundation.CGPoint
	SetAnchorPoint(value corefoundation.CGPoint)

	// The size of each tile in points.
	TileSize() corefoundation.CGSize
	SetTileSize(value corefoundation.CGSize)
	// The tile set being used by this tile map. The tile map object can only display tiles that exist in this set.
	TileSet() ISKTileSet
	SetTileSet(value ISKTileSet)
	// The number of columns in the tile map
	NumberOfColumns() uint
	SetNumberOfColumns(value uint)
	// The number of rows in the tile map.
	NumberOfRows() uint
	SetNumberOfRows(value uint)

	CenterOfTileAtColumnRow(column uint, row uint) corefoundation.CGPoint
	TileColumnIndexFromPosition(position corefoundation.CGPoint) uint
	TileDefinitionAtColumnRow(column uint, row uint) ISKTileDefinition
	TileGroupAtColumnRow(column uint, row uint) ISKTileGroup
	// Returns the tile map node object’s tile row index for the specified position in points.
	TileRowIndexFromPosition(position corefoundation.CGPoint) uint
	// The overall size of the tile map.
	MapSize() corefoundation.CGSize

	// The base color for the tile map. The influence of the color over the tile map node’s textures is controlled by [colorBlendFactor](<https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/colorBlendFactor>).
	Color() appkit.NSColor
	SetColor(value appkit.NSColor)
	// Controls the blending between the texture and the tile map object’s [color](<https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/color>). Values are clamped between zero and one where zero has no color blending and one has the maximum color blending.
	ColorBlendFactor() float64
	SetColorBlendFactor(value float64)

	// A mask that defines how the tile map is lit by light nodes in the scene.
	LightingBitMask() uint32
	SetLightingBitMask(value uint32)

	// Defines the blend mode to use when compositing the tile map over other nodes.
	BlendMode() SKBlendMode
	SetBlendMode(value SKBlendMode)

	// Defines a shader which is applied to each tile of the tile map.
	Shader() ISKShader
	SetShader(value ISKShader)
	// The values of each attribute associated with the node’s attached shader.
	AttributeValues() foundation.INSDictionary
	SetAttributeValues(value foundation.INSDictionary)
	// Sets an attribute value for an attached shader.
	SetValueForAttributeNamed(value ISKAttributeValue, key string)
	// The value of a shader attribute.
	ValueForAttributeNamed(key string) ISKAttributeValue

	// When creating a tile map node programmatically, specifies whether the tile map uses automapping behavior like the scene editor.
	EnableAutomapping() bool
	SetEnableAutomapping(value bool)
}

An interface definition for the SKTileMapNode class.

Controlling a Tile Map’s On-Screen Position Relative to its Origin

Reading or Manually Configuring the Tile Map’s Size

Querying the Tile Map’s Properties

Tinting a Tile Map

Lighting a Tile Map

Configuring How Alpha Values Blend the Sprite

Working with Custom Shaders

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode

type ISKTileSet

type ISKTileSet interface {
	objectivec.IObject

	// Initializes a new tile set with an array of tile groups and rectangular grid layout.
	InitWithTileGroups(tileGroups []SKTileGroup) SKTileSet
	// Initializes a new tile set with an array of tile groups and specified layout.
	InitWithTileGroupsTileSetType(tileGroups []SKTileGroup, tileSetType SKTileSetType) SKTileSet

	// The tile set’s default tile group.
	DefaultTileGroup() ISKTileGroup
	SetDefaultTileGroup(value ISKTileGroup)
	// The tile set’s default tile size.
	DefaultTileSize() corefoundation.CGSize
	SetDefaultTileSize(value corefoundation.CGSize)
	// A name associated with the tile set.
	Name() string
	SetName(value string)
	// The tile set’s array of tile group objects.
	TileGroups() []SKTileGroup
	SetTileGroups(value []SKTileGroup)
	// The tile set’s type.
	Type() SKTileSetType
	SetType(value SKTileSetType)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKTileSet class.

Creating a Tile Set Programmatically

Accessing or Reading a Tile Set’s Properties

See: https://developer.apple.com/documentation/SpriteKit/SKTileSet

type ISKTransformNode

type ISKTransformNode interface {
	ISKNode

	XRotation() float64
	SetXRotation(value float64)
	YRotation() float64
	SetYRotation(value float64)
	SetEulerAngles(euler Vector_float3)
	SetRotationMatrix(rotationMatrix [3][4]float32)

	EulerAngles() Vector_float3
	RotationMatrix() [3][4]float32
}

An interface definition for the SKTransformNode class.

Rotating Child Nodes

Reading the Current Rotation

See: https://developer.apple.com/documentation/SpriteKit/SKTransformNode

type ISKTransition

type ISKTransition interface {
	objectivec.IObject

	// A Boolean value that determines whether the incoming scene is paused during the transition.
	PausesIncomingScene() bool
	SetPausesIncomingScene(value bool)
	// A Boolean value that determines whether the outgoing scene is paused during the transition.
	PausesOutgoingScene() bool
	SetPausesOutgoingScene(value bool)
}

An interface definition for the SKTransition class.

Pausing

See: https://developer.apple.com/documentation/SpriteKit/SKTransition

type ISKUniform

type ISKUniform interface {
	objectivec.IObject

	// Initializes a new uniform object.
	InitWithName(name string) SKUniform
	// Initializes a new uniform object that holds a floating-point number.
	InitWithNameFloat(name string, value float32) SKUniform
	// Initializes a new uniform object that holds a reference to a texture.
	InitWithNameTexture(name string, texture ISKTexture) SKUniform

	// The uniform’s name.
	Name() string
	// The uniform object’s data type.
	UniformType() SKUniformType

	// The receiver’s value as a floating-point value.
	FloatValue() float32
	SetFloatValue(value float32)
	// The receiver’s value as a SpriteKit texture.
	TextureValue() ISKTexture
	SetTextureValue(value ISKTexture)

	InitWithNameMatrixFloat2x2(name string, value [2][2]float32) SKUniform
	InitWithNameMatrixFloat3x3(name string, value [3][4]float32) SKUniform
	InitWithNameMatrixFloat4x4(name string, value [4][4]float32) SKUniform
	InitWithNameVectorFloat2(name string, value [2]float32) SKUniform
	InitWithNameVectorFloat3(name string, value Vector_float3) SKUniform
	InitWithNameVectorFloat4(name string, value [4]float32) SKUniform

	MatrixFloat2x2Value() [2][2]float32
	SetMatrixFloat2x2Value(value [2][2]float32)
	MatrixFloat3x3Value() [3][4]float32
	SetMatrixFloat3x3Value(value [3][4]float32)
	MatrixFloat4x4Value() [4][4]float32
	SetMatrixFloat4x4Value(value [4][4]float32)
	VectorFloat2Value() [2]float32
	SetVectorFloat2Value(value [2]float32)
	VectorFloat3Value() Vector_float3
	SetVectorFloat3Value(value Vector_float3)
	VectorFloat4Value() [4]float32
	SetVectorFloat4Value(value [4]float32)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKUniform class.

Creating and Initializing Uniform Objects

Reading Information About a Uniform

Reading and Writing an Uniform Object’s Value

Initializers

Instance Properties

See: https://developer.apple.com/documentation/SpriteKit/SKUniform

type ISKVideoNode

type ISKVideoNode interface {
	ISKNode

	// Initializes a video node using an existing [AVPlayer](<https://developer.apple.com/documentation/AVFoundation/AVPlayer>) object.
	InitWithAVPlayer(player objectivec.IObject) SKVideoNode
	// Initializes a video node using a video file stored in the app bundle.
	InitWithFileNamed(videoFile string) SKVideoNode
	// Initializes a video node using a URL.
	InitWithURL(url foundation.NSURL) SKVideoNode

	// The point in the sprite that corresponds to the node’s position.
	AnchorPoint() corefoundation.CGPoint
	SetAnchorPoint(value corefoundation.CGPoint)
	// The dimensions of the video node, in points.
	Size() corefoundation.CGSize
	SetSize(value corefoundation.CGSize)

	// Starts video playback.
	Play()
	// Pauses video playback.
	Pause()
}

An interface definition for the SKVideoNode class.

Creating a Video Node

Setting the Video Node’s Visual Properties

Controlling Video Playback

See: https://developer.apple.com/documentation/SpriteKit/SKVideoNode

type ISKView

type ISKView interface {
	appkit.INSView

	// The scene currently presented by this view.
	Scene() ISKScene
	// Presents a scene.
	PresentScene(scene ISKScene)
	// Transitions from the current scene to a new scene.
	PresentSceneTransition(scene ISKScene, transition ISKTransition)

	// A Boolean value that indicates whether the view’s scene animations are paused.
	IsPaused() bool
	SetPaused(value bool)
	// The animation frame rate that the view uses to render its scene.
	PreferredFramesPerSecond() int
	SetPreferredFramesPerSecond(value int)
	// A delegate that allows dynamic control of the view’s render rate.
	Delegate() objectivec.Object
	SetDelegate(value objectivec.Object)

	// A Boolean value that indicates whether parent-child and sibling relationships affect the rendering order of nodes in the scene.
	IgnoresSiblingOrder() bool
	SetIgnoresSiblingOrder(value bool)
	// A Boolean value that indicates whether the view automatically culls non-visible nodes from the rendering tree.
	ShouldCullNonVisibleNodes() bool
	SetShouldCullNonVisibleNodes(value bool)
	// A Boolean property that indicates whether the view is rendered using transparency.
	AllowsTransparency() bool
	SetAllowsTransparency(value bool)
	// A Boolean value that indicates whether the content is rendered asynchronously.
	IsAsynchronous() bool
	SetAsynchronous(value bool)

	// A Boolean value that indicates whether the view displays a frame rate indicator.
	ShowsFPS() bool
	SetShowsFPS(value bool)
	// A Boolean value that indicates whether the view displays an overlay that shows physics bodies that are visible in the scene.
	ShowsNodeCount() bool
	SetShowsNodeCount(value bool)
	// A Boolean value that indicates whether the view displays the number of drawing passes it needed to render the view.
	ShowsDrawCount() bool
	SetShowsDrawCount(value bool)
	// A Boolean value that indicates whether the view displays the number of rectangles used to render the scene.
	ShowsQuadCount() bool
	SetShowsQuadCount(value bool)
	// A Boolean value that indicates whether the view displays physics-related debugging information.
	ShowsPhysics() bool
	SetShowsPhysics(value bool)
	// A Boolean value that indicates whether the view displays information about physics fields in the scene.
	ShowsFields() bool
	SetShowsFields(value bool)

	// Converts a point from scene coordinates to view coordinates.
	ConvertPointFromScene(point corefoundation.CGPoint, scene ISKScene) corefoundation.CGPoint
	// Converts a point from view coordinates to scene coordinates.
	ConvertPointToScene(point corefoundation.CGPoint, scene ISKScene) corefoundation.CGPoint

	// Renders a portion of a node’s contents and returns the rendered image as a texture.
	TextureFromNodeCrop(node ISKNode, crop corefoundation.CGRect) ISKTexture
	// Renders the contents of a node tree and returns the rendered image as a texture.
	TextureFromNode(node ISKNode) ISKTexture

	DisableDepthStencilBuffer() bool
	SetDisableDepthStencilBuffer(value bool)
}

An interface definition for the SKView class.

Displaying a Scene

Controlling the Timing of a Scene’s Rendering

Enabling Visual Statistics for Debugging

Converting Between View and Scene Coordinates

Snapshotting Nodes to a Texture

Instance Properties

See: https://developer.apple.com/documentation/SpriteKit/SKView

type ISKWarpGeometry

type ISKWarpGeometry interface {
	objectivec.IObject

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the SKWarpGeometry class.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpGeometry

type ISKWarpGeometryGrid

type ISKWarpGeometryGrid interface {
	ISKWarpGeometry

	// The object’s number of columns.
	NumberOfColumns() int
	// The object’s number of rows.
	NumberOfRows() int
	// The object’s total number of vertices.
	VertexCount() int

	// Returns the destination position of a vertex.
	DestPositionAtIndex(index int) [2]float32
	// Returns the source position of a vertex.
	SourcePositionAtIndex(index int) [2]float32
}

An interface definition for the SKWarpGeometryGrid class.

Accessing or Setting Warp Geometry Grid Size

Accessing or Setting Grid Vertices

See: https://developer.apple.com/documentation/SpriteKit/SKWarpGeometryGrid

type SKAction

type SKAction struct {
	objectivec.Object
}

An object that is run by a node to change its structure or content.

Overview

SKAction is an animation that is executed by a node in the scene. Actions are used to change a node in some way (like move its position over time), but you can also use actions to change the scene, like doing a fadeout. When the scene processes its nodes, the actions associated with those nodes are processed.

Controlling Action Timing

See: https://developer.apple.com/documentation/SpriteKit/SKAction

func NewSKAction

func NewSKAction() SKAction

NewSKAction creates a new SKAction instance.

func SKActionFromID

func SKActionFromID(id objc.ID) SKAction

SKActionFromID constructs a SKAction from an objc.ID.

An object that is run by a node to change its structure or content.

func (SKAction) Autorelease

func (a SKAction) Autorelease() SKAction

Autorelease adds the receiver to the current autorelease pool.

func (SKAction) Duration

func (a SKAction) Duration() foundation.NSTimeInterval

The duration required to complete an action.

Discussion

This is the expected duration of an action’s animation. The actual time an action takes to complete is modified by the SKAction.Speed property of the action and the SKNode.Speed property of the node on which it executes.

See: https://developer.apple.com/documentation/SpriteKit/SKAction/duration

func (SKAction) EncodeWithCoder

func (a SKAction) EncodeWithCoder(coder foundation.INSCoder)

func (SKAction) Init

func (a SKAction) Init() SKAction

Init initializes the instance.

func (SKAction) SetDuration

func (a SKAction) SetDuration(value foundation.NSTimeInterval)

func (SKAction) SetSpeed

func (a SKAction) SetSpeed(value float64)

func (SKAction) SetTimingFunction

func (a SKAction) SetTimingFunction(value Float32Float32Handler)

func (SKAction) SetTimingMode

func (a SKAction) SetTimingMode(value SKActionTimingMode)

func (SKAction) Speed

func (a SKAction) Speed() float64

A speed factor that modifies how fast an action runs.

Discussion

The speed factor adjusts how fast an action’s animation runs. For example, a speed factor of `2.0` means the animation runs twice as fast.

See: https://developer.apple.com/documentation/SpriteKit/SKAction/speed

func (SKAction) TimingFunction

func (a SKAction) TimingFunction() Float32Float32Handler

A block used to customize the timing function.

Discussion

If a timing function is provided, after the normal timing mode is applied, the result is sent to the timing function. The return SKActionTimingFunction value of the timing function determines the actual time used to perform the animation.

The following code shows how you can create a custom timing function using simd_smoothstep(_:_:_:) interpolation:

If the above code is combined with a vertical linear move action, the path taken by a node running this action describes the curve illustrated below:

[media-2759776]

See: https://developer.apple.com/documentation/SpriteKit/SKAction/timingFunction

func (SKAction) TimingMode

func (a SKAction) TimingMode() SKActionTimingMode

A setting that controls the speed curve of an animation.

Discussion

The possible values for this property are listed in SKActionTimingMode. The default value is SKActionTimingMode.linear.

See: https://developer.apple.com/documentation/SpriteKit/SKAction/timingMode

type SKActionClass

type SKActionClass struct {
	// contains filtered or unexported fields
}

func GetSKActionClass

func GetSKActionClass() SKActionClass

GetSKActionClass returns the class object for SKAction.

func (SKActionClass) Alloc

func (sc SKActionClass) Alloc() SKAction

Alloc allocates memory for a new instance of the class.

func (SKActionClass) Class

func (sc SKActionClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKActionTimingFunction

type SKActionTimingFunction = func(float32) float32

SKActionTimingFunction is the signature for the custom timing block.

See: https://developer.apple.com/documentation/SpriteKit/SKActionTimingFunction

type SKActionTimingMode

type SKActionTimingMode int

See: https://developer.apple.com/documentation/SpriteKit/SKActionTimingMode

const (
	// SKActionTimingEaseIn: Specifies ease-in pacing.
	SKActionTimingEaseIn SKActionTimingMode = 1
	// SKActionTimingEaseInEaseOut: Specifies ease-in ease-out pacing.
	SKActionTimingEaseInEaseOut SKActionTimingMode = 3
	// SKActionTimingEaseOut: Specifies ease-out pacing.
	SKActionTimingEaseOut SKActionTimingMode = 2
	// SKActionTimingLinear: Specifies linear pacing.
	SKActionTimingLinear SKActionTimingMode = 0
)

func (SKActionTimingMode) String

func (e SKActionTimingMode) String() string

type SKAttribute

type SKAttribute struct {
	objectivec.Object
}

A specification for dynamic per-node data used with a custom shader.

Overview

To define an attribute for your shader, you create an SKAttribute object with a unique name and data type, which is a SKAttributeType enum. After creating an SKShader object, custom attributes are added to its SKShader.Attributes array. Attribute values are set on the parent node with setValue(_:forAttribute:) and can change for each execution of a shader without the need for recompilation.

The following listing shows how you can use an attribute to pass the size of a sprite into a shader using an attribute. In this example, `a_sprite_size` is available as a global `vec2` within the GLSL code.

Listing 1. Passing an attribute to a shader.

Initializers

  • SKAttribute.InitWithNameType: Creates and initializes a new attribute object of a specified type with a name that can be referenced within the shader.

Instance Properties

See: https://developer.apple.com/documentation/SpriteKit/SKAttribute

func NewAttributeWithNameType

func NewAttributeWithNameType(name string, type_ SKAttributeType) SKAttribute

Creates and initializes a new attribute object of a specified type with a name that can be referenced within the shader.

name: The name of the attribute.

type: The type of the attribute.

Return Value

A new attribute object.

Discussion

Attribute names are typically named with a preceding “a” and an underscore. The following code shows how to initialize an attribute named `a_frequency` which is of type SKAttributeType.float.

See: https://developer.apple.com/documentation/SpriteKit/SKAttribute/init(name:type:)

func NewSKAttribute

func NewSKAttribute() SKAttribute

NewSKAttribute creates a new SKAttribute instance.

func SKAttributeFromID

func SKAttributeFromID(id objc.ID) SKAttribute

SKAttributeFromID constructs a SKAttribute from an objc.ID.

A specification for dynamic per-node data used with a custom shader.

func (SKAttribute) Autorelease

func (a SKAttribute) Autorelease() SKAttribute

Autorelease adds the receiver to the current autorelease pool.

func (SKAttribute) EncodeWithCoder

func (a SKAttribute) EncodeWithCoder(coder foundation.INSCoder)

func (SKAttribute) Init

func (a SKAttribute) Init() SKAttribute

Init initializes the instance.

func (SKAttribute) InitWithNameType

func (a SKAttribute) InitWithNameType(name string, type_ SKAttributeType) SKAttribute

Creates and initializes a new attribute object of a specified type with a name that can be referenced within the shader.

name: The name of the attribute.

type: The type of the attribute.

Return Value

A new attribute object.

Discussion

Attribute names are typically named with a preceding “a” and an underscore. The following code shows how to initialize an attribute named `a_frequency` which is of type SKAttributeType.float.

See: https://developer.apple.com/documentation/SpriteKit/SKAttribute/init(name:type:)

func (SKAttribute) Name

func (a SKAttribute) Name() string

The receiver’s name

See: https://developer.apple.com/documentation/SpriteKit/SKAttribute/name

func (SKAttribute) Type

func (a SKAttribute) Type() SKAttributeType

The data type of the attribute’s value.

See: https://developer.apple.com/documentation/SpriteKit/SKAttribute/type

type SKAttributeClass

type SKAttributeClass struct {
	// contains filtered or unexported fields
}

func GetSKAttributeClass

func GetSKAttributeClass() SKAttributeClass

GetSKAttributeClass returns the class object for SKAttribute.

func (SKAttributeClass) Alloc

func (sc SKAttributeClass) Alloc() SKAttribute

Alloc allocates memory for a new instance of the class.

func (SKAttributeClass) Class

func (sc SKAttributeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKAttributeType

type SKAttributeType int

See: https://developer.apple.com/documentation/SpriteKit/SKAttributeType

const (
	SKAttributeTypeFloat            SKAttributeType = 1
	SKAttributeTypeHalfFloat        SKAttributeType = 5
	SKAttributeTypeNone             SKAttributeType = 0
	SKAttributeTypeVectorFloat2     SKAttributeType = 2
	SKAttributeTypeVectorFloat3     SKAttributeType = 3
	SKAttributeTypeVectorFloat4     SKAttributeType = 4
	SKAttributeTypeVectorHalfFloat2 SKAttributeType = 6
	SKAttributeTypeVectorHalfFloat3 SKAttributeType = 7
	SKAttributeTypeVectorHalfFloat4 SKAttributeType = 8
)

func (SKAttributeType) String

func (e SKAttributeType) String() string

type SKAttributeValue

type SKAttributeValue struct {
	objectivec.Object
}

A container for dynamic shader data associated with a node.

Overview

SpriteKit nodes that are rendered with a custom shader can use SKAttributeValue objects to pass dynamic values which can change without requiring that shader to be recompiled. An attribute value is passed to a shader using a node’s setValue(_:forAttribute:) method using the relevant attribute’s name. For example, given a shader with a SKAttributeType.float attribute named `a_radius`:

Listing 1. Creating an attribute

The following code sets the value of this attribute to `10` and passes it to a SKSpriteNode object’s shader:

Listing 2. Setting an attribute value

The attribute, `a_radius`, is available as a global floating-point variable within the shader code.

Using this technique, a single shader can be shared across many nodes and each nodes can supply its own attributes. This approach is an alternative to using SKUniform objects which would require a recompilation for each distinct set of parameters.

Instance Properties

See: https://developer.apple.com/documentation/SpriteKit/SKAttributeValue

func NewAttributeValueWithFloat

func NewAttributeValueWithFloat(value float32) SKAttributeValue

Creates and initializes a new attribute value object that holds a floating point number.

value: The floating point value for the new attribute value.

Return Value

A new attribute value object.

See: https://developer.apple.com/documentation/SpriteKit/SKAttributeValue/init(float:)

func NewAttributeValueWithVectorFloat2

func NewAttributeValueWithVectorFloat2(value [2]float32) SKAttributeValue

Creates and initializes a new attribute value object that holds a vector of two floating point numbers.

value: The vector of two point values for the new attribute value.

Return Value

A new attribute value object.

See: https://developer.apple.com/documentation/SpriteKit/SKAttributeValue/init(vectorFloat2:)

func NewAttributeValueWithVectorFloat3

func NewAttributeValueWithVectorFloat3(value Vector_float3) SKAttributeValue

Creates and initializes a new attribute value object that holds a vector of three floating point numbers.

value: The vector of three point values for the new attribute value.

Return Value

A new attribute value object.

See: https://developer.apple.com/documentation/SpriteKit/SKAttributeValue/init(vectorFloat3:)

func NewAttributeValueWithVectorFloat4

func NewAttributeValueWithVectorFloat4(value [4]float32) SKAttributeValue

Creates and initializes a new attribute value object that holds a vector of four floating point numbers.

value: The vector of four point values for the new attribute value.

Return Value

A new attribute value object.

See: https://developer.apple.com/documentation/SpriteKit/SKAttributeValue/init(vectorFloat4:)

func NewSKAttributeValue

func NewSKAttributeValue() SKAttributeValue

NewSKAttributeValue creates a new SKAttributeValue instance.

func SKAttributeValueFromID

func SKAttributeValueFromID(id objc.ID) SKAttributeValue

SKAttributeValueFromID constructs a SKAttributeValue from an objc.ID.

A container for dynamic shader data associated with a node.

func (SKAttributeValue) Autorelease

func (a SKAttributeValue) Autorelease() SKAttributeValue

Autorelease adds the receiver to the current autorelease pool.

func (SKAttributeValue) EncodeWithCoder

func (a SKAttributeValue) EncodeWithCoder(coder foundation.INSCoder)

func (SKAttributeValue) FloatValue

func (a SKAttributeValue) FloatValue() float32

The receiver’s floating point value.

Discussion

If the receiver’s original value is a vector, SKAttributeValue.FloatValue is the first element of the vector.

See: https://developer.apple.com/documentation/SpriteKit/SKAttributeValue/floatValue

func (SKAttributeValue) Init

Init initializes the instance.

func (SKAttributeValue) SetFloatValue

func (a SKAttributeValue) SetFloatValue(value float32)

func (SKAttributeValue) SetVectorFloat2Value

func (a SKAttributeValue) SetVectorFloat2Value(value [2]float32)

func (SKAttributeValue) SetVectorFloat3Value

func (a SKAttributeValue) SetVectorFloat3Value(value Vector_float3)

func (SKAttributeValue) SetVectorFloat4Value

func (a SKAttributeValue) SetVectorFloat4Value(value [4]float32)

func (SKAttributeValue) VectorFloat2Value

func (a SKAttributeValue) VectorFloat2Value() [2]float32

The receiver’s value as a vector of two floating-point numbers.

Discussion

If the receiver’s original value is a floating-point number, the second item of the vector is set to 0. If the receiver’s original value is a vector of more than two items, the additional items are truncated.

See: https://developer.apple.com/documentation/SpriteKit/SKAttributeValue/vectorFloat2Value

func (SKAttributeValue) VectorFloat3Value

func (a SKAttributeValue) VectorFloat3Value() Vector_float3

The receiver’s value as a vector of three floating point numbers.

Discussion

If the receiver’s original value is a floating-point number or a vector_float2, the empty items in the vector are set to 0. If the receiver’s original value is a vector_float4, the last item is truncated.

See: https://developer.apple.com/documentation/SpriteKit/SKAttributeValue/vectorFloat3Value

func (SKAttributeValue) VectorFloat4Value

func (a SKAttributeValue) VectorFloat4Value() [4]float32

The receiver’s value as a vector of four floating point numbers.

Discussion

If the receiver’s original value is a floating-point number of a vector with a count less than four, the empty items in the vector are set to 0.

See: https://developer.apple.com/documentation/SpriteKit/SKAttributeValue/vectorFloat4Value

type SKAttributeValueClass

type SKAttributeValueClass struct {
	// contains filtered or unexported fields
}

func GetSKAttributeValueClass

func GetSKAttributeValueClass() SKAttributeValueClass

GetSKAttributeValueClass returns the class object for SKAttributeValue.

func (SKAttributeValueClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKAttributeValueClass) Class

func (sc SKAttributeValueClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKAudioNode

type SKAudioNode struct {
	SKNode
}

A node that plays audio.

Overview

A SKAudioNode object is used to add an audio to a scene. The sounds are played automatically using AVFoundation, and the node can optionally add 3D spatial audio effects to the audio when it is played.

The currently presented SKScene object mixes the audio from nodes in the scene based on parameters defined in the AVAudio3DMixing protocol. A scene’s SKScene.AudioEngine property allows overall control of volume and playback.

By default, SKAudioNode objects are positional, i.e. their [SKAudioNode.Positional] property is set to true. If you add an audio node to a scene with a SKScene.Listener set, SpriteKit will set the stereo balance and the volume based on the relative positions of the two nodes.

You can explicitly set the volume or stereo balance to an audio node by running actions on it.

SpriteKit includes actions that reduce an audio node’s volume by changing either its occlusion or obstruction. The difference between these actions is that occlusion affects both the direct and reverb paths of the sound while obstruction only affects the direct path. The change volume action offers absolute control over an audio node’s volume.

You can manually set the stereo balance of an audio node with a stereo pan action.

Special effects, such as speeding up or slowing down audio by changing the playback rate and adding reverb are also available as audio actions.

To learn more about audio actions, see Controlling the Audio of a Node in Action Initializers.

Initializing Audio Nodes

Configuring Audio Nodes

See: https://developer.apple.com/documentation/SpriteKit/SKAudioNode

func NewAudioNodeWithAVAudioNode

func NewAudioNodeWithAVAudioNode(node avfaudio.AVAudioNode) SKAudioNode

Initializes an audio node from an AVFoundation audio node.

node: An AVAudioNode object that holds an AVAudioEngine sound graph from a single sound source or URL.

Return Value

A newly initialized audio node.

See: https://developer.apple.com/documentation/SpriteKit/SKAudioNode/init(avAudioNode:)

func NewAudioNodeWithCoder

func NewAudioNodeWithCoder(aDecoder foundation.INSCoder) SKAudioNode

Tells you when to initialize an audio node that has been unarchived.

Discussion

Do not call this initializer directly; it’s called by the system when you should initialize an audio node that has been unarchived.

See: https://developer.apple.com/documentation/SpriteKit/SKAudioNode/init(coder:)

func NewAudioNodeWithFileNamed

func NewAudioNodeWithFileNamed(name string) SKAudioNode

Initializes an audio node from an audio asset with the specified filename.

name: A file containing an AVAudioNode.

Return Value

A newly initialized audio node.

Discussion

The named file containing the audio asset must reside within the main bundle.

See: https://developer.apple.com/documentation/SpriteKit/SKAudioNode/init(fileNamed:)

func NewAudioNodeWithURL

func NewAudioNodeWithURL(url foundation.NSURL) SKAudioNode

Initializes an audio node from an audio asset with the specified URL.

url: The URL of an audio file.

Return Value

A newly initialized audio node.

See: https://developer.apple.com/documentation/SpriteKit/SKAudioNode/init(url:)

func NewSKAudioNode

func NewSKAudioNode() SKAudioNode

NewSKAudioNode creates a new SKAudioNode instance.

func SKAudioNodeFromID

func SKAudioNodeFromID(id objc.ID) SKAudioNode

SKAudioNodeFromID constructs a SKAudioNode from an objc.ID.

A node that plays audio.

func (SKAudioNode) AutoplayLooped

func (a SKAudioNode) AutoplayLooped() bool

A Boolean value that indicates whether the audio should play in a loop when the node is added to the scene.

Discussion

If the property value is true, then the audio starts playing as soon as the node is added to the scene, and repeats after it completes. If false, then the audio node’s content never plays automatically. It must be explicitly scheduled using the scene’s audio engine. The default value is true.

See: https://developer.apple.com/documentation/SpriteKit/SKAudioNode/autoplayLooped

func (SKAudioNode) Autorelease

func (a SKAudioNode) Autorelease() SKAudioNode

Autorelease adds the receiver to the current autorelease pool.

func (SKAudioNode) AvAudioNode

func (a SKAudioNode) AvAudioNode() avfaudio.AVAudioNode

The audio node’s current audio asset.

Discussion

The AV audio node must refer to an AVAudioEngine sound graph from a single sound source or URL.

See: https://developer.apple.com/documentation/SpriteKit/SKAudioNode/avAudioNode

func (SKAudioNode) Init

func (a SKAudioNode) Init() SKAudioNode

Init initializes the instance.

func (SKAudioNode) InitWithAVAudioNode

func (a SKAudioNode) InitWithAVAudioNode(node avfaudio.AVAudioNode) SKAudioNode

Initializes an audio node from an AVFoundation audio node.

node: An AVAudioNode object that holds an AVAudioEngine sound graph from a single sound source or URL.

Return Value

A newly initialized audio node.

See: https://developer.apple.com/documentation/SpriteKit/SKAudioNode/init(avAudioNode:)

func (SKAudioNode) InitWithFileNamed

func (a SKAudioNode) InitWithFileNamed(name string) SKAudioNode

Initializes an audio node from an audio asset with the specified filename.

name: A file containing an AVAudioNode.

Return Value

A newly initialized audio node.

Discussion

The named file containing the audio asset must reside within the main bundle.

See: https://developer.apple.com/documentation/SpriteKit/SKAudioNode/init(fileNamed:)

func (SKAudioNode) InitWithURL

func (a SKAudioNode) InitWithURL(url foundation.NSURL) SKAudioNode

Initializes an audio node from an audio asset with the specified URL.

url: The URL of an audio file.

Return Value

A newly initialized audio node.

See: https://developer.apple.com/documentation/SpriteKit/SKAudioNode/init(url:)

func (SKAudioNode) IsPositional

func (a SKAudioNode) IsPositional() bool

A Boolean property that indicates whether the node’s audio is altered based on the position of the node.

Discussion

If true, the audio mixer considers the position and velocity of the SKAudioNode relative to scene’s current SKScene.Listener node. The mixer applies distance attenuation, doppler shift, and pan effects to the sound. If false, then the sound is played normally. The default value is true.

See: https://developer.apple.com/documentation/SpriteKit/SKAudioNode/isPositional

func (SKAudioNode) SetAutoplayLooped

func (a SKAudioNode) SetAutoplayLooped(value bool)

func (SKAudioNode) SetAvAudioNode

func (a SKAudioNode) SetAvAudioNode(value avfaudio.AVAudioNode)

func (SKAudioNode) SetPositional

func (a SKAudioNode) SetPositional(value bool)

type SKAudioNodeClass

type SKAudioNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKAudioNodeClass

func GetSKAudioNodeClass() SKAudioNodeClass

GetSKAudioNodeClass returns the class object for SKAudioNode.

func (SKAudioNodeClass) Alloc

func (sc SKAudioNodeClass) Alloc() SKAudioNode

Alloc allocates memory for a new instance of the class.

func (SKAudioNodeClass) Class

func (sc SKAudioNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKBlendMode

type SKBlendMode int

See: https://developer.apple.com/documentation/SpriteKit/SKBlendMode

const (
	// SKBlendModeAdd: The source and destination colors are added together.
	SKBlendModeAdd SKBlendMode = 1
	// SKBlendModeAlpha: The source and destination colors are blended by multiplying the source alpha value.
	SKBlendModeAlpha SKBlendMode = 0
	// SKBlendModeMultiply: The source color is multiplied by the destination color.
	SKBlendModeMultiply      SKBlendMode = 3
	SKBlendModeMultiplyAlpha SKBlendMode = 7
	// SKBlendModeMultiplyX2: The source color is multiplied by the destination color and then doubled.
	SKBlendModeMultiplyX2 SKBlendMode = 4
	// SKBlendModeReplace: The source color replaces the destination color.
	SKBlendModeReplace SKBlendMode = 6
	// SKBlendModeScreen: The source color is added to the destination color times the inverted source color.
	SKBlendModeScreen SKBlendMode = 5
	// SKBlendModeSubtract: The source color is subtracted from the destination color.
	SKBlendModeSubtract SKBlendMode = 2
)

func (SKBlendMode) String

func (e SKBlendMode) String() string

type SKCameraNode

type SKCameraNode struct {
	SKNode
}

A node that determines which parts of the scene are visible within a view.

Overview

If you don’t use a camera in your scene, you control the visible portion of a scene using its SKScene.AnchorPoint property.

Node Visibility

See: https://developer.apple.com/documentation/SpriteKit/SKCameraNode

func NewCameraNodeWithCoder

func NewCameraNodeWithCoder(aDecoder foundation.INSCoder) SKCameraNode

Called when a node is initialized from an .sks file.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(coder:)

func NewCameraNodeWithFileNamed

func NewCameraNodeWithFileNamed(filename string) SKCameraNode

Creates a new node by loading an archive file from the game’s main bundle.

filename: The name of the file, without a file extension. The file must be in the app’s main bundle and have a `XCUIElementTypeSks` filename extension.

Return Value

The unarchived node object.

Discussion

If you call this method on a subclass of the SKScene class and the object in the archive is an SKScene object, the returned object is initialized as if it is a member of the subclass. You use this behavior to create scene layouts in the Xcode Editor and provide custom behaviors in your subclass.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(fileNamed:)

func NewSKCameraNode

func NewSKCameraNode() SKCameraNode

NewSKCameraNode creates a new SKCameraNode instance.

func SKCameraNodeFromID

func SKCameraNodeFromID(id objc.ID) SKCameraNode

SKCameraNodeFromID constructs a SKCameraNode from an objc.ID.

A node that determines which parts of the scene are visible within a view.

func (SKCameraNode) Autorelease

func (c SKCameraNode) Autorelease() SKCameraNode

Autorelease adds the receiver to the current autorelease pool.

func (SKCameraNode) ContainedNodeSet

func (c SKCameraNode) ContainedNodeSet() foundation.INSSet

Finds nodes that are visible in the camera’s viewport.

Return Value

The set of nodes that are in the same scene as the camera and contained in the camera’s viewport.

Discussion

The camera must be part of a scene’s node hierarchy and the scene must be presented in an view.

See: https://developer.apple.com/documentation/SpriteKit/SKCameraNode/containedNodeSet()

func (SKCameraNode) ContainsNode

func (c SKCameraNode) ContainsNode(node ISKNode) bool

Checks to see if a node is visible in the camera’s viewport.

node: An SKNode object.

Return Value

true if the node in the same scene and inside the camera’s viewport; otherwise false.

Discussion

The camera must be part of a scene’s node hierarchy and the scene must be presented in an view.

See: https://developer.apple.com/documentation/SpriteKit/SKCameraNode/contains(_:)

func (SKCameraNode) Init

func (c SKCameraNode) Init() SKCameraNode

Init initializes the instance.

type SKCameraNodeClass

type SKCameraNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKCameraNodeClass

func GetSKCameraNodeClass() SKCameraNodeClass

GetSKCameraNodeClass returns the class object for SKCameraNode.

func (SKCameraNodeClass) Alloc

func (sc SKCameraNodeClass) Alloc() SKCameraNode

Alloc allocates memory for a new instance of the class.

func (SKCameraNodeClass) Class

func (sc SKCameraNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKConstraint

type SKConstraint struct {
	objectivec.Object
}

A specification for constraining a node’s position or rotation.

Overview

An SKConstraint object describes a mathematical constraint on a node’s position or orientation. You attach constraints to nodes; after a scene processes any actions and physics interactions, it applies constraints attached to nodes in its node tree. Use constraints to ensure that certain relationships are true before the system renders a scene. For example, you might use a constraint to:

- Change a node’s SKNode.ZRotation property so that it always points at another node or a position in the scene. - Keep a node within a specified distance of another node or a point in the scene. - Keep a node inside a specified rectangle. - Restrict the SKNode.ZRotation property of a node so that it has a more limited rotation range of motion.

To use constraints, create an NSArray object that contains one or more constraint objects and assign the array to a node’s SKNode.Constraints property. When the system evaluates a scene, it executes the constraints on a node in the order they appear in the SKNode.Constraints array.

You can’t change a constraint after you create it. However, you can selectively disable or enable a constraint by setting its SKConstraint.Enabled property. You can also use the SKConstraint.ReferenceNode property to convert positions to the referenced coordinate system before applying the constraint.

Controlling the Coordinate System Where a Constraint is Applied

Enabling and Disabling a Constraint

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint

func NewSKConstraint

func NewSKConstraint() SKConstraint

NewSKConstraint creates a new SKConstraint instance.

func SKConstraintFromID

func SKConstraintFromID(id objc.ID) SKConstraint

SKConstraintFromID constructs a SKConstraint from an objc.ID.

A specification for constraining a node’s position or rotation.

func (SKConstraint) Autorelease

func (c SKConstraint) Autorelease() SKConstraint

Autorelease adds the receiver to the current autorelease pool.

func (SKConstraint) Enabled

func (c SKConstraint) Enabled() bool

A Boolean value that specifies whether the constraint is applied.

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint/enabled

func (SKConstraint) EncodeWithCoder

func (c SKConstraint) EncodeWithCoder(coder foundation.INSCoder)

func (SKConstraint) Init

func (c SKConstraint) Init() SKConstraint

Init initializes the instance.

func (SKConstraint) ReferenceNode

func (c SKConstraint) ReferenceNode() ISKNode

The node whose coordinate system should be used to apply the constraint.

Discussion

The default value is `nil`, meaning that the coordinate system of the node’s parent is used to apply the constraint. If another node is specified, all positions are converted into this node’s coordinate system before the constraint is applied.

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint/referenceNode

func (SKConstraint) SetEnabled

func (c SKConstraint) SetEnabled(value bool)

func (SKConstraint) SetReferenceNode

func (c SKConstraint) SetReferenceNode(value ISKNode)

type SKConstraintClass

type SKConstraintClass struct {
	// contains filtered or unexported fields
}

func GetSKConstraintClass

func GetSKConstraintClass() SKConstraintClass

GetSKConstraintClass returns the class object for SKConstraint.

func (SKConstraintClass) Alloc

func (sc SKConstraintClass) Alloc() SKConstraint

Alloc allocates memory for a new instance of the class.

func (SKConstraintClass) Class

func (sc SKConstraintClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (SKConstraintClass) DistanceToNode

func (_SKConstraintClass SKConstraintClass) DistanceToNode(range_ ISKRange, node ISKNode) SKConstraint

Creates a constraint that keeps a node within a certain distance of another node.

range: The range of allowed distances between the two nodes.

node: The target node used to calculate the distance.

Return Value

A new constraint.

Discussion

Distance constraints constrain a node to a specified distance range of another node or a point and can be used for effects such a simulating flocking around a node, repulsive fields and trails. Supplying a distance constraint with a range with a lower limit, an upper limit or both results in very different behaviors:

[Table data omitted]

Each time when constraints are applied, a line is projected between the node’s position and the target node’s position. The distance between the two points is calculated, and if it lies outside the specified range, the node is pushed or pulled along this line until it lies within the range.

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint/distance(_:to:)-6507j

func (SKConstraintClass) DistanceToPoint

func (_SKConstraintClass SKConstraintClass) DistanceToPoint(range_ ISKRange, point corefoundation.CGPoint) SKConstraint

Creates a constraint that keeps a node within a certain distance of a point.

range: The range of allowed distances between the node and the point.

point: A point in the coordinate system of the node’s parent that is used to calculate the distance.

Return Value

A new constraint.

Discussion

Each time when constraints are applied, a line is projected between the node’s position and the target point. The distance between the two points is calculated, and if it lies outside the specified range, the node is pushed or pulled along this line until it lies within the range.

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint/distance(_:to:)-7yk7n

func (SKConstraintClass) DistanceToPointInNode

func (_SKConstraintClass SKConstraintClass) DistanceToPointInNode(range_ ISKRange, point corefoundation.CGPoint, node ISKNode) SKConstraint

Creates a constraint that keeps a node within a certain distance of a point in another node’s coordinate system.

range: The range of allowed distances.

point: The point to use as the target point.

node: The node whose coordinate system the point is specified in.

Return Value

A new constraint.

Discussion

Each time when constraints are applied, a line is projected between the node’s position and the target point. The distance between the two points is calculated, and if it lies outside the specified range, the node is pushed or pulled along this line until it lies within the range.

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint/distance(_:to:in:)

func (SKConstraintClass) OrientToNodeOffset

func (_SKConstraintClass SKConstraintClass) OrientToNodeOffset(node ISKNode, radians ISKRange) SKConstraint

Creates a constraint that forces a node to rotate to face another node.

node: The node that should be used to orient the node that this constraint is attached to.

radians: An offset that is added to the SKNode.ZRotation value after it is calculated.

Return Value

A new constraint.

Discussion

Each time when constraints are applied, a new angle is calculated so that a line projected at this angle would point at the other node’s origin. This angle is added to the values specified in the `radians` property to create a new range. Finally, the node’s SKNode.ZRotation value is clamped to fit inside this range.

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint/orient(to:offset:)-1h1tw

func (SKConstraintClass) OrientToPointInNodeOffset

func (_SKConstraintClass SKConstraintClass) OrientToPointInNodeOffset(point corefoundation.CGPoint, node ISKNode, radians ISKRange) SKConstraint

Creates a constraint that forces a node to rotate to face a point in another node’s coordinate system.

point: A point in the `node` parameter’s coordinate system.

node: The node whose coordinate system the point is specified in.

radians: An offset that is added to the SKNode.ZRotation value after it is calculated.

Return Value

A new constraint.

Discussion

Each time when constraints are applied, a new angle is calculated so that a line projected at this angle would point at the target point. This angle is added to the values specified in the `radians` property to create a new range. Finally, the node’s SKNode.ZRotation value is clamped to fit inside this range.

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint/orient(to:in:offset:)

func (SKConstraintClass) OrientToPointOffset

func (_SKConstraintClass SKConstraintClass) OrientToPointOffset(point corefoundation.CGPoint, radians ISKRange) SKConstraint

Creates a constraint that forces a node to rotate to face a fixed point.

point: A point in the node’s parent’s coordinate system.

radians: An offset that is added to the SKNode.ZRotation value after it is calculated.

Return Value

A new constraint.

Discussion

Each time when constraints are applied, a new angle is calculated so that a line projected at this angle would point at the target point. This angle is added to the values specified in the `radians` property to create a new range. Finally, the node’s SKNode.ZRotation value is clamped to fit inside this range.

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint/orient(to:offset:)-9lq3h

func (SKConstraintClass) PositionX

func (_SKConstraintClass SKConstraintClass) PositionX(range_ ISKRange) SKConstraint

Creates a constraint that restricts the x-coordinate of a node’s position.

range: The range to restrict the coordinate to.

Return Value

A new constraint.

Discussion

Each time constraints are applied, the x-coordinate of the node’s SKNode.Position property is clamped so that it lies inside the specified range.

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint/positionX(_:)

func (SKConstraintClass) PositionXY

func (_SKConstraintClass SKConstraintClass) PositionXY(xRange ISKRange, yRange ISKRange) SKConstraint

Creates a constraint that restricts both coordinates of a node’s position.

xRange: The range to restrict the x-coordinate to.

yRange: The range to restrict the y-coordinate to.

Return Value

A new constraint.

Discussion

Each time constraints are applied, the node’s SKNode.Position property is clamped so that both coordinates lie inside the specified ranges.

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint/positionX(_:y:)

func (SKConstraintClass) PositionY

func (_SKConstraintClass SKConstraintClass) PositionY(range_ ISKRange) SKConstraint

Creates a constraint that restricts the y-coordinate of a node’s position.

range: The range to restrict the coordinate to.

Return Value

A new constraint.

Discussion

Each time when constraints are applied, the y-coordinate of the node’s SKNode.Position property is clamped so that it lies inside the specified range.

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint/positionY(_:)

func (SKConstraintClass) ZRotation

func (_SKConstraintClass SKConstraintClass) ZRotation(zRange ISKRange) SKConstraint

Creates a constraint that limits the orientation of a node.

zRange: A range value that specifies the minimum and maximum values of the node’s SKNode.ZRotation property.

Return Value

A new constraint.

Discussion

Each time when constraints are applied, the node’s SKNode.ZRotation property is clamped so that it is within the specified range.

See: https://developer.apple.com/documentation/SpriteKit/SKConstraint/zRotation(_:)

type SKCropNode

type SKCropNode struct {
	SKNode
}

A node that masks pixels drawn by its children so that only some pixels are seen.

Overview

SKCropNode is a container node that you use to crop other nodes in the scene. You add other nodes to a crop node and set the crop node’s SKCropNode.MaskNode property. For example, here are some ways you might specify a mask:

- An untextured sprite that limits content to a rectangular portion of the scene. - A textured sprite that works as a precise per-pixel mask. - A collection of child nodes that form a unique shape.

You can animate the shape or contents of the mask to implement interesting effects such as hiding or revealing.

Setting the Mask Filter

See: https://developer.apple.com/documentation/SpriteKit/SKCropNode

func NewCropNodeWithCoder

func NewCropNodeWithCoder(aDecoder foundation.INSCoder) SKCropNode

Called when a node is initialized from an .sks file.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(coder:)

func NewCropNodeWithFileNamed

func NewCropNodeWithFileNamed(filename string) SKCropNode

Creates a new node by loading an archive file from the game’s main bundle.

filename: The name of the file, without a file extension. The file must be in the app’s main bundle and have a `XCUIElementTypeSks` filename extension.

Return Value

The unarchived node object.

Discussion

If you call this method on a subclass of the SKScene class and the object in the archive is an SKScene object, the returned object is initialized as if it is a member of the subclass. You use this behavior to create scene layouts in the Xcode Editor and provide custom behaviors in your subclass.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(fileNamed:)

func NewSKCropNode

func NewSKCropNode() SKCropNode

NewSKCropNode creates a new SKCropNode instance.

func SKCropNodeFromID

func SKCropNodeFromID(id objc.ID) SKCropNode

SKCropNodeFromID constructs a SKCropNode from an objc.ID.

A node that masks pixels drawn by its children so that only some pixels are seen.

func (SKCropNode) Autorelease

func (c SKCropNode) Autorelease() SKCropNode

Autorelease adds the receiver to the current autorelease pool.

func (SKCropNode) Init

func (c SKCropNode) Init() SKCropNode

Init initializes the instance.

func (SKCropNode) MaskNode

func (c SKCropNode) MaskNode() ISKNode

The node used to determine the crop node’s mask.

Discussion

The node supplied to the crop node must not be a child of another node; however, it may have children of its own.

When the crop node’s contents are rendered, the crop node first draws its mask into a private buffer. Then, it renders its children. When rendering its children, each pixel is verified against the corresponding pixel in the mask. If the pixel in the mask has an alpha value of less than 0.05, the image pixel is masked out. Any pixel not rendered by the mask node is automatically masked out.

The default value of this property is `nil`, which indicates that the child nodes should not be cropped.

See: https://developer.apple.com/documentation/SpriteKit/SKCropNode/maskNode

func (SKCropNode) SetMaskNode

func (c SKCropNode) SetMaskNode(value ISKNode)

type SKCropNodeClass

type SKCropNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKCropNodeClass

func GetSKCropNodeClass() SKCropNodeClass

GetSKCropNodeClass returns the class object for SKCropNode.

func (SKCropNodeClass) Alloc

func (sc SKCropNodeClass) Alloc() SKCropNode

Alloc allocates memory for a new instance of the class.

func (SKCropNodeClass) Class

func (sc SKCropNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKEffectNode

type SKEffectNode struct {
	SKNode
}

A node that renders its children into a separate buffer, optionally applying an effect, before drawing the final result.

Overview

An SKEffectNode object renders its children into a buffer and optionally applies a Core Image filter to this rendered output. Because effect nodes conform to SKWarpable, you can also use them to apply distortions to nodes that don’t implement the protocol, such as shape and video nodes. Use effect nodes to incorporate sophisticated special effects into a scene or to cache the contents of a static subtree for faster rendering performance.

Each time a new frame is rendered using the effect node, the effect node follows these steps:

- It draws its children into a private framebuffer. - It applies a Core Image effect to the private framebuffer. This stage is optional; see the SKEffectNode.Filter and SKEffectNode.ShouldEnableEffects properties. - It blends the contents of its private framebuffer into its parent’s framebuffer, using one of the standard sprite blend modes. - It discards its private framebuffer. This step is optional; see the SKEffectNode.ShouldRasterize property.

Applying Core Image Filters with an Effect Node

Applying a Shader with an Effect Node

Flattening an Effect Node’s Child Tree for Performance Improvement

Configuring Alpha Blending

See: https://developer.apple.com/documentation/SpriteKit/SKEffectNode

func NewEffectNodeWithCoder

func NewEffectNodeWithCoder(aDecoder foundation.INSCoder) SKEffectNode

Called when a node is initialized from an .sks file.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(coder:)

func NewEffectNodeWithFileNamed

func NewEffectNodeWithFileNamed(filename string) SKEffectNode

Creates a new node by loading an archive file from the game’s main bundle.

filename: The name of the file, without a file extension. The file must be in the app’s main bundle and have a `XCUIElementTypeSks` filename extension.

Return Value

The unarchived node object.

Discussion

If you call this method on a subclass of the SKScene class and the object in the archive is an SKScene object, the returned object is initialized as if it is a member of the subclass. You use this behavior to create scene layouts in the Xcode Editor and provide custom behaviors in your subclass.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(fileNamed:)

func NewSKEffectNode

func NewSKEffectNode() SKEffectNode

NewSKEffectNode creates a new SKEffectNode instance.

func SKEffectNodeFromID

func SKEffectNodeFromID(id objc.ID) SKEffectNode

SKEffectNodeFromID constructs a SKEffectNode from an objc.ID.

A node that renders its children into a separate buffer, optionally applying an effect, before drawing the final result.

func (SKEffectNode) AttributeValues

func (e SKEffectNode) AttributeValues() foundation.INSDictionary

The values of each attribute associated with the node’s attached shader.

Discussion

All nodes have their own copy of an attribute value and therefore the attribute values can be different per-node across the same SKShader. If instead you need all nodes to share the same value, use SKUniform. Uniforms can change values every frame, but uniforms cannot vary per-node like attributes can.

See: https://developer.apple.com/documentation/SpriteKit/SKEffectNode/attributeValues

func (SKEffectNode) Autorelease

func (e SKEffectNode) Autorelease() SKEffectNode

Autorelease adds the receiver to the current autorelease pool.

func (SKEffectNode) BlendMode

func (e SKEffectNode) BlendMode() SKBlendMode

The blend mode used to draw the node’s contents into its parent’s framebuffer.

Discussion

The default value is SKBlendMode.alpha.

See: https://developer.apple.com/documentation/SpriteKit/SKEffectNode/blendMode

func (SKEffectNode) Filter

func (e SKEffectNode) Filter() coreimage.CIFilter

The Core Image filter to apply.

Discussion

The Core Image filter must have a single `inputImage` parameter and produce a single `outputImage` parameter. The default value is `nil`. If the value is `nil` and the effect node is enabled, no filtering takes place. However, its children are still rendered in a separate pass and blended to the parent’s framebuffer.

If you wish to use a Core Image filter that doesn’t have an `inputImage` parameter, such as a sunbeams generator, you can subclass CIFilter and add an `inputImage` property. The input image’s extent can be used to define properties such as radius on the filter. The following code creates a filter based on CISunbeamsGenerator which can be used as an effect node’s filter:

See: https://developer.apple.com/documentation/SpriteKit/SKEffectNode/filter

func (SKEffectNode) Init

func (e SKEffectNode) Init() SKEffectNode

Init initializes the instance.

func (SKEffectNode) SetAttributeValues

func (e SKEffectNode) SetAttributeValues(value foundation.INSDictionary)

func (SKEffectNode) SetBlendMode

func (e SKEffectNode) SetBlendMode(value SKBlendMode)

func (SKEffectNode) SetFilter

func (e SKEffectNode) SetFilter(value coreimage.CIFilter)

func (SKEffectNode) SetShader

func (e SKEffectNode) SetShader(value ISKShader)

func (SKEffectNode) SetShouldCenterFilter

func (e SKEffectNode) SetShouldCenterFilter(value bool)

func (SKEffectNode) SetShouldEnableEffects

func (e SKEffectNode) SetShouldEnableEffects(value bool)

func (SKEffectNode) SetShouldRasterize

func (e SKEffectNode) SetShouldRasterize(value bool)

func (SKEffectNode) SetSubdivisionLevels

func (o SKEffectNode) SetSubdivisionLevels(value int)

The maximum number of subdivision iterations used to generate the final vertices.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpable/subdivisionLevels

func (SKEffectNode) SetValueForAttributeNamed

func (e SKEffectNode) SetValueForAttributeNamed(value ISKAttributeValue, key string)

Sets an attribute value for an attached shader.

value: An attribute value object containing the scalar or vector value to set in the attached shader.

key: The attribute name.

See: https://developer.apple.com/documentation/SpriteKit/SKEffectNode/setValue(_:forAttribute:)

func (SKEffectNode) SetWarpGeometry

func (o SKEffectNode) SetWarpGeometry(value ISKWarpGeometry)

The warp geometry used to define the distortion.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpable/warpGeometry

func (SKEffectNode) Shader

func (e SKEffectNode) Shader() ISKShader

A custom shader that is called when the effect node is blended into the parent’s framebuffer.

Discussion

The default value is `nil`, meaning that default blending behavior executes. If a shader is specified, it is called when the rasterized image is blended into the parent’s framebuffer.

See: https://developer.apple.com/documentation/SpriteKit/SKEffectNode/shader

func (SKEffectNode) ShouldCenterFilter

func (e SKEffectNode) ShouldCenterFilter() bool

A Boolean value that determines whether the effect node automatically sets the filter’s image center.

Discussion

If the value of this property is true and the filter has an `inputCenter` parameter, the effect node automatically sets the filter’s input center to the effect node’s origin. The default value is true.

See: https://developer.apple.com/documentation/SpriteKit/SKEffectNode/shouldCenterFilter

func (SKEffectNode) ShouldEnableEffects

func (e SKEffectNode) ShouldEnableEffects() bool

A Boolean value that determines whether the effect node applies the filter to its children as they are drawn.

Discussion

If the value of this property is true, the effect node applies the filter and blends the results. If the value is false, the effect node is ignored and its children are rendered normally. The default value is false.

See: https://developer.apple.com/documentation/SpriteKit/SKEffectNode/shouldEnableEffects

func (SKEffectNode) ShouldRasterize

func (e SKEffectNode) ShouldRasterize() bool

A Boolean value that indicates whether the results of rendering the child nodes should be cached.

Discussion

If the value of this property is true, the effect node caches the filtered image for use in future frames. If the value is false, then SpriteKit discards the rendered image and redraws it from scratch the next time the node is rendered. The default value is false. Caching the rendered image uses more memory and may take more time to render. However, if the effect node’s descendants rarely change, caching can improve performance.

When caching is enabled, changes to the effect node’s children trigger updates to the cached image in the next frame of animation. However, changing the filter’s properties does not.

See: https://developer.apple.com/documentation/SpriteKit/SKEffectNode/shouldRasterize

func (SKEffectNode) SubdivisionLevels

func (e SKEffectNode) SubdivisionLevels() int

The maximum number of subdivision iterations used to generate the final vertices.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpable/subdivisionLevels

func (SKEffectNode) ValueForAttributeNamed

func (e SKEffectNode) ValueForAttributeNamed(key string) ISKAttributeValue

Gets the value of a shader attribute.

key: The attribute name.

Return Value

An attribute value object containing the scalar or vector value or `nil` if no such attribute exists.

See: https://developer.apple.com/documentation/SpriteKit/SKEffectNode/value(forAttributeNamed:)

func (SKEffectNode) WarpGeometry

func (e SKEffectNode) WarpGeometry() ISKWarpGeometry

The warp geometry used to define the distortion.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpable/warpGeometry

type SKEffectNodeClass

type SKEffectNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKEffectNodeClass

func GetSKEffectNodeClass() SKEffectNodeClass

GetSKEffectNodeClass returns the class object for SKEffectNode.

func (SKEffectNodeClass) Alloc

func (sc SKEffectNodeClass) Alloc() SKEffectNode

Alloc allocates memory for a new instance of the class.

func (SKEffectNodeClass) Class

func (sc SKEffectNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKEmitterNode

type SKEmitterNode struct {
	SKNode
}

A source of various particle effects.

Overview

A SKEmitterNode object is a node that automatically creates and renders small particle sprites. Particles are privately owned by SpriteKit—your game cannot access the generated sprites. For example, you cannot add physics shapes to particles. Emitter nodes are often used to create smoke, fire, sparks, and other particle effects. A particle is similar to an SKSpriteNode object; it renders a textured or untextured image that is sized, colorized, and blended into the scene. However, particles differ from sprites in two important ways:

- A particle’s texture is always stretched uniformly. - Particles are not represented by objects in SpriteKit. This means you cannot perform node-related tasks on particles, nor can you associate physics bodies with particles to make them interact with other content. Although there is no visible class representing particles added by the emitter node, you can think of a particle as having properties like any other object.

Particles are purely visual objects, and their behavior is entirely defined by the emitter node that created them. The emitter node contains many properties to control the behavior of the particles it generates, including:

- The birth rate and lifetime of the particle. You can also specify the order in which the particles are rendered and the maximum number of particles that are created before the emitter turns itself off. - The starting values of the particle, including its position, orientation, color, and size. You can choose to have these starting values randomized. - The changes to apply to the particle over its lifetime. Typically, these are specified as a rate of change over time. For example, you might specify that a particle rotates at a particular rate, in radians per second. The emitter automatically updates the particle data for each frame. In most cases, you can also create more sophisticated behaviors using keyframe sequences. For example, you might specify a keyframe sequence for a particle so that it starts out small, scales up to a larger size, then shrinks before dying.

Choosing Which Node in the Scene Emits Particles

Controlling When Particles Are Created

Controlling the Rendering Order of an Emitter’s Particles

Controlling Particle Lifetime

Controlling Particle Position

Controlling Particle Velocity and Acceleration

Adjusting a Particle’s Rotation

Scaling Particles by a Factor

Changing a Particle’s Source Image and Size

Configuring Particle Color

Controlling How the Texture is Blended with Particle Color

Blending Particles with the Framebuffer

Animating Particles

Applying Physics Fields to the Particles

Taking Full Control of Particle Drawing with a Shader

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode

func NewEmitterNodeWithCoder

func NewEmitterNodeWithCoder(aDecoder foundation.INSCoder) SKEmitterNode

Called when a node is initialized from an .sks file.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(coder:)

func NewEmitterNodeWithFileNamed

func NewEmitterNodeWithFileNamed(filename string) SKEmitterNode

Creates a new node by loading an archive file from the game’s main bundle.

filename: The name of the file, without a file extension. The file must be in the app’s main bundle and have a `XCUIElementTypeSks` filename extension.

Return Value

The unarchived node object.

Discussion

If you call this method on a subclass of the SKScene class and the object in the archive is an SKScene object, the returned object is initialized as if it is a member of the subclass. You use this behavior to create scene layouts in the Xcode Editor and provide custom behaviors in your subclass.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(fileNamed:)

func NewSKEmitterNode

func NewSKEmitterNode() SKEmitterNode

NewSKEmitterNode creates a new SKEmitterNode instance.

func SKEmitterNodeFromID

func SKEmitterNodeFromID(id objc.ID) SKEmitterNode

SKEmitterNodeFromID constructs a SKEmitterNode from an objc.ID.

A source of various particle effects.

func (SKEmitterNode) AdvanceSimulationTime

func (e SKEmitterNode) AdvanceSimulationTime(sec foundation.NSTimeInterval)

Advances the emitter particle simulation.

sec: The number of seconds to simulate.

Discussion

Once added to a scene, an emitter node automatically creates new particles in new animation frames. This method allows you to artificially advance a running emitter’s simulation, causing it to generate new particles and advance any existing particles. The most common use for this method is to prepopulate an emitter node with particles after it is first added to a scene.

If an emitter is paused, either directly or by one of its parent nodes being paused, SKEmitterNode.AdvanceSimulationTime has no effect. Listing 1 shows how to advance an emitter object while it is paused, by temporarily toggling its [SKNode.Paused] property while advancing the simulation.

Listing 1. Temporarily unpausing an emitter to advance simulation time

Note that the [SKNode.Paused] property is inherited from a node’s parents, so even if the emitter hasn’t been explicitly paused but, for example, the scene has, this code will still work.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/advanceSimulationTime(_:)

func (SKEmitterNode) AttributeValues

func (e SKEmitterNode) AttributeValues() foundation.INSDictionary

The values of each attribute associated with the node’s attached shader.

Discussion

All nodes have their own copy of an attribute value and therefore the attribute values can be different per-node across the same SKShader. If instead you need all nodes to share the same value, use SKUniform. Uniforms can change values every frame, but uniforms cannot vary per-node like attributes can.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/attributeValues

func (SKEmitterNode) Autorelease

func (e SKEmitterNode) Autorelease() SKEmitterNode

Autorelease adds the receiver to the current autorelease pool.

func (SKEmitterNode) EmissionAngle

func (e SKEmitterNode) EmissionAngle() float64

The average initial direction of a particle, expressed as an angle in radians.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/emissionAngle

func (SKEmitterNode) EmissionAngleRange

func (e SKEmitterNode) EmissionAngleRange() float64

The range of allowed random values for a particle’s initial direction, expressed as an angle in radians.

Discussion

The default value is `0.0`. If non-zero, the emission angle of each particle is randomly determined and may vary by plus or minus half of the range value.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/emissionAngleRange

func (SKEmitterNode) FieldBitMask

func (e SKEmitterNode) FieldBitMask() uint32

A mask that defines which categories of physics fields can exert forces on the particles.

Discussion

When a particle is inside the region of a SKFieldNode object, that field node’s SKFieldNode.CategoryBitMask property is compared to the emitter’s SKEmitterNode.FieldBitMask property by performing a logical AND operation. If the result is a non-zero value, then the field node’s effect is applied to the particle as if it had a physics body. The physics body is assumed to have a SKPhysicsBody.Mass of `1.0` and a SKPhysicsBody.Charge of `1.0`

The default value is `0x00000000` (all bits cleared).

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/fieldBitMask

func (SKEmitterNode) Init

func (e SKEmitterNode) Init() SKEmitterNode

Init initializes the instance.

func (SKEmitterNode) NumParticlesToEmit

func (e SKEmitterNode) NumParticlesToEmit() uint

The number of particles the emitter should emit before stopping.

Discussion

The default value is `0`, which indicates that emitter creates an endless stream of particles. If a non-zero value is provided, then the emitter stops generating particles after it has created the specified number of particles.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/numParticlesToEmit

func (SKEmitterNode) ParticleAction

func (e SKEmitterNode) ParticleAction() ISKAction

An action executed by new particles.

Discussion

Although you do not have direct access to the particles created by SpriteKit, you can specify an action that all particles execute. Whenever a new particle is created, the emitter tells the particle to run that action. You can use actions to create very sophisticated behaviors.

For the purpose of using actions on particles, you can treat the particle as if it were a normal node. This means you can perform other interesting tricks, such as animating the particle’s textures.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleAction

func (SKEmitterNode) ParticleAlpha

func (e SKEmitterNode) ParticleAlpha() float64

The average starting alpha value for a particle.

Discussion

The particle alpha value is equivalent to the SKNode.Alpha property of the SKNode class. The alpha component of the color that results from the texture and color blending state is multiplied by a particle’s alpha value. The resulting particle color is then blended with the parent’s framebuffer. The default value is `1.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleAlpha

func (SKEmitterNode) ParticleAlphaRange

func (e SKEmitterNode) ParticleAlphaRange() float64

The range of allowed random values for a particle’s starting alpha value.

Discussion

The default value is `0.0`. If non-zero, the initial alpha value of each particle is randomly determined and may vary by plus or minus half of the range value.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleAlphaRange

func (SKEmitterNode) ParticleAlphaSequence

func (e SKEmitterNode) ParticleAlphaSequence() ISKKeyframeSequence

The sequence used to specify the alpha value of a particle over its lifetime.

Discussion

The default value is `nil`. If a non-`nil` value is specified, then the SKEmitterNode.ParticleAlpha, SKEmitterNode.ParticleAlphaRange, and SKEmitterNode.ParticleAlphaSpeed properties are ignored. Instead, the sequence is used to specify the alpha value.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleAlphaSequence

func (SKEmitterNode) ParticleAlphaSpeed

func (e SKEmitterNode) ParticleAlphaSpeed() float64

The rate at which the alpha value of a particle changes per second.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleAlphaSpeed

func (SKEmitterNode) ParticleBirthRate

func (e SKEmitterNode) ParticleBirthRate() float64

The rate at which new particles are created.

Discussion

The number of particles generated by the emitter every second. The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleBirthRate

func (SKEmitterNode) ParticleBlendMode

func (e SKEmitterNode) ParticleBlendMode() SKBlendMode

The blending mode used to blend particles into the framebuffer.

Discussion

The default value is SKBlendMode.alpha.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleBlendMode

func (SKEmitterNode) ParticleColor

func (e SKEmitterNode) ParticleColor() appkit.NSColor

The average initial color for a particle.

Discussion

The default value is `[SKColor clearColor]`.

A particle’s color is blended with the texture using its blend color factor. See SKEmitterNode.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColor

func (SKEmitterNode) ParticleColorAlphaRange

func (e SKEmitterNode) ParticleColorAlphaRange() float64

The range of allowed random values for the alpha component of a particle’s initial color.

Discussion

The default value is `0.0`. If non-zero, the starting alpha component of a particle’s color is randomly determined and may vary by plus or minus half of the range value.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColorAlphaRange

func (SKEmitterNode) ParticleColorAlphaSpeed

func (e SKEmitterNode) ParticleColorAlphaSpeed() float64

The rate at which the alpha component of a particle’s color changes per second.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColorAlphaSpeed

func (SKEmitterNode) ParticleColorBlendFactor

func (e SKEmitterNode) ParticleColorBlendFactor() float64

The average starting value for the color blend factor.

Discussion

The default value is `0.0`, which means that the texture is used as is, ignoring the particle’s color. Otherwise, the texture is blended with the color. The maximum value is `1.0`, which means the particle renders with a full-tint color.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColorBlendFactor

func (SKEmitterNode) ParticleColorBlendFactorRange

func (e SKEmitterNode) ParticleColorBlendFactorRange() float64

The range of allowed random values for a particle’s starting color blend factor.

Discussion

The default value is `0.0`. If non-zero, the initial color blend factor of each particle is randomly determined and may vary by plus or minus half of the range value.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColorBlendFactorRange

func (SKEmitterNode) ParticleColorBlendFactorSequence

func (e SKEmitterNode) ParticleColorBlendFactorSequence() ISKKeyframeSequence

The sequence used to specify the color blend factor of a particle over its lifetime.

Discussion

The default value is `nil`. If a non-`nil` value is specified, then the SKEmitterNode.ParticleColorBlendFactor, SKEmitterNode.ParticleColorBlendFactorRange, and SKEmitterNode.ParticleColorBlendFactorSpeed properties are ignored. Instead, the sequence is used to specify the color blend factor.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColorBlendFactorSequence

func (SKEmitterNode) ParticleColorBlendFactorSpeed

func (e SKEmitterNode) ParticleColorBlendFactorSpeed() float64

The rate at which the color blend factor changes per second.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColorBlendFactorSpeed

func (SKEmitterNode) ParticleColorBlueRange

func (e SKEmitterNode) ParticleColorBlueRange() float64

The range of allowed random values for the blue component of a particle’s initial color.

Discussion

The default value is `0.0`. If non-zero, the starting blue component of a particle’s color is randomly determined and may vary by plus or minus half of the range value.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColorBlueRange

func (SKEmitterNode) ParticleColorBlueSpeed

func (e SKEmitterNode) ParticleColorBlueSpeed() float64

The rate at which the blue component of a particle’s color changes per second.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColorBlueSpeed

func (SKEmitterNode) ParticleColorGreenRange

func (e SKEmitterNode) ParticleColorGreenRange() float64

The range of allowed random values for the green component of a particle’s initial color.

Discussion

The default value is `0.0`. If non-zero, the starting green component of a particle’s color is randomly determined and may vary by plus or minus half of the range value.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColorGreenRange

func (SKEmitterNode) ParticleColorGreenSpeed

func (e SKEmitterNode) ParticleColorGreenSpeed() float64

The rate at which the green component of a particle’s color changes per second.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColorGreenSpeed

func (SKEmitterNode) ParticleColorRedRange

func (e SKEmitterNode) ParticleColorRedRange() float64

The range of allowed random values for the red component of a particle’s initial color.

Discussion

The default value is `0.0`. If non-zero, the starting red component of a particle’s color is randomly determined and may vary by plus or minus half of the range value.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColorRedRange

func (SKEmitterNode) ParticleColorRedSpeed

func (e SKEmitterNode) ParticleColorRedSpeed() float64

The rate at which the red component of a particle’s color changes per second.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColorRedSpeed

func (SKEmitterNode) ParticleColorSequence

func (e SKEmitterNode) ParticleColorSequence() ISKKeyframeSequence

The sequence used to specify the color components of a particle over its lifetime.

Discussion

The default value is `nil`. If a non-`nil` value is specified, then the SKEmitterNode.ParticleColor, SKEmitterNode.ParticleColorAlphaRange, SKEmitterNode.ParticleColorRedRange, SKEmitterNode.ParticleColorGreenRange, SKEmitterNode.ParticleColorBlueRange, SKEmitterNode.ParticleColorAlphaSpeed, SKEmitterNode.ParticleColorRedSpeed, SKEmitterNode.ParticleColorGreenSpeed, and SKEmitterNode.ParticleColorBlueSpeed properties are ignored. Instead, the sequence is used to specify the particle color.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleColorSequence

func (SKEmitterNode) ParticleLifetime

func (e SKEmitterNode) ParticleLifetime() float64

The average lifetime of a particle, in seconds.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleLifetime

func (SKEmitterNode) ParticleLifetimeRange

func (e SKEmitterNode) ParticleLifetimeRange() float64

The range of allowed random values for a particle’s lifetime.

Discussion

The default value is `0.0`. If non-zero, the lifetime of each particle is randomly determined and may vary by plus or minus half of the range value.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleLifetimeRange

func (SKEmitterNode) ParticlePosition

func (e SKEmitterNode) ParticlePosition() corefoundation.CGPoint

The average starting position for a particle.

Discussion

The default value is `(0.0,0.0)`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particlePosition

func (SKEmitterNode) ParticlePositionRange

func (e SKEmitterNode) ParticlePositionRange() corefoundation.CGVector

The range of allowed random values for a particle’s position.

Discussion

The default value is `(0.0,0.0)`. If a component is non-zero, the same component of a particle’s position is randomly determined and may vary by plus or minus half of the range value.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particlePositionRange

func (SKEmitterNode) ParticleRenderOrder

func (e SKEmitterNode) ParticleRenderOrder() SKParticleRenderOrder

The order in which the emitter’s particles are rendered.

Discussion

The default value is SKParticleRenderOrder.oldestLast.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleRenderOrder

func (SKEmitterNode) ParticleRotation

func (e SKEmitterNode) ParticleRotation() float64

The average initial rotation of a particle, expressed as an angle in radians.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleRotation

func (SKEmitterNode) ParticleRotationRange

func (e SKEmitterNode) ParticleRotationRange() float64

The range of allowed random values for a particle’s initial rotation, expressed as an angle in radians.

Discussion

The default value is `0.0`. If non-zero, the initial rotation of each particle is randomly determined and may vary by plus or minus half of the range value.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleRotationRange

func (SKEmitterNode) ParticleRotationSpeed

func (e SKEmitterNode) ParticleRotationSpeed() float64

The speed at which a particle rotates, expressed in radians per second.

Discussion

This is uniform for all particles generated by the emitter. The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleRotationSpeed

func (SKEmitterNode) ParticleScale

func (e SKEmitterNode) ParticleScale() float64

The average initial scale factor of a particle.

Discussion

The default value is `1.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleScale

func (SKEmitterNode) ParticleScaleRange

func (e SKEmitterNode) ParticleScaleRange() float64

The range of allowed random values for a particle’s initial scale.

Discussion

The default value is `0.0`. If non-zero, the initial scale of each particle is randomly determined and may vary by plus or minus half of the range value.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleScaleRange

func (SKEmitterNode) ParticleScaleSequence

func (e SKEmitterNode) ParticleScaleSequence() ISKKeyframeSequence

The sequence used to specify the scale factor of a particle over its lifetime.

Discussion

The default value is `nil`. If a non-`nil` value is specified, then the SKEmitterNode.ParticleScale, SKEmitterNode.ParticleScaleRange, and SKEmitterNode.ParticleScaleSpeed properties are ignored. Instead, the sequence is used to specify the scale factor.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleScaleSequence

func (SKEmitterNode) ParticleScaleSpeed

func (e SKEmitterNode) ParticleScaleSpeed() float64

The rate at which a particle’s scale factor changes per second.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleScaleSpeed

func (SKEmitterNode) ParticleSize

func (e SKEmitterNode) ParticleSize() corefoundation.CGSize

The starting size of each particle.

Discussion

The default value is CGSizeZero. If set to the default, the size of the texture stored in the SKEmitterNode.ParticleTexture property is used to determine the size of a particle. If a texture has not been assigned, you must set this property to a non-empty size.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleSize

func (SKEmitterNode) ParticleSpeed

func (e SKEmitterNode) ParticleSpeed() float64

The average initial speed of a new particle, in points per second.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleSpeed

func (SKEmitterNode) ParticleSpeedRange

func (e SKEmitterNode) ParticleSpeedRange() float64

The range of allowed random values for a particle’s initial speed.

Discussion

The default value is `0.0`. If non-zero, the speed of each particle is randomly determined and may vary by plus or minus half of the range value.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleSpeedRange

func (SKEmitterNode) ParticleTexture

func (e SKEmitterNode) ParticleTexture() ISKTexture

The texture to use to render a particle.

Discussion

A particle is rendered as if it were a SKSpriteNode object. The default value is `nil`, which means a single-color rectangle is used to draw the particle. If a non-`nil` value is specified, then the texture is colorized and used to draw particles.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleTexture

func (SKEmitterNode) ParticleZPosition

func (e SKEmitterNode) ParticleZPosition() float64

The average starting depth of a particle.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/particleZPosition

func (SKEmitterNode) ResetSimulation

func (e SKEmitterNode) ResetSimulation()

Removes all existing particles and restarts the simulation.

Discussion

Resetting the simulation clears the internal state of the simulation.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/resetSimulation()

func (SKEmitterNode) SetAttributeValues

func (e SKEmitterNode) SetAttributeValues(value foundation.INSDictionary)

func (SKEmitterNode) SetEmissionAngle

func (e SKEmitterNode) SetEmissionAngle(value float64)

func (SKEmitterNode) SetEmissionAngleRange

func (e SKEmitterNode) SetEmissionAngleRange(value float64)

func (SKEmitterNode) SetFieldBitMask

func (e SKEmitterNode) SetFieldBitMask(value uint32)

func (SKEmitterNode) SetNumParticlesToEmit

func (e SKEmitterNode) SetNumParticlesToEmit(value uint)

func (SKEmitterNode) SetParticleAction

func (e SKEmitterNode) SetParticleAction(value ISKAction)

func (SKEmitterNode) SetParticleAlpha

func (e SKEmitterNode) SetParticleAlpha(value float64)

func (SKEmitterNode) SetParticleAlphaRange

func (e SKEmitterNode) SetParticleAlphaRange(value float64)

func (SKEmitterNode) SetParticleAlphaSequence

func (e SKEmitterNode) SetParticleAlphaSequence(value ISKKeyframeSequence)

func (SKEmitterNode) SetParticleAlphaSpeed

func (e SKEmitterNode) SetParticleAlphaSpeed(value float64)

func (SKEmitterNode) SetParticleBirthRate

func (e SKEmitterNode) SetParticleBirthRate(value float64)

func (SKEmitterNode) SetParticleBlendMode

func (e SKEmitterNode) SetParticleBlendMode(value SKBlendMode)

func (SKEmitterNode) SetParticleColor

func (e SKEmitterNode) SetParticleColor(value appkit.NSColor)

func (SKEmitterNode) SetParticleColorAlphaRange

func (e SKEmitterNode) SetParticleColorAlphaRange(value float64)

func (SKEmitterNode) SetParticleColorAlphaSpeed

func (e SKEmitterNode) SetParticleColorAlphaSpeed(value float64)

func (SKEmitterNode) SetParticleColorBlendFactor

func (e SKEmitterNode) SetParticleColorBlendFactor(value float64)

func (SKEmitterNode) SetParticleColorBlendFactorRange

func (e SKEmitterNode) SetParticleColorBlendFactorRange(value float64)

func (SKEmitterNode) SetParticleColorBlendFactorSequence

func (e SKEmitterNode) SetParticleColorBlendFactorSequence(value ISKKeyframeSequence)

func (SKEmitterNode) SetParticleColorBlendFactorSpeed

func (e SKEmitterNode) SetParticleColorBlendFactorSpeed(value float64)

func (SKEmitterNode) SetParticleColorBlueRange

func (e SKEmitterNode) SetParticleColorBlueRange(value float64)

func (SKEmitterNode) SetParticleColorBlueSpeed

func (e SKEmitterNode) SetParticleColorBlueSpeed(value float64)

func (SKEmitterNode) SetParticleColorGreenRange

func (e SKEmitterNode) SetParticleColorGreenRange(value float64)

func (SKEmitterNode) SetParticleColorGreenSpeed

func (e SKEmitterNode) SetParticleColorGreenSpeed(value float64)

func (SKEmitterNode) SetParticleColorRedRange

func (e SKEmitterNode) SetParticleColorRedRange(value float64)

func (SKEmitterNode) SetParticleColorRedSpeed

func (e SKEmitterNode) SetParticleColorRedSpeed(value float64)

func (SKEmitterNode) SetParticleColorSequence

func (e SKEmitterNode) SetParticleColorSequence(value ISKKeyframeSequence)

func (SKEmitterNode) SetParticleLifetime

func (e SKEmitterNode) SetParticleLifetime(value float64)

func (SKEmitterNode) SetParticleLifetimeRange

func (e SKEmitterNode) SetParticleLifetimeRange(value float64)

func (SKEmitterNode) SetParticlePosition

func (e SKEmitterNode) SetParticlePosition(value corefoundation.CGPoint)

func (SKEmitterNode) SetParticlePositionRange

func (e SKEmitterNode) SetParticlePositionRange(value corefoundation.CGVector)

func (SKEmitterNode) SetParticleRenderOrder

func (e SKEmitterNode) SetParticleRenderOrder(value SKParticleRenderOrder)

func (SKEmitterNode) SetParticleRotation

func (e SKEmitterNode) SetParticleRotation(value float64)

func (SKEmitterNode) SetParticleRotationRange

func (e SKEmitterNode) SetParticleRotationRange(value float64)

func (SKEmitterNode) SetParticleRotationSpeed

func (e SKEmitterNode) SetParticleRotationSpeed(value float64)

func (SKEmitterNode) SetParticleScale

func (e SKEmitterNode) SetParticleScale(value float64)

func (SKEmitterNode) SetParticleScaleRange

func (e SKEmitterNode) SetParticleScaleRange(value float64)

func (SKEmitterNode) SetParticleScaleSequence

func (e SKEmitterNode) SetParticleScaleSequence(value ISKKeyframeSequence)

func (SKEmitterNode) SetParticleScaleSpeed

func (e SKEmitterNode) SetParticleScaleSpeed(value float64)

func (SKEmitterNode) SetParticleSize

func (e SKEmitterNode) SetParticleSize(value corefoundation.CGSize)

func (SKEmitterNode) SetParticleSpeed

func (e SKEmitterNode) SetParticleSpeed(value float64)

func (SKEmitterNode) SetParticleSpeedRange

func (e SKEmitterNode) SetParticleSpeedRange(value float64)

func (SKEmitterNode) SetParticleTexture

func (e SKEmitterNode) SetParticleTexture(value ISKTexture)

func (SKEmitterNode) SetParticleZPosition

func (e SKEmitterNode) SetParticleZPosition(value float64)

func (SKEmitterNode) SetShader

func (e SKEmitterNode) SetShader(value ISKShader)

func (SKEmitterNode) SetTargetNode

func (e SKEmitterNode) SetTargetNode(value ISKNode)

func (SKEmitterNode) SetValueForAttributeNamed

func (e SKEmitterNode) SetValueForAttributeNamed(value ISKAttributeValue, key string)

Sets an attribute value for an attached shader.

value: An attribute value object containing the scalar or vector value to set in the attached shader.

key: The attribute name.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/setValue(_:forAttribute:)

func (SKEmitterNode) SetXAcceleration

func (e SKEmitterNode) SetXAcceleration(value float64)

func (SKEmitterNode) SetYAcceleration

func (e SKEmitterNode) SetYAcceleration(value float64)

func (SKEmitterNode) Shader

func (e SKEmitterNode) Shader() ISKShader

A custom shader used to determine how particles are rendered.

Discussion

The default value is `nil`. If a shader is specified, then the shader is used to determine the output colors for any of the emitter’s particles.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/shader

func (SKEmitterNode) TargetNode

func (e SKEmitterNode) TargetNode() ISKNode

The target node that renders the emitter’s particles.

Discussion

The default value is `nil`, which means that particles are treated as if they were children of the emitter node. In future frames of animation, the particle positions are affected by the emitter node’s properties. If you specify a different target node, the initial properties of new particles are calculated based on the emitter node’s properties, but in future frames of animation the particles are treated as if they were children of the target node.

For example, assume you have an emitter node as a child of the scene node and the node is being rotated by changing its SKNode.ZRotation property. The behavior of the emitter node changes based on the value of the target node:

- If the SKEmitterNode.TargetNode property is `nil`, then the positions of both previously generated and new particles are rotated. - If the SKEmitterNode.TargetNode property points to the scene node, then new particles are adjusted when the emitter node rotates, but previously generated particles are not.

By spawning the particles inside the scene node, they have behavior independent of the emitter’s properties.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/targetNode

func (SKEmitterNode) ValueForAttributeNamed

func (e SKEmitterNode) ValueForAttributeNamed(key string) ISKAttributeValue

Gets the value of a shader attribute.

key: The attribute name.

Return Value

An attribute value object containing the scalar or vector value or `nil` if no such attribute exists.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/value(forAttributeNamed:)

func (SKEmitterNode) XAcceleration

func (e SKEmitterNode) XAcceleration() float64

The acceleration to apply to a particle’s horizontal velocity.

Discussion

This property is useful for simulating wind, gravity and other effects. It is uniformly applied to all particles generated by the emitter.

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/xAcceleration

func (SKEmitterNode) YAcceleration

func (e SKEmitterNode) YAcceleration() float64

The acceleration to apply to a particle’s vertical velocity.

Discussion

This property is useful for simulating wind, gravity and other effects. It is uniformly applied to all particles generated by the emitter.

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKEmitterNode/yAcceleration

type SKEmitterNodeClass

type SKEmitterNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKEmitterNodeClass

func GetSKEmitterNodeClass() SKEmitterNodeClass

GetSKEmitterNodeClass returns the class object for SKEmitterNode.

func (SKEmitterNodeClass) Alloc

func (sc SKEmitterNodeClass) Alloc() SKEmitterNode

Alloc allocates memory for a new instance of the class.

func (SKEmitterNodeClass) Class

func (sc SKEmitterNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKFieldForceEvaluator

type SKFieldForceEvaluator = func(float32, float32, float32, float32, float64) float32

SKFieldForceEvaluator is the definition for a custom block that processes a single physics body’s interaction with the field.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldForceEvaluator

type SKFieldNode

type SKFieldNode struct {
	SKNode
}

A node that applies physics effects to nearby nodes.

Overview

There are many different kinds of field nodes that can be created, each with different effects. The SKFieldNode section lists the field types you can create using SpriteKit, including a type that allows you to apply custom forces to physics bodies. Instantiate the appropriate kind of field node and then add it to the scene’s node tree.

When the scene simulates physics effects, a field node applies its effect to a physics body so long as the following are true:

- The field node is in the scene’s node tree. - The field node’s [SKFieldNode.Enabled] property is true. - The physics body is attached to a node that is in the scene’s node tree. - The physics body is located inside the field node’s region (see SKFieldNode.Region). - The physics body is not located inside the region of another field node whose [SKFieldNode.Exclusive] property is set to true. - A logical AND operation between the field node’s SKFieldNode.CategoryBitMask property and the physics body’s SKPhysicsBody.FieldBitMask property results in a nonzero value.

Determining Which Physics Bodies Are Affected by the Field

Configuring the Strength of the Field

Configuring Other Field Properties

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode

func NewFieldNodeWithCoder

func NewFieldNodeWithCoder(aDecoder foundation.INSCoder) SKFieldNode

Called when a node is initialized from an .sks file.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(coder:)

func NewFieldNodeWithFileNamed

func NewFieldNodeWithFileNamed(filename string) SKFieldNode

Creates a new node by loading an archive file from the game’s main bundle.

filename: The name of the file, without a file extension. The file must be in the app’s main bundle and have a `XCUIElementTypeSks` filename extension.

Return Value

The unarchived node object.

Discussion

If you call this method on a subclass of the SKScene class and the object in the archive is an SKScene object, the returned object is initialized as if it is a member of the subclass. You use this behavior to create scene layouts in the Xcode Editor and provide custom behaviors in your subclass.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(fileNamed:)

func NewSKFieldNode

func NewSKFieldNode() SKFieldNode

NewSKFieldNode creates a new SKFieldNode instance.

func SKFieldNodeFromID

func SKFieldNodeFromID(id objc.ID) SKFieldNode

SKFieldNodeFromID constructs a SKFieldNode from an objc.ID.

A node that applies physics effects to nearby nodes.

func (SKFieldNode) AnimationSpeed

func (f SKFieldNode) AnimationSpeed() float32

The rate at which a noise or turbulence field node changes.

Discussion

A value of `0.0` means that the field should not animate at all.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/animationSpeed

func (SKFieldNode) Autorelease

func (f SKFieldNode) Autorelease() SKFieldNode

Autorelease adds the receiver to the current autorelease pool.

func (SKFieldNode) CategoryBitMask

func (f SKFieldNode) CategoryBitMask() uint32

A mask that defines which categories this field belongs to.

Discussion

Every field in a scene can be assigned to up to 32 different categories, each corresponding to a bit in the bit mask. The mask values are not predetermined by Sprite Kit. You define the mask values that are used in your game. The field node’s SKFieldNode.CategoryBitMask property is compared to a physics body’s SKPhysicsBody.FieldBitMask property using a logical AND operation. If the result is nonzero, the field is applied to the physics body.

The default value is `0xFFFFFFFF` (all bits set).

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/categoryBitMask

func (SKFieldNode) Direction

func (f SKFieldNode) Direction() Vector_float3

The direction of a velocity field node.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/direction

func (SKFieldNode) Falloff

func (f SKFieldNode) Falloff() float32

The exponent that defines the rate of decay for the strength of the field as the distance increases between the node and the physics body being affected.

Discussion

When the force of a field node is calculated, the force is multiplied by `pow(distance - minRadius, -falloff)`. The default falloff value is `0`, which indicates that no attenuation takes place. Some types of field nodes ignore the falloff parameter entirely, while others change the default value to something that is more logical for that type of field node.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/falloff

func (SKFieldNode) Init

func (f SKFieldNode) Init() SKFieldNode

Init initializes the instance.

func (SKFieldNode) IsEnabled

func (f SKFieldNode) IsEnabled() bool

A Boolean value that indicates whether the field is active.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/isEnabled

func (SKFieldNode) IsExclusive

func (f SKFieldNode) IsExclusive() bool

A Boolean value that indicates whether the field node should override all other field nodes that might otherwise affect physics bodies.

Discussion

If the value is set to true and a physics body is within this field’s region, all other field nodes that might otherwise affect this body are ignored. The default value is false.

If you set this property to true on multiple field nodes within a scene, their regions should not overlap. If they do, the results are undefined.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/isExclusive

func (SKFieldNode) MinimumRadius

func (f SKFieldNode) MinimumRadius() float32

The minimum value for distance-based effects.

Discussion

When the distance between the node and a physics body is calculated, any distance shorter than the value stored in the SKFieldNode.MinimumRadius property is treated as if it is equal to it. The default value is a very small (but nonzero) value.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/minimumRadius

func (SKFieldNode) Region

func (f SKFieldNode) Region() ISKRegion

The area (relative to the node’s origin) that the field affects.

Discussion

A field node applies its effect to all physics bodies that are partially or completely inside its region. The default value is a region of infinite size.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/region

func (SKFieldNode) SetAnimationSpeed

func (f SKFieldNode) SetAnimationSpeed(value float32)

func (SKFieldNode) SetCategoryBitMask

func (f SKFieldNode) SetCategoryBitMask(value uint32)

func (SKFieldNode) SetDirection

func (f SKFieldNode) SetDirection(value Vector_float3)

func (SKFieldNode) SetEnabled

func (f SKFieldNode) SetEnabled(value bool)

func (SKFieldNode) SetExclusive

func (f SKFieldNode) SetExclusive(value bool)

func (SKFieldNode) SetFalloff

func (f SKFieldNode) SetFalloff(value float32)

func (SKFieldNode) SetMinimumRadius

func (f SKFieldNode) SetMinimumRadius(value float32)

func (SKFieldNode) SetRegion

func (f SKFieldNode) SetRegion(value ISKRegion)

func (SKFieldNode) SetSmoothness

func (f SKFieldNode) SetSmoothness(value float32)

func (SKFieldNode) SetStrength

func (f SKFieldNode) SetStrength(value float32)

func (SKFieldNode) SetTexture

func (f SKFieldNode) SetTexture(value ISKTexture)

func (SKFieldNode) Smoothness

func (f SKFieldNode) Smoothness() float32

The smoothness of the noise used to generate the forces.

Discussion

This parameter should be a value between `0.0` and `1.0`, where `1.0` represents a uniform smoothness.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/smoothness

func (SKFieldNode) Strength

func (f SKFieldNode) Strength() float32

The strength of the field.

Discussion

The default value is `1.0`. There’s no specific unit of measurement for this property because the actual effect is dependent on the kind of field node being created. In practice, the best approach is to experiment with different field strengths and use them to determine the proper value empirically.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/strength

func (SKFieldNode) Texture

func (f SKFieldNode) Texture() ISKTexture

A normal texture that specifies the velocities at different points in a velocity field node.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/texture

type SKFieldNodeClass

type SKFieldNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKFieldNodeClass

func GetSKFieldNodeClass() SKFieldNodeClass

GetSKFieldNodeClass returns the class object for SKFieldNode.

func (SKFieldNodeClass) Alloc

func (sc SKFieldNodeClass) Alloc() SKFieldNode

Alloc allocates memory for a new instance of the class.

func (SKFieldNodeClass) Class

func (sc SKFieldNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (SKFieldNodeClass) CustomFieldWithEvaluationBlock

func (_SKFieldNodeClass SKFieldNodeClass) CustomFieldWithEvaluationBlock(block Float32Float32Handler) SKFieldNode

Creates a field node that calculates and applies a custom force to the physics body.

block: A custom block to be executed when a physics body is affected by the field. Your block should calculate and return the force to be applied to the body.

Return Value

A new custom field node.

Discussion

The value returned by the custom block is a vector for an impulse force which is applied to the physics body being evaluated for that frame. Only the `x` and `y` components of the return value are used by SpriteKit, the `z` component is ignored.

The values passed into the block by the `position` and `velocity` arguments measured in meters: if you need to convert them into points — as used by SpriteKit — multiply the values by 150.

The following code shows how to create a custom field to emulate drag. The block returns the negative of the square root of the velocity of the physics body. This decelerates a physics body passing through the SKFieldNode object’s region.

Listing 1. Creating a custom drag field

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/customField(evaluationBlock:)

func (SKFieldNodeClass) DragField

func (_SKFieldNodeClass SKFieldNodeClass) DragField() SKFieldNode

Creates a field node that applies a force that resists the motion of physics bodies.

Return Value

A new drag field node.

Discussion

The force is applied in the opposite direction of the physics body’s SKPhysicsBody.Velocity property and has a magnitude proportional to the field’s SKFieldNode.Strength property and the physics body’s speed. This field models Stoke’s Law.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/dragField()

func (SKFieldNodeClass) ElectricField

func (_SKFieldNodeClass SKFieldNodeClass) ElectricField() SKFieldNode

Creates a field node that applies an electrical force proportional to the electrical charge of physics bodies.

Return Value

A new electric field node.

Discussion

The force points toward the field node’s position and has a magnitude proportional to the field’s SKFieldNode.Strength property and the physics body’s SKPhysicsBody.Charge property. This field models the first part of the Lorentz equation:

F = qE

Where F equals force, q equals charge, and E equals electric field.

The SKFieldNode.Falloff property of an electrical field node is set by default to `2`.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/electricField()

func (SKFieldNodeClass) LinearGravityFieldWithVector

func (_SKFieldNodeClass SKFieldNodeClass) LinearGravityFieldWithVector(direction Vector_float3) SKFieldNode

Creates a field node that accelerates physics bodies in a specific direction.

direction: The direction and magnitude of the gravitational force. The values represent the acceleration of the field in meters per second squared. For example, to simulate earth’s gravity, specify `(0, -9.8, 0)`. The `z` component on the vector is ignored.

Return Value

A new linear gravity field node.

Discussion

If the field node is rotated, the direction of its gravity field is also rotated. The calculated force is proportional to the physics body’s mass (meaning that the acceleration applied to all affected physics bodies is a constant).

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/linearGravityField(withVector:)

func (SKFieldNodeClass) MagneticField

func (_SKFieldNodeClass SKFieldNodeClass) MagneticField() SKFieldNode

Creates a field node that applies a magnetic force based on the velocity and electrical charge of the physics bodies.

Return Value

A new magnetic field node.

Discussion

The force generated by this field is directed on a line that is determined by calculating the cross-product between the direction of the the physics body’s SKPhysicsBody.Velocity property and a line traced between the field node and the physics body. This field models the second part of the Lorentz equation:

F = qvB

Where F equals force, q equals charge, v equals velocity, B equals magnetic field and E equals electric field.

The force has a magnitude proportional to the field’s SKFieldNode.Strength property and the physics body’s SKPhysicsBody.Charge and SKPhysicsBody.Velocity properties. Therefore, physics bodies that are either stationary or with a charge of zero will not be affected by a magnetic field. Magnetic fields with a negative strength value impart a clockwise spin on the physics bodies they affect, while a positive strength give a clockwise spin.The SKFieldNode.Falloff property of a magnetic field node is set by default to `2`.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/magneticField()

func (SKFieldNodeClass) NoiseFieldWithSmoothnessAnimationSpeed

func (_SKFieldNodeClass SKFieldNodeClass) NoiseFieldWithSmoothnessAnimationSpeed(smoothness float64, speed float64) SKFieldNode

Creates a field node that applies a randomized acceleration to physics bodies.

smoothness: The smoothness of the noise used to generate the forces. This parameter should be a value between `0.0` and `1.0`, where `1.0` represents a uniform smoothness.

speed: The speed at which the noise field should change. A value of `0.0` means that the field should not animate at all.

Return Value

A new noise field node.

Discussion

Use a noise field to simulate effects such as fireflies or snow.

The acceleration is proportional to the field strength in a pseudo-random direction. The calculated force is proportional to the physics body’s mass (meaning that the acceleration applied to all affected physics bodies is a constant).

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/noiseField(withSmoothness:animationSpeed:)

func (SKFieldNodeClass) RadialGravityField

func (_SKFieldNodeClass SKFieldNodeClass) RadialGravityField() SKFieldNode

Creates a field node that accelerates physics bodies toward the field node.

Return Value

A new radial gravity field node.

Discussion

The strength of the field measures the acceleration of the field in meters per second squared. A positive number indicates that the body is accelerating toward the field node. The calculated force is proportional to the physics body’s mass (meaning that the acceleration applied to all affected physics bodies is a constant). The SKFieldNode.Falloff property of a radial gravity field node is set by default to `2`.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/radialGravityField()

func (SKFieldNodeClass) SpringField

func (_SKFieldNodeClass SKFieldNodeClass) SpringField() SKFieldNode

Creates a field node that applies a spring-like force that pulls physics bodies toward the field node.

Return Value

A new spring field node.

Discussion

The strength of the field measures the strength of the spring. A positive number indicates that the body is accelerating toward the field node. The SKFieldNode.Falloff property of a spring field node is set by default to `-1`.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/springField()

func (SKFieldNodeClass) TurbulenceFieldWithSmoothnessAnimationSpeed

func (_SKFieldNodeClass SKFieldNodeClass) TurbulenceFieldWithSmoothnessAnimationSpeed(smoothness float64, speed float64) SKFieldNode

Creates a field node that applies a randomized acceleration to physics bodies.

smoothness: The smoothness of the noise used to generate the forces. This parameter should be a value between `0.0` and `1.0`, where `1.0` represents a uniform smoothness.

speed: The speed at which the noise field should change. A value of `0.0` means that the field should not animate at all.

Return Value

A new turbulence field node.

Discussion

The acceleration’s magnitude is proportional to a body’s velocity.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/turbulenceField(withSmoothness:animationSpeed:)

func (SKFieldNodeClass) VelocityFieldWithTexture

func (_SKFieldNodeClass SKFieldNodeClass) VelocityFieldWithTexture(velocityTexture ISKTexture) SKFieldNode

Creates a field node that sets the velocity of physics bodies that enter the node’s area based on the pixel values of a texture.

velocityTexture: A normal texture used to specify the velocities at different points in the field.

Return Value

A new velocity field node.

Discussion

When a physics body is affected, its new velocity in each frame is calculated by performing a texture lookup (treating the value as a normal vector) and then multiplying that vector by the strength of the field. The field has an implicit size (region) equal to the size of the texture; physics bodies outside this area are unaffected by the field node.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/velocityField(with:)

func (SKFieldNodeClass) VelocityFieldWithVector

func (_SKFieldNodeClass SKFieldNodeClass) VelocityFieldWithVector(direction Vector_float3) SKFieldNode

Creates a field node that gives physics bodies a constant velocity.

direction: The velocity that any affected physics bodies will have. The `z` component on the vector is ignored.

Return Value

A new velocity field node.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/velocityField(withVector:)

func (SKFieldNodeClass) VortexField

func (_SKFieldNodeClass SKFieldNodeClass) VortexField() SKFieldNode

Creates a field node that applies a perpendicular force to physics bodies.

Return Value

A new vortex field node.

Discussion

The strength of the field measures the acceleration of the field in meters per second squared (meaning that similar to gravity, all physics bodies are affected equally). The physics body is accelerated along the perpendicular of the line between the field node’s position and the position of the physics body. A positive field strength indicates the body is accelerated in a counter-clockwise direction. The SKFieldNode.Falloff property of a vortex field node is set by default to `2`.

See: https://developer.apple.com/documentation/SpriteKit/SKFieldNode/vortexField()

type SKInterpolationMode

type SKInterpolationMode int

See: https://developer.apple.com/documentation/SpriteKit/SKInterpolationMode

const (
	// SKInterpolationModeLinear: Values between two keyframes are interpolated linearly.
	SKInterpolationModeLinear SKInterpolationMode = 1
	// SKInterpolationModeSpline: Values between two keyframes using a spline curve.
	SKInterpolationModeSpline SKInterpolationMode = 2
	// SKInterpolationModeStep: Values between two keyframes are not interpolated.
	SKInterpolationModeStep SKInterpolationMode = 3
)

func (SKInterpolationMode) String

func (e SKInterpolationMode) String() string

type SKKeyframeSequence

type SKKeyframeSequence struct {
	objectivec.Object
}

An object that performs interpolation between values specified at different times (keyframes).

Overview

The primary use for an SKKeyframeSequence object is to animate properties on particles emitted by an SKEmitterNode object, but it can also be used for your general interpolation needs across a discrete set of inputs.

When a keyframe sequence is used with an emitter node, particles determine their values by sampling the keyframe sequence. The sequence replaces the normal simulation performed by the emitter node.

First Steps

Sequence Building

Sequence Running

Sequence Information

Interpolation Modifiers

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence

func NewKeyframeSequenceWithCapacity

func NewKeyframeSequenceWithCapacity(numItems uint) SKKeyframeSequence

Initializes a new keyframe sequence.

numItems: The initial capacity of the new sequence.

Return Value

A newly initialized empty sequence.

Discussion

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/init(capacity:)

func NewKeyframeSequenceWithKeyframeValuesTimes

func NewKeyframeSequenceWithKeyframeValuesTimes(values foundation.INSArray, times []foundation.NSNumber) SKKeyframeSequence

Initializes a keyframe sequence with an initial set of values and times.

values: An array of value objects that define the keyframe values for the sequence.

times: An array of NSNumber objects containing floating-point values that specify the time values for the keyframes.

Return Value

A newly initialized sequence.

Discussion

The two arrays must have an identical number of elements. The keyframes in the new sequence are stored in the same order as the input arrays.

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/init(keyframeValues:times:)

func NewSKKeyframeSequence

func NewSKKeyframeSequence() SKKeyframeSequence

NewSKKeyframeSequence creates a new SKKeyframeSequence instance.

func SKKeyframeSequenceFromID

func SKKeyframeSequenceFromID(id objc.ID) SKKeyframeSequence

SKKeyframeSequenceFromID constructs a SKKeyframeSequence from an objc.ID.

An object that performs interpolation between values specified at different times (keyframes).

func (SKKeyframeSequence) AddKeyframeValueTime

func (k SKKeyframeSequence) AddKeyframeValueTime(value objectivec.IObject, time float64)

Adds a keyframe to the sequence.

value: An object that defines the value to add. It must have the same class as other value objects stored in the sequence.

time: The corresponding time.

Discussion

The new keyframe is appended to the end of the array.

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/addKeyframeValue(_:time:)

func (SKKeyframeSequence) Autorelease

func (k SKKeyframeSequence) Autorelease() SKKeyframeSequence

Autorelease adds the receiver to the current autorelease pool.

func (SKKeyframeSequence) Count

func (k SKKeyframeSequence) Count() uint

The number of keyframes in the sequence.

Return Value

The number of keyframes in the sequence.

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/count()

func (SKKeyframeSequence) EncodeWithCoder

func (k SKKeyframeSequence) EncodeWithCoder(coder foundation.INSCoder)

func (SKKeyframeSequence) GetKeyframeTimeForIndex

func (k SKKeyframeSequence) GetKeyframeTimeForIndex(index uint) float64

Gets the time for a keyframe in the sequence.

index: The index of the keyframe.

Return Value

The time value for the keyframe.

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/getKeyframeTime(for:)

func (SKKeyframeSequence) GetKeyframeValueForIndex

func (k SKKeyframeSequence) GetKeyframeValueForIndex(index uint) objectivec.IObject

Gets the value for a keyframe in the sequence.

index: The index of the keyframe.

Return Value

The value object for the keyframe.

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/getKeyframeValue(for:)

func (SKKeyframeSequence) Init

Init initializes the instance.

func (SKKeyframeSequence) InitWithCapacity

func (k SKKeyframeSequence) InitWithCapacity(numItems uint) SKKeyframeSequence

Initializes a new keyframe sequence.

numItems: The initial capacity of the new sequence.

Return Value

A newly initialized empty sequence.

Discussion

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/init(capacity:)

func (SKKeyframeSequence) InitWithKeyframeValuesTimes

func (k SKKeyframeSequence) InitWithKeyframeValuesTimes(values foundation.INSArray, times []foundation.NSNumber) SKKeyframeSequence

Initializes a keyframe sequence with an initial set of values and times.

values: An array of value objects that define the keyframe values for the sequence.

times: An array of NSNumber objects containing floating-point values that specify the time values for the keyframes.

Return Value

A newly initialized sequence.

Discussion

The two arrays must have an identical number of elements. The keyframes in the new sequence are stored in the same order as the input arrays.

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/init(keyframeValues:times:)

func (SKKeyframeSequence) InterpolationMode

func (k SKKeyframeSequence) InterpolationMode() SKInterpolationMode

The mode used to determine how values for times between the keyframes are calculated.

Discussion

The possible values are defined in SKInterpolationMode. The default value is SKInterpolationMode.linear.

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/interpolationMode

func (SKKeyframeSequence) RemoveKeyframeAtIndex

func (k SKKeyframeSequence) RemoveKeyframeAtIndex(index uint)

Removes a keyframe from the sequence.

index: The index of the keyframe value to remove.

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/removeKeyframe(at:)

func (SKKeyframeSequence) RemoveLastKeyframe

func (k SKKeyframeSequence) RemoveLastKeyframe()

Removes the last value in the sequence.

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/removeLastKeyframe()

func (SKKeyframeSequence) RepeatMode

func (k SKKeyframeSequence) RepeatMode() SKRepeatMode

The mode used to determine how the keyframe sequence repeats.

Discussion

The possible values are defined in SKRepeatMode. The default value is SKRepeatMode.clamp.

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/repeatMode

func (SKKeyframeSequence) SampleAtTime

func (k SKKeyframeSequence) SampleAtTime(time float64) objectivec.IObject

Calculates the sample at a particular time.

time: The time value to sample.

Return Value

An object that contains the interpolated sample. The class of this object matches the class of the values stored in the keyframe sequence — either an NSNumber or an [SKColor].

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/sample(atTime:)

func (SKKeyframeSequence) SetInterpolationMode

func (k SKKeyframeSequence) SetInterpolationMode(value SKInterpolationMode)

func (SKKeyframeSequence) SetKeyframeTimeForIndex

func (k SKKeyframeSequence) SetKeyframeTimeForIndex(time float64, index uint)

Changes the time for a specific keyframe.

time: The new time value for the keyframe.

index: The index of the keyframe to change.

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/setKeyframeTime(_:for:)

func (SKKeyframeSequence) SetKeyframeValueForIndex

func (k SKKeyframeSequence) SetKeyframeValueForIndex(value objectivec.IObject, index uint)

Changes the value for a specific keyframe.

value: The new value for the keyframe.

index: The index of the keyframe to change.

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/setKeyframeValue(_:for:)

func (SKKeyframeSequence) SetKeyframeValueTimeForIndex

func (k SKKeyframeSequence) SetKeyframeValueTimeForIndex(value objectivec.IObject, time float64, index uint)

Replaces a keyframe in the sequence with a new keyframe.

value: The new value for the keyframe.

time: The new time for the keyframe.

index: The index of the keyframe to change.

See: https://developer.apple.com/documentation/SpriteKit/SKKeyframeSequence/setKeyframeValue(_:time:for:)

func (SKKeyframeSequence) SetRepeatMode

func (k SKKeyframeSequence) SetRepeatMode(value SKRepeatMode)

type SKKeyframeSequenceClass

type SKKeyframeSequenceClass struct {
	// contains filtered or unexported fields
}

func GetSKKeyframeSequenceClass

func GetSKKeyframeSequenceClass() SKKeyframeSequenceClass

GetSKKeyframeSequenceClass returns the class object for SKKeyframeSequence.

func (SKKeyframeSequenceClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKKeyframeSequenceClass) Class

func (sc SKKeyframeSequenceClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKLabelHorizontalAlignmentMode

type SKLabelHorizontalAlignmentMode int

See: https://developer.apple.com/documentation/SpriteKit/SKLabelHorizontalAlignmentMode

const (
	// SKLabelHorizontalAlignmentModeCenter: Centers the text horizontally on the node’s origin.
	SKLabelHorizontalAlignmentModeCenter SKLabelHorizontalAlignmentMode = 0
	// SKLabelHorizontalAlignmentModeLeft: Positions the text so that the left side of the text is on the node’s origin.
	SKLabelHorizontalAlignmentModeLeft SKLabelHorizontalAlignmentMode = 1
	// SKLabelHorizontalAlignmentModeRight: Positions the text so that the right side of the text is on the node’s origin.
	SKLabelHorizontalAlignmentModeRight SKLabelHorizontalAlignmentMode = 2
)

func (SKLabelHorizontalAlignmentMode) String

type SKLabelNode

type SKLabelNode struct {
	SKNode
}

A graphical element that draws text.

Overview

SKLabelNode allows you to render text in your scene. You can define a custom style using properties such as SKLabelNode.FontName and SKLabelNode.FontColor, or configure the look of your text with an NSAttributedString.

Creating a Label

Setting a Label’s Text

Specifying a Label’s Font

Controlling a Label’s Alignment

Defining a Label’s Line-Breaking Behavior

Colorizing a Label

Configuring Alpha Blending

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode

func NewLabelNodeWithAttributedText

func NewLabelNodeWithAttributedText(attributedText foundation.NSAttributedString) SKLabelNode

Initializes a new label object with an attributed text string.

attributedText: The attributed string from which to initialize the label.

Return Value

A lable initialized from attributed text.

Discussion

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/init(attributedText:)

func NewLabelNodeWithCoder

func NewLabelNodeWithCoder(aDecoder foundation.INSCoder) SKLabelNode

Called when a node is initialized from an .sks file.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(coder:)

func NewLabelNodeWithFileNamed

func NewLabelNodeWithFileNamed(filename string) SKLabelNode

Creates a new node by loading an archive file from the game’s main bundle.

filename: The name of the file, without a file extension. The file must be in the app’s main bundle and have a `XCUIElementTypeSks` filename extension.

Return Value

The unarchived node object.

Discussion

If you call this method on a subclass of the SKScene class and the object in the archive is an SKScene object, the returned object is initialized as if it is a member of the subclass. You use this behavior to create scene layouts in the Xcode Editor and provide custom behaviors in your subclass.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(fileNamed:)

func NewLabelNodeWithFontNamed

func NewLabelNodeWithFontNamed(fontName string) SKLabelNode

Initializes a new label object with a specified font.

fontName: The name of the font used by the label.

Return Value

An initialized label object.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/init(fontNamed:)

func NewLabelNodeWithText

func NewLabelNodeWithText(text string) SKLabelNode

Initializes a new label object with a text string.

text: The text to use to initialize the label node.

Return Value

An initialized label object.

Discussion

The label node’s font is set to Helvetica Neue Ultra Light, 32 point.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/init(text:)

func NewSKLabelNode

func NewSKLabelNode() SKLabelNode

NewSKLabelNode creates a new SKLabelNode instance.

func SKLabelNodeFromID

func SKLabelNodeFromID(id objc.ID) SKLabelNode

SKLabelNodeFromID constructs a SKLabelNode from an objc.ID.

A graphical element that draws text.

func (SKLabelNode) AttributedText

func (l SKLabelNode) AttributedText() foundation.NSAttributedString

The attributed string displayed by the label.

Discussion

The following properties are ignored if attributedText is defined:

[Table data omitted]

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/attributedText

func (SKLabelNode) Autorelease

func (l SKLabelNode) Autorelease() SKLabelNode

Autorelease adds the receiver to the current autorelease pool.

func (SKLabelNode) BlendMode

func (l SKLabelNode) BlendMode() SKBlendMode

The blend mode used to draw the label into the parent’s framebuffer.

Discussion

The default value is SKBlendMode.alpha.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/blendMode

func (SKLabelNode) Color

func (l SKLabelNode) Color() appkit.NSColor

An alternative to the font color that can be used for animations.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/color

func (SKLabelNode) ColorBlendFactor

func (l SKLabelNode) ColorBlendFactor() float64

A floating-point value that describes how the color is blended with the font color.

Discussion

The value must be a number between `0.0` and `1.0`, inclusive. The default value (`0.0`) indicates that the color property is ignored and that the label’s font color should be used unmodified. For values greater than `0.0`, the font color is blended with the blend color, with the maximum value of 1.0 determining that the font color is 100% of the blend color.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/colorBlendFactor

func (SKLabelNode) FontColor

func (l SKLabelNode) FontColor() appkit.NSColor

The color of the label.

Discussion

The default color is white.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/fontColor

func (SKLabelNode) FontName

func (l SKLabelNode) FontName() string

The font used for the text in the label.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/fontName

func (SKLabelNode) FontSize

func (l SKLabelNode) FontSize() float64

The size of the font used in the label.

Discussion

The default font size is 32 points.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/fontSize

func (SKLabelNode) HorizontalAlignmentMode

func (l SKLabelNode) HorizontalAlignmentMode() SKLabelHorizontalAlignmentMode

The horizontal position of the text within the node.

Discussion

The possible values for this property are listed in SKLabelHorizontalAlignmentMode. The default value of this property is SKLabelHorizontalAlignmentMode.center.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/horizontalAlignmentMode

func (SKLabelNode) Init

func (l SKLabelNode) Init() SKLabelNode

Init initializes the instance.

func (SKLabelNode) InitWithFontNamed

func (l SKLabelNode) InitWithFontNamed(fontName string) SKLabelNode

Initializes a new label object with a specified font.

fontName: The name of the font used by the label.

Return Value

An initialized label object.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/init(fontNamed:)

func (SKLabelNode) LineBreakMode

func (l SKLabelNode) LineBreakMode() appkit.NSLineBreakMode

Determines the line-break mode for multiple lines.

Discussion

The default value is NSLineBreakByTruncatingTail.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/lineBreakMode

func (SKLabelNode) NumberOfLines

func (l SKLabelNode) NumberOfLines() int

Determines the number of lines to draw.

Discussion

The default value is 1 (a single line). A value of 0 in interpreted as an unlimited number of lines. If the height of the text reaches the number of lines, the text will be truncated using the line break mode.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/numberOfLines

func (SKLabelNode) PreferredMaxLayoutWidth

func (l SKLabelNode) PreferredMaxLayoutWidth() float64

The width, in screen points, after which line-break mode should be applied.

Discussion

The default value is 0, which means that line break mode will not be applied.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/preferredMaxLayoutWidth

func (SKLabelNode) SetAttributedText

func (l SKLabelNode) SetAttributedText(value foundation.NSAttributedString)

func (SKLabelNode) SetBlendMode

func (l SKLabelNode) SetBlendMode(value SKBlendMode)

func (SKLabelNode) SetColor

func (l SKLabelNode) SetColor(value appkit.NSColor)

func (SKLabelNode) SetColorBlendFactor

func (l SKLabelNode) SetColorBlendFactor(value float64)

func (SKLabelNode) SetFontColor

func (l SKLabelNode) SetFontColor(value appkit.NSColor)

func (SKLabelNode) SetFontName

func (l SKLabelNode) SetFontName(value string)

func (SKLabelNode) SetFontSize

func (l SKLabelNode) SetFontSize(value float64)

func (SKLabelNode) SetHorizontalAlignmentMode

func (l SKLabelNode) SetHorizontalAlignmentMode(value SKLabelHorizontalAlignmentMode)

func (SKLabelNode) SetLineBreakMode

func (l SKLabelNode) SetLineBreakMode(value appkit.NSLineBreakMode)

func (SKLabelNode) SetNumberOfLines

func (l SKLabelNode) SetNumberOfLines(value int)

func (SKLabelNode) SetPreferredMaxLayoutWidth

func (l SKLabelNode) SetPreferredMaxLayoutWidth(value float64)

func (SKLabelNode) SetText

func (l SKLabelNode) SetText(value string)

func (SKLabelNode) SetVerticalAlignmentMode

func (l SKLabelNode) SetVerticalAlignmentMode(value SKLabelVerticalAlignmentMode)

func (SKLabelNode) Text

func (l SKLabelNode) Text() string

The string that the label node displays.

Discussion

This property is ignored if attributedText is defined.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/text

func (SKLabelNode) VerticalAlignmentMode

func (l SKLabelNode) VerticalAlignmentMode() SKLabelVerticalAlignmentMode

The vertical position of the text within the node.

Discussion

The possible values for this property are listed in SKLabelVerticalAlignmentMode. The default value of this property is SKLabelVerticalAlignmentMode.baseline.

See: https://developer.apple.com/documentation/SpriteKit/SKLabelNode/verticalAlignmentMode

type SKLabelNodeClass

type SKLabelNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKLabelNodeClass

func GetSKLabelNodeClass() SKLabelNodeClass

GetSKLabelNodeClass returns the class object for SKLabelNode.

func (SKLabelNodeClass) Alloc

func (sc SKLabelNodeClass) Alloc() SKLabelNode

Alloc allocates memory for a new instance of the class.

func (SKLabelNodeClass) Class

func (sc SKLabelNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKLabelVerticalAlignmentMode

type SKLabelVerticalAlignmentMode int

See: https://developer.apple.com/documentation/SpriteKit/SKLabelVerticalAlignmentMode

const (
	// SKLabelVerticalAlignmentModeBaseline: Positions the text so that the font’s baseline lies on the node’s origin.
	SKLabelVerticalAlignmentModeBaseline SKLabelVerticalAlignmentMode = 0
	// SKLabelVerticalAlignmentModeBottom: Positions the text so that the bottom of the text is on the node’s origin.
	SKLabelVerticalAlignmentModeBottom SKLabelVerticalAlignmentMode = 3
	// SKLabelVerticalAlignmentModeCenter: Centers the text vertically on the node’s origin.
	SKLabelVerticalAlignmentModeCenter SKLabelVerticalAlignmentMode = 1
	// SKLabelVerticalAlignmentModeTop: Positions the text so that the top of the text is on the node’s origin.
	SKLabelVerticalAlignmentModeTop SKLabelVerticalAlignmentMode = 2
)

func (SKLabelVerticalAlignmentMode) String

type SKLightNode

type SKLightNode struct {
	SKNode
}

A node that lights surrounding nodes.

Overview

To use lighting, add a light node to the scene. Because lights are nodes, they can be moved or perform actions just like other nodes. However, light nodes are invisible except through their effects on sprite nodes configured to interact with them. When a sprite node is affected by a light, the lighting properties of the light node and the lighting properties of the sprite node determine what is rendered. Lighting may affect how unrelated portions of the scene are rendered. For example, if a sprite is configured to cast a shadow, the shadow is rendered on top of other content.

An SKLightNode object and an SKSpriteNode object add lighting to the scene if all of the following are true:

- The light node and the sprite node are both in the scene. - The light node’s [SKLightNode.Enabled] property is true. - The light node’s SKLightNode.CategoryBitMask property and one of the sprite’s lighting masks are logically combined using an AND operation, and the result is a nonzero number.

SKLightNode describes the different kinds of effects that can be generated by a light, based on which mask is being tested on the sprite.

[Table data omitted]

If any of the criteria are not met, the sprite is considered unlit and is rendered using the default behavior.

Determining Whether a Light Node Is Active

Configuring the Lighting Properties

See: https://developer.apple.com/documentation/SpriteKit/SKLightNode

func NewLightNodeWithCoder

func NewLightNodeWithCoder(aDecoder foundation.INSCoder) SKLightNode

Called when a node is initialized from an .sks file.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(coder:)

func NewLightNodeWithFileNamed

func NewLightNodeWithFileNamed(filename string) SKLightNode

Creates a new node by loading an archive file from the game’s main bundle.

filename: The name of the file, without a file extension. The file must be in the app’s main bundle and have a `XCUIElementTypeSks` filename extension.

Return Value

The unarchived node object.

Discussion

If you call this method on a subclass of the SKScene class and the object in the archive is an SKScene object, the returned object is initialized as if it is a member of the subclass. You use this behavior to create scene layouts in the Xcode Editor and provide custom behaviors in your subclass.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(fileNamed:)

func NewSKLightNode

func NewSKLightNode() SKLightNode

NewSKLightNode creates a new SKLightNode instance.

func SKLightNodeFromID

func SKLightNodeFromID(id objc.ID) SKLightNode

SKLightNodeFromID constructs a SKLightNode from an objc.ID.

A node that lights surrounding nodes.

func (SKLightNode) AmbientColor

func (l SKLightNode) AmbientColor() appkit.NSColor

The ambient color of the light.

Discussion

The alpha value of the color is ignored. The default color is black, meaning that the light does not have an ambient component. The ambient component of the light is not affected by the light’s SKLightNode.Falloff property, nor is it affected by any normal map (SKSpriteNode.NormalTexture) on the sprite node.

See: https://developer.apple.com/documentation/SpriteKit/SKLightNode/ambientColor

func (SKLightNode) Autorelease

func (l SKLightNode) Autorelease() SKLightNode

Autorelease adds the receiver to the current autorelease pool.

func (SKLightNode) CategoryBitMask

func (l SKLightNode) CategoryBitMask() uint32

A mask that defines which categories this light belongs to.

Discussion

Every light in a scene can be assigned to up to 32 different categories, each corresponding to a bit in the bit mask. SpriteKit does not predefine any lighting categories, so it is up to you to define which values are used in your game. When a scene is rendered, a light’s SKLightNode.CategoryBitMask property is compared to each sprite node’s SKSpriteNode.LightingBitMask, SKSpriteNode.ShadowCastBitMask, and SKSpriteNode.ShadowedBitMask properties to determine whether that sprite interacts with the light.

The default value is `0x00000001`.

See: https://developer.apple.com/documentation/SpriteKit/SKLightNode/categoryBitMask

func (SKLightNode) Falloff

func (l SKLightNode) Falloff() float64

The exponent for the rate of decay of the light source.

Discussion

The default value is `1.0`, which means the light decays linearly with distance. The value must be a positive number less than or equal to `1.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKLightNode/falloff

func (SKLightNode) Init

func (l SKLightNode) Init() SKLightNode

Init initializes the instance.

func (SKLightNode) IsEnabled

func (l SKLightNode) IsEnabled() bool

A Boolean value that indicates whether the node is casting light.

Discussion

If the value is true, the light is enabled and affects sprite nodes in the scene. The default is true.

See: https://developer.apple.com/documentation/SpriteKit/SKLightNode/isEnabled

func (SKLightNode) LightColor

func (l SKLightNode) LightColor() appkit.NSColor

The diffuse and specular color of the light source.

Discussion

The default value is white.

If you are using custom shaders, you can substitute an SKUniform object instead.

See: https://developer.apple.com/documentation/SpriteKit/SKLightNode/lightColor

func (SKLightNode) SetAmbientColor

func (l SKLightNode) SetAmbientColor(value appkit.NSColor)

func (SKLightNode) SetCategoryBitMask

func (l SKLightNode) SetCategoryBitMask(value uint32)

func (SKLightNode) SetEnabled

func (l SKLightNode) SetEnabled(value bool)

func (SKLightNode) SetFalloff

func (l SKLightNode) SetFalloff(value float64)

func (SKLightNode) SetLightColor

func (l SKLightNode) SetLightColor(value appkit.NSColor)

func (SKLightNode) SetShadowColor

func (l SKLightNode) SetShadowColor(value appkit.NSColor)

func (SKLightNode) ShadowColor

func (l SKLightNode) ShadowColor() appkit.NSColor

The color of any shadow cast by a sprite.

Discussion

The default color is black with an opacity (alpha) of `0.5`.

When lighting is calculated, shadows are created as if a ray was cast out from the light node’s position. If a sprite casts a shadow, the rays are blocked when they intersect with the sprite’s physics body. Otherwise, the sprite’s texture is used to generate a mask, and any pixel in the sprite node’s texture that has an alpha value that is nonzero blocks the light.

Shadows may be cast on content that is rendered prior to the sprite, even if that content does not otherwise interact with the light.

See: https://developer.apple.com/documentation/SpriteKit/SKLightNode/shadowColor

type SKLightNodeClass

type SKLightNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKLightNodeClass

func GetSKLightNodeClass() SKLightNodeClass

GetSKLightNodeClass returns the class object for SKLightNode.

func (SKLightNodeClass) Alloc

func (sc SKLightNodeClass) Alloc() SKLightNode

Alloc allocates memory for a new instance of the class.

func (SKLightNodeClass) Class

func (sc SKLightNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKMutableTexture

type SKMutableTexture struct {
	SKTexture
}

A texture whose contents can be dynamically updated.

Overview

Normally, SpriteKit textures (SKTexture objects) are static, meaning that once created, their contents cannot be changed. This is important because a static image can be more efficiently managed inside the graphics hardware. However, sometimes you need to be able to update the contents of a texture dynamically. In this case, you should use a mutable texture. Because there is a performance penalty for updating the texture’s contents, consider other options first. For example, you can render a texture in hardware using the SKView.TextureFromNode method and a node tree.

To use this class, create a mutable texture using either one of its creation methods or those of its superclass. Then, when you need to update the mutable texture object’s contents, call the SKMutableTexture.ModifyPixelDataWithBlock method. Your block is called with the location of the texture in memory. Your block should update this texture and then return.

Creating an Empty Mutable Texture

Modifying a Mutable Texture’s Contents

See: https://developer.apple.com/documentation/SpriteKit/SKMutableTexture

func NewMutableTextureWithSize

func NewMutableTextureWithSize(size corefoundation.CGSize) SKMutableTexture

Initializes an empty texture with a specific size.

size: The size of the texture, in pixels.

Return Value

An empty mutable texture.

Discussion

You must call the SKMutableTexture.ModifyPixelDataWithBlock method at least once before using this texture.

See: https://developer.apple.com/documentation/SpriteKit/SKMutableTexture/init(size:)

func NewMutableTextureWithSizePixelFormat

func NewMutableTextureWithSizePixelFormat(size corefoundation.CGSize, format int32) SKMutableTexture

Initializes an empty texture with a specific size and format.

size: The size of the texture, in pixels.

format: A Core Video format code. Three codes are supported: kCVPixelFormatType_32RGBA, kCVPixelFormatType_64RGBAHalf, and kCVPixelFormatType_128RGBAFloat for byte, half-float, and float components respectively.

Return Value

An empty mutable texture.

Discussion

You must call the SKMutableTexture.ModifyPixelDataWithBlock method at least once before using this texture.

See: https://developer.apple.com/documentation/SpriteKit/SKMutableTexture/init(size:pixelFormat:)

func NewSKMutableTexture

func NewSKMutableTexture() SKMutableTexture

NewSKMutableTexture creates a new SKMutableTexture instance.

func SKMutableTextureFromID

func SKMutableTextureFromID(id objc.ID) SKMutableTexture

SKMutableTextureFromID constructs a SKMutableTexture from an objc.ID.

A texture whose contents can be dynamically updated.

func (SKMutableTexture) Autorelease

func (m SKMutableTexture) Autorelease() SKMutableTexture

Autorelease adds the receiver to the current autorelease pool.

func (SKMutableTexture) Init

Init initializes the instance.

func (SKMutableTexture) InitWithSize

Initializes an empty texture with a specific size.

size: The size of the texture, in pixels.

Return Value

An empty mutable texture.

Discussion

You must call the SKMutableTexture.ModifyPixelDataWithBlock method at least once before using this texture.

See: https://developer.apple.com/documentation/SpriteKit/SKMutableTexture/init(size:)

func (SKMutableTexture) InitWithSizePixelFormat

func (m SKMutableTexture) InitWithSizePixelFormat(size corefoundation.CGSize, format int32) SKMutableTexture

Initializes an empty texture with a specific size and format.

size: The size of the texture, in pixels.

format: A Core Video format code. Three codes are supported: kCVPixelFormatType_32RGBA, kCVPixelFormatType_64RGBAHalf, and kCVPixelFormatType_128RGBAFloat for byte, half-float, and float components respectively.

Return Value

An empty mutable texture.

Discussion

You must call the SKMutableTexture.ModifyPixelDataWithBlock method at least once before using this texture.

See: https://developer.apple.com/documentation/SpriteKit/SKMutableTexture/init(size:pixelFormat:)

func (SKMutableTexture) ModifyPixelDataWithBlock

func (m SKMutableTexture) ModifyPixelDataWithBlock(block UnsafePointerUintptrHandler)

Modifies the contents of a mutable texture.

block: A block to be called when the texture can be safely modified. The block takes the following parameters:

pixelData: A pointer to the start of the current texture data. lengthInBytes: The length of the texture data in bytes.

Discussion

The contents of the texture can be modified only at specific times when the graphics hardware permits it. When this method is called, it schedules a new background task to update the texture and then returns. Your block is called when the texture can be modified. Your block is called on an arbitrary queue. Your block should modify the texture’s contents and then return.

The texture bytes are assumed to be stored as tightly packed 32 bpp, 8bpc (unsigned integer) RGBA pixel data. The color components you provide should have already been multiplied by the alpha value.

See: https://developer.apple.com/documentation/SpriteKit/SKMutableTexture/modifyPixelData(_:)

type SKMutableTextureClass

type SKMutableTextureClass struct {
	// contains filtered or unexported fields
}

func GetSKMutableTextureClass

func GetSKMutableTextureClass() SKMutableTextureClass

GetSKMutableTextureClass returns the class object for SKMutableTexture.

func (SKMutableTextureClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKMutableTextureClass) Class

func (sc SKMutableTextureClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKNode

type SKNode struct {
	objectivec.Object
}

The base class of all SpriteKit nodes.

Overview

SKNode provides base properties for its subclasses and it can be used as a container or layout tool for other nodes. For example, you might add a collection of nodes as children to an SKNode that all move together within the scene; because nodes inherit the properties of their parent, changing the parent node’s SKNode.Position propagates the change to its children as well.

SKNode does not draw any content itself. Its visual counterparts are listed in Nodes that Draw in Nodes for Scene Building.

First Steps

Positioning Content in a Scene

Querying the Content Size

  • SKNode.Frame: A rectangle in the parent’s coordinate system that contains the node’s content, ignoring the node’s children.
  • SKNode.CalculateAccumulatedFrame: Returns a rectangle in the parent’s coordinate system that contains the position and size of itself and all child nodes.

Configuring Draw Order

Scaling and Rotating

Modifying the Node Tree

Accessing Nodes by Name

Altering Node Visibility

Running Actions

Adding Physics Behaviors

Constraining Node Position or Rotation

Detecting Collisions Manually

  • SKNode.IntersectsNode: Returns a Boolean value that indicates whether this node intersects the specified node.

Adding GameplayKit Behaviors

Handling User Input

Hit Testing

  • SKNode.ContainsPoint: Returns a Boolean value that indicates whether a point lies inside the parent’s coordinate system.
  • SKNode.NodeAtPoint: Returns the deepest visible descendant that intersects a point.
  • SKNode.NodesAtPoint: Returns an array of all visible descendants that intersect a point.

Converting Between Coordinate Systems of Different Nodes

  • SKNode.ConvertPointFromNode: Converts a point from the coordinate system of another node in the node tree to the coordinate system of this node.
  • SKNode.ConvertPointToNode: Converts a point in this node’s coordinate system to the coordinate system of another node in the node tree.

Adding Custom Data Without Subclassing

Providing Accessibility

See: https://developer.apple.com/documentation/SpriteKit/SKNode

func NewNodeWithCoder

func NewNodeWithCoder(aDecoder foundation.INSCoder) SKNode

Called when a node is initialized from an .sks file.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(coder:)

func NewNodeWithFileNamed

func NewNodeWithFileNamed(filename string) SKNode

Creates a new node by loading an archive file from the game’s main bundle.

filename: The name of the file, without a file extension. The file must be in the app’s main bundle and have a `XCUIElementTypeSks` filename extension.

Return Value

The unarchived node object.

Discussion

If you call this method on a subclass of the SKScene class and the object in the archive is an SKScene object, the returned object is initialized as if it is a member of the subclass. You use this behavior to create scene layouts in the Xcode Editor and provide custom behaviors in your subclass.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(fileNamed:)

func NewSKNode

func NewSKNode() SKNode

NewSKNode creates a new SKNode instance.

func SKNodeFromID

func SKNodeFromID(id objc.ID) SKNode

SKNodeFromID constructs a SKNode from an objc.ID.

The base class of all SpriteKit nodes.

func (SKNode) AccessibilityChildren

func (n SKNode) AccessibilityChildren() foundation.INSArray

An array of user interface elements that represent children of this element.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/accessibilityChildren

func (SKNode) AccessibilityFrame

func (n SKNode) AccessibilityFrame() corefoundation.CGRect

The size of this user interface element, in screen points.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/accessibilityFrame

func (SKNode) AccessibilityHelp

func (n SKNode) AccessibilityHelp() string

The help description of this user interface element; for example, the text shown in a tooltip.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/accessibilityHelp

func (SKNode) AccessibilityHitTest

func (n SKNode) AccessibilityHitTest(point corefoundation.CGPoint) objectivec.IObject

Returns the frontmost user interface element in the element hierarchy.

point: Relative to the bottom-left of the screen, in screen points, and guaranteed to lie within the receiver.

Discussion

Override this method to implement your own, deeper hit testing within a user interface element.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/accessibilityHitTest(_:)

func (SKNode) AccessibilityLabel

func (n SKNode) AccessibilityLabel() string

A short description of this user interface element.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/accessibilityLabel

func (SKNode) AccessibilityParent

func (n SKNode) AccessibilityParent() objectivec.IObject

The user interface element that contains this element.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/accessibilityParent

func (SKNode) AccessibilityRole

func (n SKNode) AccessibilityRole() string

A string value describing the user interface element type; for example, a button.

Discussion

See Roles for more information.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/accessibilityRole

func (SKNode) AccessibilityRoleDescription

func (n SKNode) AccessibilityRoleDescription() string

A string value describing the user interface element name and type; for example, the Buy button.

Discussion

See Roles for more information.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/accessibilityRoleDescription

func (SKNode) AccessibilitySubrole

func (n SKNode) AccessibilitySubrole() string

A string that defines this user interface element’s subrole; for example, a full-screen button.

Discussion

See [Subroles] for more information.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/accessibilitySubrole

func (SKNode) ActionForKey

func (n SKNode) ActionForKey(key string) ISKAction

Returns an action associated with a specific key.

key: A string that uniquely identifies an action.

Return Value

If an action exists that matches the key, the action object is returned. Otherwise, `nil` is returned.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/action(forKey:)

func (SKNode) AddChild

func (n SKNode) AddChild(node ISKNode)

Adds a node to the end of the receiver’s list of child nodes.

node: The node to add. The node must not already have a parent.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/addChild(_:)

func (SKNode) Alpha

func (n SKNode) Alpha() float64

The transparency value applied to the node’s contents.

Discussion

The default value is `1.0`.

The SKNode class does not perform drawing, but many of its subclasses do. When a node or any of its descendants are drawn, the alpha component of each pixel is multiplied by the node’s SKNode.Alpha property and then clamped to the range `0.0`-`1.0`. This modified alpha value is used to blend the pixel into the framebuffer. Subclasses that render content define properties that determine the blending operations used in conjunction with the alpha value to blend pixels into the parent’s framebuffer.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/alpha

func (SKNode) Autorelease

func (n SKNode) Autorelease() SKNode

Autorelease adds the receiver to the current autorelease pool.

func (SKNode) CalculateAccumulatedFrame

func (n SKNode) CalculateAccumulatedFrame() corefoundation.CGRect

Returns a rectangle in the parent’s coordinate system that contains the position and size of itself and all child nodes.

Discussion

The frame takes into the account the cumulative effect of the SKNode.XScale, SKNode.YScale, and SKNode.ZRotation properties of each node in the subtree.

Listing 1 shows, in Swift, how SKNode.CalculateAccumulatedFrame can be used display the bounding box of a shape node. The child node, although smaller than its parent, is rotated by 30° so that its bounds extend beyond its parent’s bounds. After `childNode` has been added to `parentNode`, a further shape node, `boundingBoxNode`, is created with its size based on the accumulated frame of parentNode.

Listing 1. Displaying the accumulated frame of a shape node

The figure below shows the result of Listing 1 with `parentNode` rendered in blue, `childNode` rendered in red and the `boundingBoxNode` rendered with a dashed line.

[media-2793217]

See: https://developer.apple.com/documentation/SpriteKit/SKNode/calculateAccumulatedFrame()

func (SKNode) ChildNodeWithName

func (n SKNode) ChildNodeWithName(name string) ISKNode

Searches the children of the receiving node for a node with a specific name.

name: The name to search for. This may be either the literal name of the node or a customized search string. See `Searching the Node Tree`.

Return Value

If a node object with that name is found, the method returns the node object. Otherwise, it returns `nil`.

Discussion

If more than one child share the same name, the first node discovered is returned.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/childNode(withName:)

func (SKNode) Children

func (n SKNode) Children() []SKNode

The node’s children.

Discussion

The objects in this array are all SKNode objects.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/children

func (SKNode) Constraints

func (n SKNode) Constraints() []SKConstraint

A list of constraints to apply to the node.

Discussion

Assign an array of SKConstraint objects to the node. The scene processes these constraints before the scene is rendered. The constraints are processed in array order. If multiple nodes in the node tree have constraints, there is no guaranteed order that the nodes are processed in.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/constraints

func (SKNode) ContainsPoint

func (n SKNode) ContainsPoint(p corefoundation.CGPoint) bool

Returns a Boolean value that indicates whether a point lies inside the parent’s coordinate system.

p: A [CGPoint] to test against.

Return Value

true if the point lies inside the parent’s coordinate system; otherwise false.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/contains(_:)

func (SKNode) ConvertPointFromNode

func (n SKNode) ConvertPointFromNode(point corefoundation.CGPoint, node ISKNode) corefoundation.CGPoint

Converts a point from the coordinate system of another node in the node tree to the coordinate system of this node.

point: A point in the other node’s coordinate system.

node: Another node in the same node tree as this node.

Return Value

The same point converted to this node’s coordinate system.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/convert(_:from:)

func (SKNode) ConvertPointToNode

func (n SKNode) ConvertPointToNode(point corefoundation.CGPoint, node ISKNode) corefoundation.CGPoint

Converts a point in this node’s coordinate system to the coordinate system of another node in the node tree.

point: A point in this node’s coordinate system.

node: Another node in the same node tree as this node.

Return Value

The same point converted to the other node’s coordinate system.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/convert(_:to:)

func (SKNode) EncodeWithCoder

func (n SKNode) EncodeWithCoder(coder foundation.INSCoder)

func (SKNode) Entity

func (n SKNode) Entity() objectivec.IObject

The GameplayKit entity this node represents.

Discussion

The Entity-Component architecture in the GameplayKit framework is a way to more easily manage complex object graphs in your game. For more information on this architecture, read Entities and Components in GameplayKit Programming Guide.

When you add entities (and their components) to a scene in the Xcode SpriteKit Scene Editor, Xcode automatically archive those entities alongside the SpriteKit scene content. Use the GKScene class to load the SpriteKit scene with its associated GameplayKit objects. Each entity associated with a SpriteKit node has a GKSKNodeComponent object that manages the relationship between the node and the GKEntity object it represents.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/entity

func (SKNode) EnumerateChildNodesWithNameUsingBlock

func (n SKNode) EnumerateChildNodesWithNameUsingBlock(name string, block SKNodeBoolHandler)

Searches the children of the receiving node to perform processing for nodes that share a name.

name: The name to search for. This may be either the literal name of the node or a customized search string. See `Searching the Node Tree`.

block: A block to execute on nodes that match the `name` parameter. The block has the signature `(` SKNode `, ` UnsafeMutablePointer `)`.

Discussion

This method enumerates the child array in order, searching for nodes whose names match the search parameter. The block is called once for each node that matches the name parameter.

The following Swift code shows how you could enumerate through the child nodes of a scene with a name containing the string `yellow`. Each matching node is hidden until the enumeration finds a node that also contains the string `triangle`. When this node is reached, `stop` is set to true and the processing stops.

Listing 1. Enumerating child nodes

You can also search by class name using SKNode.EnumerateChildNodesWithNameUsingBlock. However, for custom classes, you need to specify the fully annotated class name (i.e. the project name followed by the class name). The following Swift code shows a custom class, [SpaceshipNode], based on SKSpriteNode, and created in a project named [SpaceGame]. The first search fails to return an instance of [SpaceshipNode] added as a child of `parentNode`:

Listing 2. Enumerating child nodes

See: https://developer.apple.com/documentation/SpriteKit/SKNode/enumerateChildNodes(withName:using:)

func (SKNode) Frame

func (n SKNode) Frame() corefoundation.CGRect

A rectangle in the parent’s coordinate system that contains the node’s content, ignoring the node’s children.

Discussion

The frame is the smallest rectangle that contains the node’s content, taking into account the node’s SKNode.XScale, SKNode.YScale, and SKNode.ZRotation properties.

Since SKNode does not draw content of its own, its frame size is arbitrary; it’s the visual subclasses of SKNode that do draw that define the frame’s size with a meaningful value that encloses its visual content.

To get a rect that encloses all the child nodes of an SKNode parent object, use SKNode.CalculateAccumulatedFrame.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/frame

func (SKNode) HasActions

func (n SKNode) HasActions() bool

Returns a Boolean value that indicates whether the node is executing actions.

Return Value

true if the node has any executing actions; otherwise false.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/hasActions()

func (SKNode) InParentHierarchy

func (n SKNode) InParentHierarchy(parent ISKNode) bool

Returns a Boolean value that indicates whether the node is a descendant of the target node.

parent: An SKNode object to test against.

Return Value

true if the node is a descendant of the `parent` node; otherwise false.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/inParentHierarchy(_:)

func (SKNode) Init

func (n SKNode) Init() SKNode

Init initializes the instance.

func (SKNode) InitWithCoder

func (n SKNode) InitWithCoder(aDecoder foundation.INSCoder) SKNode

Called when a node is initialized from an .sks file.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(coder:)

func (SKNode) InsertChildAtIndex

func (n SKNode) InsertChildAtIndex(node ISKNode, index int)

Inserts a node into a specific position in the receiver’s list of child nodes.

node: The node to add. The node must not already have a parent.

index: The position in the array to insert the node.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/insertChild(_:at:)

func (SKNode) IntersectsNode

func (n SKNode) IntersectsNode(node ISKNode) bool

Returns a Boolean value that indicates whether this node intersects the specified node.

node: Another node in the same node tree.

Return Value

true if the two nodes intersect; otherwise false.

Discussion

The two nodes are considered to intersect if their frames intersect. The children of both nodes are ignored in this test.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/intersects(_:)

func (SKNode) IsAccessibilityElement

func (n SKNode) IsAccessibilityElement() bool

A toggle you implement to indicate to the system whether this user interface element should be exposed to the user.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/isAccessibilityElement

func (SKNode) IsAccessibilityEnabled

func (n SKNode) IsAccessibilityEnabled() bool

A toggle you implement to indicate to the system whether this user interface element should respond to user input.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/isAccessibilityEnabled

func (SKNode) IsEqualToNode

func (n SKNode) IsEqualToNode(node ISKNode) bool

Compares the parameter node to the receiving node.

node: The node to compare to the receiving node.

Return Value

true if the node is a descendant of the `parent` node; otherwise false.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/isEqual(to:)

func (SKNode) IsHidden

func (n SKNode) IsHidden() bool

A Boolean value that determines whether a node and its descendants are rendered.

Discussion

When hidden, a node and its descendants are not rendered. However, they still exist in the scene and continue to interact in other ways. For example, the node’s actions still run and the node can still be intersected with other nodes. The default value is false.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/isHidden

func (SKNode) IsPaused

func (n SKNode) IsPaused() bool

A Boolean value that determines whether actions on the node and its descendants are processed.

Discussion

If the value is true, the node (and all of its descendants) are skipped when a scene processes actions.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/isPaused

func (SKNode) IsUserInteractionEnabled

func (n SKNode) IsUserInteractionEnabled() bool

A Boolean value that indicates whether the node receives touch events.

Discussion

The default value is false.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/isUserInteractionEnabled

func (SKNode) MoveToParent

func (n SKNode) MoveToParent(parent ISKNode)

Moves the node to a new parent node in the scene.

parent: An SKNode object to move the receiver to. This node must be in the same scene as the node’s current parent.

Discussion

The node maintains its current position in scene coordinates.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/move(toParent:)

func (SKNode) Name

func (n SKNode) Name() string

The node’s assignable name.

Discussion

This property is used to identify a node in other parts of your game logic. For example, you might use this name as part of collision testing. You can also search for nodes in a tree by their name.

When choosing a name for a node, decide whether each node gets a unique name or whether some nodes will share a common name. If you give the node a unique name, you can find the node later by calling the SKNode.ChildNodeWithName method. If a name is shared by multiple nodes, the name usually means that these are all a similar object type in your game. In this case, you can iterate over those objects by calling the SKNode.EnumerateChildNodesWithNameUsingBlock method.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/name

func (SKNode) NodeAtPoint

func (n SKNode) NodeAtPoint(p corefoundation.CGPoint) ISKNode

Returns the deepest visible descendant that intersects a point.

p: A point in the node’s coordinate system.

Return Value

A descendant in the subtree that intersects the point, or the receiver if no nodes intersect the point. Only nodes that have an [SKNode.Hidden] of `false` and an SKNode.Alpha greater that zero are returned. If multiple descendants intersect the point, the deepest node in the tree is returned. If multiple nodes are at the same level, the intersecting node with the largest z position is returned.

Discussion

A point is considered to be in a node if it lies inside the rectangle returned by the SKNode.CalculateAccumulatedFrame method.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/atPoint(_:)

func (SKNode) NodesAtPoint

func (n SKNode) NodesAtPoint(p corefoundation.CGPoint) []SKNode

Returns an array of all visible descendants that intersect a point.

p: A point in the node’s coordinate system.

Return Value

An array of all SKNode objects in the subtree that intersect the point. Only nodes that have an [SKNode.Hidden] of `false` and an SKNode.Alpha greater that zero are included in the returned array. If no nodes intersect the point, an empty array is returned.

Discussion

A point is considered to be in a node if it lies inside the rectangle returned by the SKNode.CalculateAccumulatedFrame method.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/nodes(at:)

func (SKNode) ObjectForKeyedSubscript

func (n SKNode) ObjectForKeyedSubscript(name string) []SKNode

Returns an array of nodes that match the name parameter.

name: The name to search for. This may be either the literal name of the node or a customized search string. See `Searching the Node Tree`.

Return Value

An array of SKNode objects that match the name. If no matching nodes are found, an empty array is returned.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/subscript(_:)

func (SKNode) Parent

func (n SKNode) Parent() ISKNode

The node’s parent node.

Discussion

If the node is not in a node tree, the value is `nil`.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/parent

func (SKNode) PhysicsBody

func (n SKNode) PhysicsBody() ISKPhysicsBody

The physics body associated with the node.

Discussion

The default value is `nil`, which indicates that the node does not participate in the physics simulation at all. If a physics body is provided, when the scene’s physics are simulated, the physics body updates the node’s position and rotates the node.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/physicsBody

func (SKNode) Position

func (n SKNode) Position() corefoundation.CGPoint

The position of the node in its parent’s coordinate system.

Discussion

The default value is `(0.0,0.0)`.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/position

func (SKNode) ReachConstraints

func (n SKNode) ReachConstraints() ISKReachConstraints

The reach constraints to apply to the node when executing a reach action.

Discussion

To use inverse kinematics, create a new SKReachConstraints object and assign it to this property. When a reach action calculates the new positions of this node, the possible values for this node are restricted to the constraints defined by this object. For more information on the inverse kinematic actions, see SKAction.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/reachConstraints

func (SKNode) RemoveActionForKey

func (n SKNode) RemoveActionForKey(key string)

Removes an action associated with a specific key.

key: A string that uniquely identifies an action.

Discussion

If an action is found that matches the key, it is removed from the node.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/removeAction(forKey:)

func (SKNode) RemoveAllActions

func (n SKNode) RemoveAllActions()

Ends and removes all actions from the node.

Discussion

When an action is removed from the node, any remaining animation the action would perform is skipped; however, previous changes are not reverted. It is possible that an action may make a final change to the scene when removed; if so, it is documented for the specific action in SKAction.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/removeAllActions()

func (SKNode) RemoveAllChildren

func (n SKNode) RemoveAllChildren()

Removes all of the node’s children.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/removeAllChildren()

func (SKNode) RemoveChildrenInArray

func (n SKNode) RemoveChildrenInArray(nodes []SKNode)

Removes a list of children from the receiving node.

nodes: An array of SKNode objects that are all children of the receiving node.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/removeChildren(in:)

func (SKNode) RemoveFromParent

func (n SKNode) RemoveFromParent()

Removes the receiving node from its parent.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/removeFromParent()

func (SKNode) RunAction

func (n SKNode) RunAction(action ISKAction)

Adds an action to the list of actions executed by the node.

action: The action to perform.

Discussion

The new action is processed the next time the scene’s animation loop is processed.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/run(_:)

func (SKNode) RunActionCompletion

func (n SKNode) RunActionCompletion(action ISKAction, block VoidHandler)

Adds an action to the list of actions executed by the node and schedules the argument block to be run upon completion of the action.

action: The action to perform.

block: A completion block called when the action completes.

Discussion

See: https://developer.apple.com/documentation/SpriteKit/SKNode/run(_:completion:)

func (SKNode) RunActionCompletionSync

func (n SKNode) RunActionCompletionSync(ctx context.Context, action ISKAction) error

RunActionCompletionSync is a synchronous wrapper around SKNode.RunActionCompletion. It blocks until the completion handler fires or the context is cancelled.

func (SKNode) RunActionWithKey

func (n SKNode) RunActionWithKey(action ISKAction, key string)

Adds an identifiable action to the list of actions executed by the node.

action: The action to perform.

key: A unique key used to identify the action.

Discussion

This method is identical to SKNode.RunAction, but the action is stored so that it can be retrieved later. If an action using the same key is already running, it is removed before the new action is added.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/run(_:withKey:)

func (SKNode) Scene

func (n SKNode) Scene() ISKScene

The scene node that contains this node.

Discussion

If the node is not embedded in a scene, the value is `nil`.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/scene

func (SKNode) SetAccessibilityChildren

func (n SKNode) SetAccessibilityChildren(value foundation.INSArray)

func (SKNode) SetAccessibilityElement

func (n SKNode) SetAccessibilityElement(value bool)

func (SKNode) SetAccessibilityEnabled

func (n SKNode) SetAccessibilityEnabled(value bool)

func (SKNode) SetAccessibilityFrame

func (n SKNode) SetAccessibilityFrame(value corefoundation.CGRect)

func (SKNode) SetAccessibilityHelp

func (n SKNode) SetAccessibilityHelp(value string)

func (SKNode) SetAccessibilityLabel

func (n SKNode) SetAccessibilityLabel(value string)

func (SKNode) SetAccessibilityParent

func (n SKNode) SetAccessibilityParent(value objectivec.IObject)

func (SKNode) SetAccessibilityRole

func (n SKNode) SetAccessibilityRole(value string)

func (SKNode) SetAccessibilityRoleDescription

func (n SKNode) SetAccessibilityRoleDescription(value string)

func (SKNode) SetAccessibilitySubrole

func (n SKNode) SetAccessibilitySubrole(value string)

func (SKNode) SetAlpha

func (n SKNode) SetAlpha(value float64)

func (SKNode) SetConstraints

func (n SKNode) SetConstraints(value []SKConstraint)

func (SKNode) SetEntity

func (n SKNode) SetEntity(value objectivec.IObject)

func (SKNode) SetHidden

func (n SKNode) SetHidden(value bool)

func (SKNode) SetName

func (n SKNode) SetName(value string)

func (SKNode) SetPaused

func (n SKNode) SetPaused(value bool)

func (SKNode) SetPhysicsBody

func (n SKNode) SetPhysicsBody(value ISKPhysicsBody)

func (SKNode) SetPosition

func (n SKNode) SetPosition(value corefoundation.CGPoint)

func (SKNode) SetReachConstraints

func (n SKNode) SetReachConstraints(value ISKReachConstraints)

func (SKNode) SetScale

func (n SKNode) SetScale(scale float64)

Sets the SKNode.XScale and SKNode.YScale properties of the node.

scale: The new value to use for the node’s SKNode.XScale and SKNode.YScale properties.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/setScale(_:)

func (SKNode) SetSpeed

func (n SKNode) SetSpeed(value float64)

func (SKNode) SetUserData

func (n SKNode) SetUserData(value foundation.INSDictionary)

func (SKNode) SetUserInteractionEnabled

func (n SKNode) SetUserInteractionEnabled(value bool)

func (SKNode) SetXScale

func (n SKNode) SetXScale(value float64)

func (SKNode) SetYScale

func (n SKNode) SetYScale(value float64)

func (SKNode) SetZPosition

func (n SKNode) SetZPosition(value float64)

func (SKNode) SetZRotation

func (n SKNode) SetZRotation(value float64)

func (SKNode) Speed

func (n SKNode) Speed() float64

A speed modifier applied to all actions executed by a node and its descendants.

Discussion

The default value is `1.0`, which means that all actions run at their normal speed. If you set a different speed, time appears to run faster or slower for all actions executed on the node and its descendants. For example, if you set a speed value of `2.0`, actions run twice as fast.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/speed

func (SKNode) UserData

func (n SKNode) UserData() foundation.INSDictionary

A dictionary containing arbitrary data.

Discussion

You use this property to store your own data in a node. For example, you might store game-specific data about each node to use inside your game logic. This can be a useful alternative to creating your own node subclasses to hold game data.

SpriteKit does not do anything with the data stored in the node. However, the data is archived when the node is archived.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/userData

func (SKNode) XScale

func (n SKNode) XScale() float64

A scaling factor that multiplies the width of a node and its children.

Discussion

The SKNode.XScale property scales the width of the node and all of its descendants. The scale value affects how a node’s frame is calculated, its hit test area, how it is drawn, and other similar characteristics. The default value is `1.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/xScale

func (SKNode) YScale

func (n SKNode) YScale() float64

A scaling factor that multiplies the height of a node and its children.

Discussion

The SKNode.YScale property scales the height of the node and all of its descendants. The scale value affects how a node’s frame is calculated, its hit test area, how it is drawn, and other similar characteristics. The default value is `1.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/yScale

func (SKNode) ZPosition

func (n SKNode) ZPosition() float64

The height of the node relative to its parent.

Discussion

The default value is `0.0`. The positive z axis is projected toward the viewer so that nodes with larger z-position values are closer to the viewer. When a node tree is rendered, the height of each node (in absolute coordinates) is calculated and then all nodes in the tree are rendered from smallest z-position value to largest z-position value. If multiple nodes share the same z-position, those nodes are sorted so that parent nodes are drawn before their children, and siblings are rendered in the order that they appear in their parent’s SKNode.Children array. Hit-testing is processed in the opposite order.

The SKView class’s SKView.IgnoresSiblingOrder property controls whether node sorting is enabled for nodes at the same z-position.

Using a Node’s Depth to Add Effects

SpriteKit uses the SKNode.ZPosition value only to determine the hit testing and drawing order. You can also the z position to implement your own game effects. For example, you might use the height of a node to determine how it is rendered or how it moves onscreen. In this way, you can simulate fog or parallax effects. SpriteKit does not create these effects for you. Usually, you implement them by processing the scene immediately before it is rendered.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/zPosition

func (SKNode) ZRotation

func (n SKNode) ZRotation() float64

The Euler rotation about the z axis (in radians).

Discussion

The default value is `0.0`, which indicates no rotation. A positive value indicates a counterclockwise rotation. When the coordinate system is rotated, it affects the node and its descendants. The rotation affects the node’s SKNode.Frame property, hit testing, rendering, and other similar characteristics.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/zRotation

type SKNodeBoolHandler

type SKNodeBoolHandler = func(*SKNode, *bool)

SKNodeBoolHandler handles A block to execute on nodes that match the `name` parameter.

Used by:

type SKNodeClass

type SKNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKNodeClass

func GetSKNodeClass() SKNodeClass

GetSKNodeClass returns the class object for SKNode.

func (SKNodeClass) Alloc

func (sc SKNodeClass) Alloc() SKNode

Alloc allocates memory for a new instance of the class.

func (SKNodeClass) Class

func (sc SKNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (SKNodeClass) ObstaclesFromNodeBounds

func (_SKNodeClass SKNodeClass) ObstaclesFromNodeBounds(nodes []SKNode) []objectivec.IObject

Converts each node into an obstacle by transforming its bounds into the scene’s coordinate system.

nodes: An array of SKNode objects.

Return Value

An array of GKPolygonObstacle objects.

Discussion

Use the array of obstacles to create an obstacle graph (GKObstacleGraph) in GameplayKit. See GameplayKit and GameplayKit Programming Guide.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/obstacles(fromNodeBounds:)

func (SKNodeClass) ObstaclesFromNodePhysicsBodies

func (_SKNodeClass SKNodeClass) ObstaclesFromNodePhysicsBodies(nodes []SKNode) []objectivec.IObject

Converts each node into an obstacle by transforming the node’s physics body shape into the scene’s coordinate system.

nodes: An array of SKNode objects.

Return Value

An array of GKPolygonObstacle objects.

Discussion

Use the array of obstacles to create an obstacle graph (GKObstacleGraph) in GameplayKit. See GameplayKit and GameplayKit Programming Guide.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/obstacles(fromNodePhysicsBodies:)

func (SKNodeClass) ObstaclesFromSpriteTexturesAccuracy

func (_SKNodeClass SKNodeClass) ObstaclesFromSpriteTexturesAccuracy(sprites []SKNode, accuracy float32) []objectivec.IObject

Turns each node into an obstacle by changing the node’s texture into a physics shape and converting it into the scene’s coordinate system.

sprites: An array of SKNode objects.

accuracy: A floating point value between `0.001` and `1.0`, inclusive. Higher values create a more precise (but more complex) representation of the obstacle.

Return Value

An array of GKPolygonObstacle objects.

Discussion

Use the array of obstacles to create an obstacle graph (GKObstacleGraph) in GameplayKit. See GameplayKit and GameplayKit Programming Guide.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/obstacles(fromSpriteTextures:accuracy:)

type SKNodeFocusBehavior

type SKNodeFocusBehavior int

See: https://developer.apple.com/documentation/SpriteKit/SKNodeFocusBehavior

const (
	// SKNodeFocusBehaviorFocusable: Node is focusable and prevents nodes that it visually obscures from becoming focusable.
	SKNodeFocusBehaviorFocusable SKNodeFocusBehavior = 2
	// SKNodeFocusBehaviorNone: Node is not focusable.
	SKNodeFocusBehaviorNone SKNodeFocusBehavior = 0
	// SKNodeFocusBehaviorOccluding: Node is not focusable and prevents nodes that it visually obscures from becoming focusable.
	SKNodeFocusBehaviorOccluding SKNodeFocusBehavior = 1
)

func (SKNodeFocusBehavior) String

func (e SKNodeFocusBehavior) String() string

type SKParticleRenderOrder

type SKParticleRenderOrder uint

See: https://developer.apple.com/documentation/SpriteKit/SKParticleRenderOrder

const (
	// SKParticleRenderOrderDontCare: The particles can be rendered in any order.
	SKParticleRenderOrderDontCare SKParticleRenderOrder = 2
	// SKParticleRenderOrderOldestFirst: The particles are rendered from oldest to newest.
	SKParticleRenderOrderOldestFirst SKParticleRenderOrder = 1
	// SKParticleRenderOrderOldestLast: The particles are rendered from newest to oldest.
	SKParticleRenderOrderOldestLast SKParticleRenderOrder = 0
)

func (SKParticleRenderOrder) String

func (e SKParticleRenderOrder) String() string

type SKPhysicsBody

type SKPhysicsBody struct {
	objectivec.Object
}

An object that adds physics simulation to a node.

Overview

Assign a SKPhysicsBody object to the SKNode.PhysicsBody property of the SKNode object to add physics simulation to the node. When a scene processes a new frame, it performs physics calculations on physics bodies attached to nodes in the scene. These calculations include gravity, friction, and collisions with other bodies. You can also apply your own forces and impulses to a body. After the scene completes these calculations, it updates the positions and orientations of the node objects.

SpriteKit supports two kinds of physics bodies, volume-based bodies and edge-based bodies. When you create a physics body, its kind, size, and shape are determined by the constructor method you call. An edge-based body does not have mass or volume and is unaffected by forces or impulses in the system. Edge-based bodies are used to represent volumeless boundaries or hollow spaces in your physics simulation. In contrast, volume-based bodies are used to represent objects with mass and volume. The [SKPhysicsBody.Dynamic] property controls whether a volume-based body is affected by gravity, friction, collisions with other objects, and forces or impulses you directly apply to it.

The SKPhysicsBody class defines the physical characteristics for the body when it is simulated by the scene. For volume-based bodies, the most important property is the SKPhysicsBody.Mass property. A volume-based body is assumed to have a uniform density. You can either set the SKPhysicsBody.Mass property directly, or you can set the body’s SKPhysicsBody.Density property and let the physics body calculate its own mass. All values in Sprite Kit are specified using the International System of Units (SI units). The actual forces and mass values are not important so long as your game uses consistent values.

When you design a game that uses physics, you define the different categories of physics objects that appear in the scene. You define up to 32 different categories of physics bodies, and a body can be assigned to as many of these categories as you want. In addition to declaring its own categories, a physics body also declares which categories of bodies it interacts with. See SKPhysicsBody. You use a similar mechanism to declare which physics field nodes (SKFieldNode) can affect the physics body.

For a volume-based body, you can dynamically control how the body is affected by forces or collisions. See SKPhysicsBody.

Defining How Forces Affect a Physics Body

Defining a Physics Body’s Physical Properties

Working with Collisions and Contacts

Applying Forces and Impulses to a Physics Body

Inspecting a Physics Body’s Position and Velocity

Reading a Physics Body’s Node

Determining Which Joints Are Connected to a Physics Body

Interacting with Physics Fields

Pinning a Physics Body to a Node’s Parent

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody

func NewPhysicsBodyWithBodies

func NewPhysicsBodyWithBodies(bodies []SKPhysicsBody) SKPhysicsBody

Creates a physics body that’s shaped like a union of the argument physics bodies.

bodies: An array of SKPhysicsBody objects. The objects must be volume-based physics bodies. (You may not use a compound body created using this method in the array.)

Return Value

A new compound-physics body.

Discussion

The shapes of the physics bodies passed into this method are used to create a new physics body whose covered area is the union of the areas of its children. These areas do not need to be contiguous. If there is space between two parts, other bodies may be able to pass between these parts. However, the physics body is treated as a single connected body, meaning that a force or impulse applied to the body affects all of the pieces as if they are held together with an indestructible frame.

The properties on the children, such as mass or friction, are ignored. Only the shapes of the child bodies are used.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/init(bodies:)

func NewPhysicsBodyWithCircleOfRadius

func NewPhysicsBodyWithCircleOfRadius(r float64) SKPhysicsBody

Creates a circular physics body centered on the owning node’s origin.

r: The radius of the circle.

Return Value

A new volume-based physics body.

Discussion

The following code shows the code that creates the physics body for a spherical or circular object. Because the physics body is attached to a sprite object, it usually needs volume. In this case, the sprite image is assumed to closely approximate a circle centered on the anchor point, so the radius of the circle is calculated and used to create the physics body.

Listing 1. A physics body for a circular sprite

If the physics body were significantly smaller than the sprite’s image, the data used to create the physics body might need to be provided by some other source, such as a property list.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/init(circleOfRadius:)

func NewPhysicsBodyWithCircleOfRadiusCenter

func NewPhysicsBodyWithCircleOfRadiusCenter(r float64, center corefoundation.CGPoint) SKPhysicsBody

Creates a circular physics body centered on an arbitrary point.

r: The radius of the circle.

center: The origin of the circle in the owning node’s coordinate system.

Return Value

A new volume-based physics body.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/init(circleOfRadius:center:)

func NewPhysicsBodyWithEdgeChainFromPath

func NewPhysicsBodyWithEdgeChainFromPath(path coregraphics.CGPathRef) SKPhysicsBody

Creates an edge chain from a path.

path: A Core Graphics path. The points are specified relative to the owning node’s origin. The path must not intersect itself.

Return Value

A new edge-based physics body.

Discussion

An edge has no volume or mass and is always treated as if the [SKPhysicsBody.Dynamic] property is equal to false. Edges may only collide with volume-based physics bodies.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/init(edgeChainFrom:)

func NewPhysicsBodyWithEdgeFromPointToPoint

func NewPhysicsBodyWithEdgeFromPointToPoint(p1 corefoundation.CGPoint, p2 corefoundation.CGPoint) SKPhysicsBody

Creates an edge between two points.

p1: The starting point for the edge, relative to the owning node’s origin.

p2: The ending point for the edge, relative to the owning node’s origin.

Return Value

A new edge-based physics body.

Discussion

An edge has no volume or mass and is always treated as if the [SKPhysicsBody.Dynamic] property is equal to false. Edges may only collide with volume-based physics bodies.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/init(edgeFrom:to:)

func NewPhysicsBodyWithEdgeLoopFromPath

func NewPhysicsBodyWithEdgeLoopFromPath(path coregraphics.CGPathRef) SKPhysicsBody

Creates an edge loop from a path.

path: A Core Graphics path. The points are specified relative to the owning node’s origin. The path must not intersect itself.

Return Value

A new edge-based physics body.

Discussion

If the path is not already closed, a loop is automatically created by joining the last point to the first.

An edge has no volume or mass and is always treated as if the [SKPhysicsBody.Dynamic] property is equal to false. Edges may only collide with volume-based physics bodies.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/init(edgeLoopFrom:)-5grxu

func NewPhysicsBodyWithEdgeLoopFromRect

func NewPhysicsBodyWithEdgeLoopFromRect(rect corefoundation.CGRect) SKPhysicsBody

Creates an edge loop from a rectangle.

rect: The rectangle that defines the edges. The rectangle is specified relative to the owning node’s origin.

Return Value

A new edge-based physics body.

Discussion

An edge has no volume or mass and is always treated as if the [SKPhysicsBody.Dynamic] property is equal to false. Edges may only collide with volume-based physics bodies.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/init(edgeLoopFrom:)-8sqfy

func NewPhysicsBodyWithPolygonFromPath

func NewPhysicsBodyWithPolygonFromPath(path coregraphics.CGPathRef) SKPhysicsBody

Creates a polygonal physics body.

path: A convex polygonal path with counterclockwise winding and no self intersections. The points are specified relative to the owning node’s origin.

Return Value

A new volume-based physics body.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/init(polygonFrom:)

func NewPhysicsBodyWithRectangleOfSize

func NewPhysicsBodyWithRectangleOfSize(s corefoundation.CGSize) SKPhysicsBody

Creates a rectangular physics body centered on the owning node’s origin.

s: The size of the rectangle.

Return Value

A new volume-based physics body.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/init(rectangleOf:)

func NewPhysicsBodyWithRectangleOfSizeCenter

func NewPhysicsBodyWithRectangleOfSizeCenter(s corefoundation.CGSize, center corefoundation.CGPoint) SKPhysicsBody

Creates a rectangular physics body centered on an arbitrary point.

s: The size of the rectangle.

center: The center of the square in the owning node’s coordinate system.

Return Value

A new volume-based physics body.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/init(rectangleOf:center:)

func NewPhysicsBodyWithTextureAlphaThresholdSize

func NewPhysicsBodyWithTextureAlphaThresholdSize(texture ISKTexture, alphaThreshold float32, size corefoundation.CGSize) SKPhysicsBody

Creates a physics body from the contents of a texture, capturing only the texels that exceed a specified transparency value.

texture: The texture to analyze.

alphaThreshold: The minimum alpha value for texels that should be part of the new physics body.

size: The size of the physics body to return.

Return Value

A new volume-based physics body.

Discussion

Use this method when your sprite has a shape that you want replicated in its physics body. The texture is scaled to the new size and then analyzed. A new physics body is created that includes all of the texels in the texture whose alpha values equal or exceed the `alphaThreshold` parameter. The shape of this body attempts to strike a good balance between performance and accuracy. For example, fine details may be ignored if keeping them would cause a significant performance penalty.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/init(texture:alphaThreshold:size:)

func NewPhysicsBodyWithTextureSize

func NewPhysicsBodyWithTextureSize(texture ISKTexture, size corefoundation.CGSize) SKPhysicsBody

Creates a physics body from the contents of a texture.

texture: The texture to convert into a physics body.

size: The size of the physics body to return.

Return Value

A new volume-based physics body.

Discussion

Use this method when your sprite has a shape that you want replicated in its physics body. The texture is scaled to the new size and then analyzed. A new physics body is created that includes all of the texels in the texture that have a nonzero alpha value. The shape of this body attempts to strike a good balance between performance and accuracy. For example, fine details may be ignored if keeping them would cause a significant performance penalty.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/init(texture:size:)

func NewSKPhysicsBody

func NewSKPhysicsBody() SKPhysicsBody

NewSKPhysicsBody creates a new SKPhysicsBody instance.

func SKPhysicsBodyFromID

func SKPhysicsBodyFromID(id objc.ID) SKPhysicsBody

SKPhysicsBodyFromID constructs a SKPhysicsBody from an objc.ID.

An object that adds physics simulation to a node.

func (SKPhysicsBody) AffectedByGravity

func (p SKPhysicsBody) AffectedByGravity() bool

A Boolean value that indicates whether this physics body is affected by the physics world’s gravity.

Discussion

The physics world’s SKPhysicsWorld.Gravity property defines the gravitational forces applied to volume-based bodies in the scene.

The default value is `true`. This property is ignored on edge-based bodies, which are always unaffected by gravity.

Physics bodies with `affectedByGravity` set to `false` are still affected by the gravity fields created by SKFieldNodeClass.LinearGravityFieldWithVector and SKFieldNodeClass.RadialGravityField.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/affectedByGravity

func (SKPhysicsBody) AllContactedBodies

func (p SKPhysicsBody) AllContactedBodies() []SKPhysicsBody

The physics bodies that this physics body is in contact with.

Return Value

An array of SKPhysicsBody objects that this body is in contact with.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/allContactedBodies()

func (SKPhysicsBody) AllowsRotation

func (p SKPhysicsBody) AllowsRotation() bool

A Boolean value that indicates whether the physics body is affected by angular forces and impulses applied to it.

Discussion

The default value is true. This property is ignored on edge-based bodies, which are unaffected by forces in the system.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/allowsRotation

func (SKPhysicsBody) AngularDamping

func (p SKPhysicsBody) AngularDamping() float64

A property that reduces the body’s rotational velocity.

Discussion

This property is used to simulate fluid or air friction forces on the body. The property must be a value between `0.0` and `1.0`. The default value is `0.1`. If the value is `0.0`, no angular damping is applied to the object.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/angularDamping

func (SKPhysicsBody) AngularVelocity

func (p SKPhysicsBody) AngularVelocity() float64

The physics body’s angular speed.

Discussion

The angular velocity is a pseudo vector around an axis vector of `(0.0,0.0,1.0)` measured in radians per second.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/angularVelocity

func (SKPhysicsBody) ApplyAngularImpulse

func (p SKPhysicsBody) ApplyAngularImpulse(impulse float64)

Applies an impulse that imparts angular momentum to an object.

impulse: The magnitude of the impulse. The impulse is measured in Newton-seconds.

Discussion

This method affects the body’s angular velocity without changing the body’s linear velocity.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/applyAngularImpulse(_:)

func (SKPhysicsBody) ApplyForce

func (p SKPhysicsBody) ApplyForce(force corefoundation.CGVector)

Applies a force to the center of gravity of a physics body.

force: A vector that describes how much force was applied in each dimension. The force is measured in Newtons.

Discussion

This method accelerates the body without imparting any angular acceleration to it. The acceleration is applied for a single simulation step (one frame).

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/applyForce(_:)

func (SKPhysicsBody) ApplyForceAtPoint

func (p SKPhysicsBody) ApplyForceAtPoint(force corefoundation.CGVector, point corefoundation.CGPoint)

Applies a force to a specific point of a physics body.

force: A vector that describes how much force was applied in each dimension. The force is measured in Newtons.

point: A point in scene coordinates that defines where the force was applied to the physics body.

Discussion

Because the force is applied to a specific point on the body, it may impart both linear acceleration and angular acceleration. The force is applied for a single simulation step (one frame).

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/applyForce(_:at:)

func (SKPhysicsBody) ApplyImpulse

func (p SKPhysicsBody) ApplyImpulse(impulse corefoundation.CGVector)

Applies an impulse to the center of gravity of a physics body.

impulse: A vector that describes how much momentum was imparted in each dimension. The impulse is measured in Newton-seconds.

Discussion

This method affects the body’s linear velocity without changing the body’s angular velocity.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/applyImpulse(_:)

func (SKPhysicsBody) ApplyImpulseAtPoint

func (p SKPhysicsBody) ApplyImpulseAtPoint(impulse corefoundation.CGVector, point corefoundation.CGPoint)

Applies an impulse to a specific point of a physics body.

impulse: A vector that describes how much momentum to impart to the body. The impulse is measured in Newton-seconds.

point: A point in scene coordinates that defines where the impulse was applied to the physics body.

Discussion

Because this impulse is applied to a specific point on the object, it may change both the body’s velocity and angular velocity.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/applyImpulse(_:at:)

func (SKPhysicsBody) ApplyTorque

func (p SKPhysicsBody) ApplyTorque(torque float64)

Applies torque to an object.

torque: The amount of torque, in Newton-meters.

Discussion

This method generates an angular acceleration on the body without causing any linear acceleration. The force is applied for a single simulation step (one frame).

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/applyTorque(_:)

func (SKPhysicsBody) Area

func (p SKPhysicsBody) Area() float64

The area covered by the body.

Discussion

This property is used in conjunction with the SKPhysicsBody.Density property to calculate the body’s mass.

The value returned for the area is measured in meters: if you need to convert it into points — as used by SpriteKit — multiply the values by 150². The following listing shows how to calculate the area of a box which is ten points square.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/area

func (SKPhysicsBody) Autorelease

func (p SKPhysicsBody) Autorelease() SKPhysicsBody

Autorelease adds the receiver to the current autorelease pool.

func (SKPhysicsBody) CategoryBitMask

func (p SKPhysicsBody) CategoryBitMask() uint32

A mask that defines which categories this physics body belongs to.

Discussion

Every physics body in a scene can be assigned to up to 32 different categories, each corresponding to a bit in the bit mask. You define the mask values used in your game. In conjunction with the SKPhysicsBody.CollisionBitMask and SKPhysicsBody.ContactTestBitMask properties, you define which physics bodies interact with each other and when your game is notified of these interactions.

The default value is `0xFFFFFFFF` (all bits set).

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/categoryBitMask

func (SKPhysicsBody) Charge

func (p SKPhysicsBody) Charge() float64

The electrical charge of the physics body.

Discussion

The electrical charge is used by electromagnetic fields to calculate electromagnetic force effects on the physics body. See SKFieldNode.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/charge

func (SKPhysicsBody) CollisionBitMask

func (p SKPhysicsBody) CollisionBitMask() uint32

A mask that defines which categories of physics bodies can collide with this physics body.

Discussion

When two physics bodies contact each other, a collision may occur. This body’s collision mask is compared to the other body’s category mask by performing a logical AND operation. If the result is a nonzero value, this body is affected by the collision. Each body independently chooses whether it wants to be affected by the other body. For example, you might use this to avoid collision calculations that would make negligible changes to a body’s velocity.

The default value is `0xFFFFFFFF` (all bits set).

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/collisionBitMask

func (SKPhysicsBody) ContactTestBitMask

func (p SKPhysicsBody) ContactTestBitMask() uint32

A mask that defines which categories of physics bodies cause intersection notifications with this physics body.

Discussion

When two bodies share the same space, each body’s category mask is tested against the other body’s contact mask by performing a logical AND operation. If either comparison results in a nonzero value, an SKPhysicsContact object is created and passed to the physics world’s delegate. For best performance, only set bits in the contacts mask for interactions you are interested in.

The default value is `0x00000000` (all bits cleared).

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/contactTestBitMask

func (SKPhysicsBody) Density

func (p SKPhysicsBody) Density() float64

The density of the object, in kilograms per square meter.

Discussion

The actual unit is arbitrary as long as relative masses of objects are consistent throughout the game.

The SKPhysicsBody.Mass and SKPhysicsBody.Density properties are interrelated. When you change the value of either property, the other property’s value is automatically recalculated to be consistent.

The default value is `1.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/density

func (SKPhysicsBody) EncodeWithCoder

func (p SKPhysicsBody) EncodeWithCoder(coder foundation.INSCoder)

func (SKPhysicsBody) FieldBitMask

func (p SKPhysicsBody) FieldBitMask() uint32

A mask that defines which categories of physics fields can exert forces on this physics body.

Discussion

When a physics body is inside the region of an SKFieldNode object, that field node’s SKFieldNode.CategoryBitMask property is compared to this physics body’s SKPhysicsBody.FieldBitMask property by performing a logical AND operation. If the result is a nonzero value, the field node’s effect is applied to the physics body.

The default value is `0xFFFFFFFF` (all bits set).

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/fieldBitMask

func (SKPhysicsBody) Friction

func (p SKPhysicsBody) Friction() float64

The roughness of the surface of the physics body.

Discussion

This property is used to apply a frictional force to physics bodies in contact with this physics body. The property must be a value between `0.0` and `1.0`. The default value is `0.2`.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/friction

func (SKPhysicsBody) Init

func (p SKPhysicsBody) Init() SKPhysicsBody

Init initializes the instance.

func (SKPhysicsBody) IsDynamic

func (p SKPhysicsBody) IsDynamic() bool

A Boolean value that indicates whether the physics body is moved by the physics simulation.

Discussion

The default value is true. If the value is false, the physics body ignores all forces and impulses applied to it. This property is ignored on edge-based bodies; they are automatically static.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/isDynamic

func (SKPhysicsBody) IsResting

func (p SKPhysicsBody) IsResting() bool

A Boolean property that indicates whether the object is at rest within the physics simulation.

Discussion

This property is automatically set to true by the physics simulation when it determines that the body is at rest. This means that the body is at rest on another body in the system. Resting bodies do not participate in the physics simulation until an impulse is applied to the object or another object collides with it. This improves the performance of the physics simulation. If all bodies in the world are resting, the entire simulation is at rest, reducing the number of calculations that are performed by the physics world.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/isResting

func (SKPhysicsBody) Joints

func (p SKPhysicsBody) Joints() []SKPhysicsJoint

The joints connected to this physics body.

Discussion

This property holds an array of SKPhysicsJoint objects that define all joints added to the scene’s physics world that are connected to this physics body.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/joints

func (SKPhysicsBody) LinearDamping

func (p SKPhysicsBody) LinearDamping() float64

A property that reduces the body’s linear velocity.

Discussion

This property is used to simulate fluid or air friction forces on the body. The property must be a value between `0.0` and `1.0`. The default value is `0.1`. If the value is `0.0`, no linear damping is applied to the object.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/linearDamping

func (SKPhysicsBody) Mass

func (p SKPhysicsBody) Mass() float64

The mass of the body, in kilograms.

Discussion

The actual unit is arbitrary as long as relative masses of objects are consistent throughout the game. The mass of the body affects its momentum as well as how forces are applied to the object.

The SKPhysicsBody.Mass and SKPhysicsBody.Density properties are interrelated. When you change the value of either property, the other property’s value is automatically recalculated to be consistent. The default value is based on the size of the physics body and the body’s default density.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/mass

func (SKPhysicsBody) Node

func (p SKPhysicsBody) Node() ISKNode

The node that this body is connected to.

Discussion

You associate the body with a node by assigning it to the SKNode.PhysicsBody property of the SKNode object. If the body is not associated with a node, the value is `nil`.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/node

func (SKPhysicsBody) Pinned

func (p SKPhysicsBody) Pinned() bool

A Boolean value that indicates whether the physics body’s node is pinned to its parent node.

Discussion

The default value is false. If true, the node’s position is fixed relative to its parent. The node’s position cannot be changed by actions or physics forces. The node can freely rotate around its position in response to collisions or other forces. If the parent node has a physics body, the two physics bodies are treated as if they are connected with a pin joint.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/pinned

func (SKPhysicsBody) Restitution

func (p SKPhysicsBody) Restitution() float64

The bounciness of the physics body.

Discussion

This property is used to determine how much energy the physics body loses when it bounces off another object. The property must be a value between `0.0` and `1.0`. The default value is `0.2`.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/restitution

func (SKPhysicsBody) SetAffectedByGravity

func (p SKPhysicsBody) SetAffectedByGravity(value bool)

func (SKPhysicsBody) SetAllowsRotation

func (p SKPhysicsBody) SetAllowsRotation(value bool)

func (SKPhysicsBody) SetAngularDamping

func (p SKPhysicsBody) SetAngularDamping(value float64)

func (SKPhysicsBody) SetAngularVelocity

func (p SKPhysicsBody) SetAngularVelocity(value float64)

func (SKPhysicsBody) SetCategoryBitMask

func (p SKPhysicsBody) SetCategoryBitMask(value uint32)

func (SKPhysicsBody) SetCharge

func (p SKPhysicsBody) SetCharge(value float64)

func (SKPhysicsBody) SetCollisionBitMask

func (p SKPhysicsBody) SetCollisionBitMask(value uint32)

func (SKPhysicsBody) SetContactTestBitMask

func (p SKPhysicsBody) SetContactTestBitMask(value uint32)

func (SKPhysicsBody) SetDensity

func (p SKPhysicsBody) SetDensity(value float64)

func (SKPhysicsBody) SetDynamic

func (p SKPhysicsBody) SetDynamic(value bool)

func (SKPhysicsBody) SetFieldBitMask

func (p SKPhysicsBody) SetFieldBitMask(value uint32)

func (SKPhysicsBody) SetFriction

func (p SKPhysicsBody) SetFriction(value float64)

func (SKPhysicsBody) SetLinearDamping

func (p SKPhysicsBody) SetLinearDamping(value float64)

func (SKPhysicsBody) SetMass

func (p SKPhysicsBody) SetMass(value float64)

func (SKPhysicsBody) SetPinned

func (p SKPhysicsBody) SetPinned(value bool)

func (SKPhysicsBody) SetResting

func (p SKPhysicsBody) SetResting(value bool)

func (SKPhysicsBody) SetRestitution

func (p SKPhysicsBody) SetRestitution(value float64)

func (SKPhysicsBody) SetUsesPreciseCollisionDetection

func (p SKPhysicsBody) SetUsesPreciseCollisionDetection(value bool)

func (SKPhysicsBody) SetVelocity

func (p SKPhysicsBody) SetVelocity(value corefoundation.CGVector)

func (SKPhysicsBody) UsesPreciseCollisionDetection

func (p SKPhysicsBody) UsesPreciseCollisionDetection() bool

A Boolean value that determines whether the physics world uses an iterative collision detection algorithm.

Discussion

When SpriteKit performs collision detection, it first determines the locations of all of the physics bodies in the scene. Then it determines whether collisions or contacts occurred. This computational method is fast, but can sometimes result in missed collisions. A small body might move so fast that it completely passes through another physics body without ever having a frame of animation where the two touch each other.

If you have physics bodies that must collide, you can hint to SpriteKit to use a more precise collision model to check for interactions. This model is more expensive, so it should be used sparingly. When either body uses precise collisions, multiple contact iterations are evaluated to ensure that all contacts are detected.

The default value is false. If two bodies in a collision do not perform precise collision detection, and one passes completely through the other in a single frame, no collision is detected. If this property is set to true on either body, the simulation performs a more precise and more expensive calculation to detect these collisions. This property should be set to true on small, fast moving bodies.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/usesPreciseCollisionDetection

func (SKPhysicsBody) Velocity

func (p SKPhysicsBody) Velocity() corefoundation.CGVector

The physics body’s velocity vector, measured in meters per second.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsBody/velocity

type SKPhysicsBodyBoolHandler

type SKPhysicsBodyBoolHandler = func(*SKPhysicsBody, *bool)

SKPhysicsBodyBoolHandler handles A block to be called for each physics body that contains the point.

Used by:

type SKPhysicsBodyCGPointCGVectorBoolHandler

type SKPhysicsBodyCGPointCGVectorBoolHandler = func(*SKPhysicsBody, corefoundation.CGPoint, corefoundation.CGVector, *bool)

SKPhysicsBodyCGPointCGVectorBoolHandler handles A block to be called for each physics body that the ray touches.

  • body: The physics body that the ray intersected.
  • point: The point in scene coordinates where the ray contacted the physics body.
  • normal: The normal vector for the physics body at the point of contact.
  • stop: A pointer to a Boolean variable. Your block can set this to [true](<https://developer.apple.com/documentation/Swift/true>) to terminate the enumeration.

Used by:

type SKPhysicsBodyClass

type SKPhysicsBodyClass struct {
	// contains filtered or unexported fields
}

func GetSKPhysicsBodyClass

func GetSKPhysicsBodyClass() SKPhysicsBodyClass

GetSKPhysicsBodyClass returns the class object for SKPhysicsBody.

func (SKPhysicsBodyClass) Alloc

func (sc SKPhysicsBodyClass) Alloc() SKPhysicsBody

Alloc allocates memory for a new instance of the class.

func (SKPhysicsBodyClass) Class

func (sc SKPhysicsBodyClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKPhysicsContact

type SKPhysicsContact struct {
	objectivec.Object
}

A description of the contact between two physics bodies.

Overview

An SKPhysicsContact object is created automatically by SpriteKit to describe a contact between two physical bodies in a physics world.To receive contact messages, read the SKScene.PhysicsWorld property of an SKScene object you are interested in, and assign its SKPhysicsWorld.ContactDelegate property to point to an object that implements the SKPhysicsContactDelegate protocol. Then, for each physics body in your scene, set the SKPhysicsBody.CategoryBitMask and SKPhysicsBody.ContactTestBitMask properties to define which interactions should generate contact messages.

Inspecting the Contact Properties

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsContact

func NewSKPhysicsContact

func NewSKPhysicsContact() SKPhysicsContact

NewSKPhysicsContact creates a new SKPhysicsContact instance.

func SKPhysicsContactFromID

func SKPhysicsContactFromID(id objc.ID) SKPhysicsContact

SKPhysicsContactFromID constructs a SKPhysicsContact from an objc.ID.

A description of the contact between two physics bodies.

func (SKPhysicsContact) Autorelease

func (p SKPhysicsContact) Autorelease() SKPhysicsContact

Autorelease adds the receiver to the current autorelease pool.

func (SKPhysicsContact) BodyA

func (p SKPhysicsContact) BodyA() ISKPhysicsBody

The first body in the contact.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsContact/bodyA

func (SKPhysicsContact) BodyB

func (p SKPhysicsContact) BodyB() ISKPhysicsBody

The second body in the contact.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsContact/bodyB

func (SKPhysicsContact) CollisionImpulse

func (p SKPhysicsContact) CollisionImpulse() float64

The impulse that specifies how hard these two bodies struck each other in Newton-seconds.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsContact/collisionImpulse

func (SKPhysicsContact) ContactNormal

func (p SKPhysicsContact) ContactNormal() corefoundation.CGVector

The normal vector specifying the direction of the collision.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsContact/contactNormal

func (SKPhysicsContact) ContactPoint

func (p SKPhysicsContact) ContactPoint() corefoundation.CGPoint

The contact point between the two physics bodies, in scene coordinates.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsContact/contactPoint

func (SKPhysicsContact) Init

Init initializes the instance.

type SKPhysicsContactClass

type SKPhysicsContactClass struct {
	// contains filtered or unexported fields
}

func GetSKPhysicsContactClass

func GetSKPhysicsContactClass() SKPhysicsContactClass

GetSKPhysicsContactClass returns the class object for SKPhysicsContact.

func (SKPhysicsContactClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKPhysicsContactClass) Class

func (sc SKPhysicsContactClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKPhysicsContactDelegate

type SKPhysicsContactDelegate interface {
	objectivec.IObject
}

Methods your app can implement to respond when physics bodies come into contact.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsContactDelegate

type SKPhysicsContactDelegateConfig

type SKPhysicsContactDelegateConfig struct {

	// Other Methods
	// DidBeginContact — Called when two bodies first contact each other.
	DidBeginContact func(contact SKPhysicsContact)
	// DidEndContact — Called when the contact ends between two physics bodies.
	DidEndContact func(contact SKPhysicsContact)
}

SKPhysicsContactDelegateConfig holds optional typed callbacks for SKPhysicsContactDelegate methods. Set non-nil fields to register the corresponding Objective-C delegate method. Methods with nil callbacks are not registered, so [NSObject.RespondsToSelector] returns false for them — matching the Objective-C delegate pattern exactly.

See Apple Documentation for protocol details.

type SKPhysicsContactDelegateObject

type SKPhysicsContactDelegateObject struct {
	objectivec.Object
}

SKPhysicsContactDelegateObject wraps an existing Objective-C object that conforms to the SKPhysicsContactDelegate protocol.

func NewSKPhysicsContactDelegate

func NewSKPhysicsContactDelegate(config SKPhysicsContactDelegateConfig) SKPhysicsContactDelegateObject

NewSKPhysicsContactDelegate creates an Objective-C object implementing the SKPhysicsContactDelegate protocol.

Each call registers a unique Objective-C class containing only the methods set in config. This means [NSObject.RespondsToSelector] works correctly for optional delegate methods — only non-nil callbacks are registered.

The returned SKPhysicsContactDelegateObject satisfies the SKPhysicsContactDelegate interface and can be passed directly to SetDelegate and similar methods.

See Apple Documentation for protocol details.

func SKPhysicsContactDelegateObjectFromID

func SKPhysicsContactDelegateObjectFromID(id objc.ID) SKPhysicsContactDelegateObject

SKPhysicsContactDelegateObjectFromID constructs a SKPhysicsContactDelegateObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (SKPhysicsContactDelegateObject) BaseObject

func (SKPhysicsContactDelegateObject) DidBeginContact

func (o SKPhysicsContactDelegateObject) DidBeginContact(contact ISKPhysicsContact)

Called when two bodies first contact each other.

contact: An object that describes the contact.

Discussion

The two physics bodies described in the contact parameter are not passed in a guaranteed order. The following code shows how you might respond to the beginning of a contact event to execute code if either physics body is owned by a node with the name `ground`.

Listing 1. Responding to a contact event.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsContactDelegate/didBegin(_:)

func (SKPhysicsContactDelegateObject) DidEndContact

func (o SKPhysicsContactDelegateObject) DidEndContact(contact ISKPhysicsContact)

Called when the contact ends between two physics bodies.

contact: An object that describes the contact.

Discussion

The two physics bodies described in the contact parameter are not passed in a guaranteed order. The following code shows how you might respond to the end of a contact event to execute code if either physics body is owned by a node with the name `ground`.

Listing 1. Responding to a contact event

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsContactDelegate/didEnd(_:)

type SKPhysicsJoint

type SKPhysicsJoint struct {
	objectivec.Object
}

The abstract superclass for objects that connect physics bodies.

Overview

An SKPhysicsJoint object connects two physics bodies so that they are simulated together by the physics world. You never instantiate objects of this class directly; instead, you instantiate one of the subclasses that defines the kind of joint you want to make.

Accessing or Setting a Joint’s Bodies

Reading the Stress and Speed that Are Currently Applied to a Joint

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJoint

func NewSKPhysicsJoint

func NewSKPhysicsJoint() SKPhysicsJoint

NewSKPhysicsJoint creates a new SKPhysicsJoint instance.

func SKPhysicsJointFromID

func SKPhysicsJointFromID(id objc.ID) SKPhysicsJoint

SKPhysicsJointFromID constructs a SKPhysicsJoint from an objc.ID.

The abstract superclass for objects that connect physics bodies.

func (SKPhysicsJoint) Autorelease

func (p SKPhysicsJoint) Autorelease() SKPhysicsJoint

Autorelease adds the receiver to the current autorelease pool.

func (SKPhysicsJoint) BodyA

func (p SKPhysicsJoint) BodyA() ISKPhysicsBody

The first body connected by the joint.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJoint/bodyA

func (SKPhysicsJoint) BodyB

func (p SKPhysicsJoint) BodyB() ISKPhysicsBody

The second body connected by the joint.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJoint/bodyB

func (SKPhysicsJoint) EncodeWithCoder

func (p SKPhysicsJoint) EncodeWithCoder(coder foundation.INSCoder)

func (SKPhysicsJoint) Init

func (p SKPhysicsJoint) Init() SKPhysicsJoint

Init initializes the instance.

func (SKPhysicsJoint) ReactionForce

func (p SKPhysicsJoint) ReactionForce() corefoundation.CGVector

The instantaneous reaction force, in newtons, currently being directed at the anchor point.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJoint/reactionForce

func (SKPhysicsJoint) ReactionTorque

func (p SKPhysicsJoint) ReactionTorque() float64

Instantaneous reaction torque, in newton-meters, currently being directed at the anchor point.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJoint/reactionTorque

func (SKPhysicsJoint) SetBodyA

func (p SKPhysicsJoint) SetBodyA(value ISKPhysicsBody)

func (SKPhysicsJoint) SetBodyB

func (p SKPhysicsJoint) SetBodyB(value ISKPhysicsBody)

type SKPhysicsJointClass

type SKPhysicsJointClass struct {
	// contains filtered or unexported fields
}

func GetSKPhysicsJointClass

func GetSKPhysicsJointClass() SKPhysicsJointClass

GetSKPhysicsJointClass returns the class object for SKPhysicsJoint.

func (SKPhysicsJointClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKPhysicsJointClass) Class

func (sc SKPhysicsJointClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKPhysicsJointFixed

type SKPhysicsJointFixed struct {
	SKPhysicsJoint
}

A joint that fuses two physics bodies together at a reference point.

Overview

An SKPhysicsJointFixed object fuses two physics bodies together at a reference point. Fixed joints are useful for creating complex shapes that can be broken apart later.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointFixed

func NewSKPhysicsJointFixed

func NewSKPhysicsJointFixed() SKPhysicsJointFixed

NewSKPhysicsJointFixed creates a new SKPhysicsJointFixed instance.

func SKPhysicsJointFixedFromID

func SKPhysicsJointFixedFromID(id objc.ID) SKPhysicsJointFixed

SKPhysicsJointFixedFromID constructs a SKPhysicsJointFixed from an objc.ID.

A joint that fuses two physics bodies together at a reference point.

func (SKPhysicsJointFixed) Autorelease

func (p SKPhysicsJointFixed) Autorelease() SKPhysicsJointFixed

Autorelease adds the receiver to the current autorelease pool.

func (SKPhysicsJointFixed) Init

Init initializes the instance.

type SKPhysicsJointFixedClass

type SKPhysicsJointFixedClass struct {
	// contains filtered or unexported fields
}

func GetSKPhysicsJointFixedClass

func GetSKPhysicsJointFixedClass() SKPhysicsJointFixedClass

GetSKPhysicsJointFixedClass returns the class object for SKPhysicsJointFixed.

func (SKPhysicsJointFixedClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKPhysicsJointFixedClass) Class

func (sc SKPhysicsJointFixedClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (SKPhysicsJointFixedClass) JointWithBodyABodyBAnchor

func (_SKPhysicsJointFixedClass SKPhysicsJointFixedClass) JointWithBodyABodyBAnchor(bodyA ISKPhysicsBody, bodyB ISKPhysicsBody, anchor corefoundation.CGPoint) SKPhysicsJointFixed

Creates a new fixed joint.

bodyA: The first body to connect. The body must be connected to a node that is already part of the scene’s node tree.

bodyB: The second body to connect. The body must be connected to a node that is already part of the scene’s node tree.

anchor: The anchor point for the connection in the scene’s coordinate system.

Return Value

A new fixed joint.

Discussion

You must add the joint to a physics world associated with the scene before it takes effect.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointFixed/joint(withBodyA:bodyB:anchor:)

type SKPhysicsJointLimit

type SKPhysicsJointLimit struct {
	SKPhysicsJoint
}

A joint that imposes a maximum distance between two physics bodies, as if they were connected by a rope.

Configuring a Limit Joint

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointLimit

func NewSKPhysicsJointLimit

func NewSKPhysicsJointLimit() SKPhysicsJointLimit

NewSKPhysicsJointLimit creates a new SKPhysicsJointLimit instance.

func SKPhysicsJointLimitFromID

func SKPhysicsJointLimitFromID(id objc.ID) SKPhysicsJointLimit

SKPhysicsJointLimitFromID constructs a SKPhysicsJointLimit from an objc.ID.

A joint that imposes a maximum distance between two physics bodies, as if they were connected by a rope.

func (SKPhysicsJointLimit) Autorelease

func (p SKPhysicsJointLimit) Autorelease() SKPhysicsJointLimit

Autorelease adds the receiver to the current autorelease pool.

func (SKPhysicsJointLimit) Init

Init initializes the instance.

func (SKPhysicsJointLimit) MaxLength

func (p SKPhysicsJointLimit) MaxLength() float64

The maximum distance allowed between the two physics bodies connected by the limit joint.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointLimit/maxLength

func (SKPhysicsJointLimit) SetMaxLength

func (p SKPhysicsJointLimit) SetMaxLength(value float64)

type SKPhysicsJointLimitClass

type SKPhysicsJointLimitClass struct {
	// contains filtered or unexported fields
}

func GetSKPhysicsJointLimitClass

func GetSKPhysicsJointLimitClass() SKPhysicsJointLimitClass

GetSKPhysicsJointLimitClass returns the class object for SKPhysicsJointLimit.

func (SKPhysicsJointLimitClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKPhysicsJointLimitClass) Class

func (sc SKPhysicsJointLimitClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (SKPhysicsJointLimitClass) JointWithBodyABodyBAnchorAAnchorB

func (_SKPhysicsJointLimitClass SKPhysicsJointLimitClass) JointWithBodyABodyBAnchorAAnchorB(bodyA ISKPhysicsBody, bodyB ISKPhysicsBody, anchorA corefoundation.CGPoint, anchorB corefoundation.CGPoint) SKPhysicsJointLimit

Creates a new limit joint.

bodyA: The first body to connect. The body must be connected to a node that is already part of the scene’s node tree.

bodyB: The second body to connect. The body must be connected to a node that is already part of the scene’s node tree.

anchorA: A connection point on the first body in the scene’s coordinate system.

anchorB: A connection point on the second body in the scene’s coordinate system.

Return Value

A new limit joint.

Discussion

You must add the joint to a physics world associated with the scene before it takes effect.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointLimit/joint(withBodyA:bodyB:anchorA:anchorB:)

type SKPhysicsJointPin

type SKPhysicsJointPin struct {
	SKPhysicsJoint
}

A joint that pins together two physics bodies, allowing independent rotation.

Overview

An SKPhysicsJointPin object allows two physics bodies to independently rotate around the anchor point as if pinned together. You can configure how far the two objects may rotate and the resistance to rotation.

Configuring a Pin Joint

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointPin

func NewSKPhysicsJointPin

func NewSKPhysicsJointPin() SKPhysicsJointPin

NewSKPhysicsJointPin creates a new SKPhysicsJointPin instance.

func SKPhysicsJointPinFromID

func SKPhysicsJointPinFromID(id objc.ID) SKPhysicsJointPin

SKPhysicsJointPinFromID constructs a SKPhysicsJointPin from an objc.ID.

A joint that pins together two physics bodies, allowing independent rotation.

func (SKPhysicsJointPin) Autorelease

func (p SKPhysicsJointPin) Autorelease() SKPhysicsJointPin

Autorelease adds the receiver to the current autorelease pool.

func (SKPhysicsJointPin) FrictionTorque

func (p SKPhysicsJointPin) FrictionTorque() float64

The resistance applied by the pin joint to spinning around the anchor point.

Discussion

The range of values is from `0.0` to `1.0`. The default value is `0.0`. If a value greater than the default is specified, friction is applied to reduce the object’s angular velocity around the pin.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointPin/frictionTorque

func (SKPhysicsJointPin) Init

Init initializes the instance.

func (SKPhysicsJointPin) LowerAngleLimit

func (p SKPhysicsJointPin) LowerAngleLimit() float64

The smallest angle allowed for the pin joint, in radians.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointPin/lowerAngleLimit

func (SKPhysicsJointPin) RotationSpeed

func (p SKPhysicsJointPin) RotationSpeed() float64

The speed, in radians per second, at which the physics bodies are driven around the pin joint.

Discussion

The SKPhysicsJointPin.FrictionTorque property limits the maximum amount of torque that can be applied to the physics bodies.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointPin/rotationSpeed

func (SKPhysicsJointPin) SetFrictionTorque

func (p SKPhysicsJointPin) SetFrictionTorque(value float64)

func (SKPhysicsJointPin) SetLowerAngleLimit

func (p SKPhysicsJointPin) SetLowerAngleLimit(value float64)

func (SKPhysicsJointPin) SetRotationSpeed

func (p SKPhysicsJointPin) SetRotationSpeed(value float64)

func (SKPhysicsJointPin) SetShouldEnableLimits

func (p SKPhysicsJointPin) SetShouldEnableLimits(value bool)

func (SKPhysicsJointPin) SetUpperAngleLimit

func (p SKPhysicsJointPin) SetUpperAngleLimit(value float64)

func (SKPhysicsJointPin) ShouldEnableLimits

func (p SKPhysicsJointPin) ShouldEnableLimits() bool

A Boolean value that indicates whether the pin joint’s rotation is limited to a specific range of values.

Discussion

The default value is false. If true, the SKPhysicsJointPin.LowerAngleLimit and SKPhysicsJointPin.UpperAngleLimit properties are used to limit the angle of the pin joint.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointPin/shouldEnableLimits

func (SKPhysicsJointPin) UpperAngleLimit

func (p SKPhysicsJointPin) UpperAngleLimit() float64

The largest angle allowed for the pin joint, in radians.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointPin/upperAngleLimit

type SKPhysicsJointPinClass

type SKPhysicsJointPinClass struct {
	// contains filtered or unexported fields
}

func GetSKPhysicsJointPinClass

func GetSKPhysicsJointPinClass() SKPhysicsJointPinClass

GetSKPhysicsJointPinClass returns the class object for SKPhysicsJointPin.

func (SKPhysicsJointPinClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKPhysicsJointPinClass) Class

func (sc SKPhysicsJointPinClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (SKPhysicsJointPinClass) JointWithBodyABodyBAnchor

func (_SKPhysicsJointPinClass SKPhysicsJointPinClass) JointWithBodyABodyBAnchor(bodyA ISKPhysicsBody, bodyB ISKPhysicsBody, anchor corefoundation.CGPoint) SKPhysicsJointPin

Creates a new pin joint.

bodyA: The first body to connect. The body must be connected to a node that is already part of the scene’s node tree.

bodyB: The second body to connect. The body must be connected to a node that is already part of the scene’s node tree.

anchor: The connection point between the two bodies in the scene’s coordinate system.

Return Value

A new pin joint.

Discussion

You must add the joint to a physics world associated with the scene before it takes effect.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointPin/joint(withBodyA:bodyB:anchor:)

type SKPhysicsJointSliding

type SKPhysicsJointSliding struct {
	SKPhysicsJoint
}

A joint that allows two physics bodies to slide along an axis.

Overview

An SKPhysicsJointSliding object allows the anchor points of the two physics bodies to slide along a chosen axis. The joint can be configured to limit the distance that the two objects are allowed to slide along the axis.

Configuring a Sliding Joint

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointSliding

func NewSKPhysicsJointSliding

func NewSKPhysicsJointSliding() SKPhysicsJointSliding

NewSKPhysicsJointSliding creates a new SKPhysicsJointSliding instance.

func SKPhysicsJointSlidingFromID

func SKPhysicsJointSlidingFromID(id objc.ID) SKPhysicsJointSliding

SKPhysicsJointSlidingFromID constructs a SKPhysicsJointSliding from an objc.ID.

A joint that allows two physics bodies to slide along an axis.

func (SKPhysicsJointSliding) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (SKPhysicsJointSliding) Init

Init initializes the instance.

func (SKPhysicsJointSliding) LowerDistanceLimit

func (p SKPhysicsJointSliding) LowerDistanceLimit() float64

The smallest distance allowed for the sliding joint.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointSliding/lowerDistanceLimit

func (SKPhysicsJointSliding) SetLowerDistanceLimit

func (p SKPhysicsJointSliding) SetLowerDistanceLimit(value float64)

func (SKPhysicsJointSliding) SetShouldEnableLimits

func (p SKPhysicsJointSliding) SetShouldEnableLimits(value bool)

func (SKPhysicsJointSliding) SetUpperDistanceLimit

func (p SKPhysicsJointSliding) SetUpperDistanceLimit(value float64)

func (SKPhysicsJointSliding) ShouldEnableLimits

func (p SKPhysicsJointSliding) ShouldEnableLimits() bool

A Boolean value that indicates whether the sliding joint is restricted so that the objects may only slide a finite distance from the initial anchor point.

Discussion

The default value is false. If true, then the SKPhysicsJointSliding.LowerDistanceLimit and SKPhysicsJointSliding.UpperDistanceLimit properties are used to limit the distance of the sliding joint.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointSliding/shouldEnableLimits

func (SKPhysicsJointSliding) UpperDistanceLimit

func (p SKPhysicsJointSliding) UpperDistanceLimit() float64

The largest distance allowed for the sliding joint.

Discussion

The default value is `0.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointSliding/upperDistanceLimit

type SKPhysicsJointSlidingClass

type SKPhysicsJointSlidingClass struct {
	// contains filtered or unexported fields
}

func GetSKPhysicsJointSlidingClass

func GetSKPhysicsJointSlidingClass() SKPhysicsJointSlidingClass

GetSKPhysicsJointSlidingClass returns the class object for SKPhysicsJointSliding.

func (SKPhysicsJointSlidingClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKPhysicsJointSlidingClass) Class

Class returns the underlying Objective-C class pointer.

func (SKPhysicsJointSlidingClass) JointWithBodyABodyBAnchorAxis

func (_SKPhysicsJointSlidingClass SKPhysicsJointSlidingClass) JointWithBodyABodyBAnchorAxis(bodyA ISKPhysicsBody, bodyB ISKPhysicsBody, anchor corefoundation.CGPoint, axis corefoundation.CGVector) SKPhysicsJointSliding

Creates a new sliding joint.

bodyA: The first body to connect. The body must be connected to a node that is already part of the scene’s node tree.

bodyB: The second body to connect. The body must be connected to a node that is already part of the scene’s node tree.

anchor: The anchor point for the connection in the scene’s coordinate system.

axis: A vector that defines the direction that the joint is allowed to slide.

Return Value

A new sliding joint.

Discussion

You must add the joint to a physics world associated with the scene before it takes effect.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointSliding/joint(withBodyA:bodyB:anchor:axis:)

type SKPhysicsJointSpring

type SKPhysicsJointSpring struct {
	SKPhysicsJoint
}

A joint that simulates a spring connecting two physics bodies.

Overview

An SKPhysicsJointSpring object simulates connecting two physics bodies together with a spring. The farther the two objects move from each other, the more force is applied to bring the two bodies back together.

Configuring a Spring Joint

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointSpring

func NewSKPhysicsJointSpring

func NewSKPhysicsJointSpring() SKPhysicsJointSpring

NewSKPhysicsJointSpring creates a new SKPhysicsJointSpring instance.

func SKPhysicsJointSpringFromID

func SKPhysicsJointSpringFromID(id objc.ID) SKPhysicsJointSpring

SKPhysicsJointSpringFromID constructs a SKPhysicsJointSpring from an objc.ID.

A joint that simulates a spring connecting two physics bodies.

func (SKPhysicsJointSpring) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (SKPhysicsJointSpring) Damping

func (p SKPhysicsJointSpring) Damping() float64

Defines how the spring’s motion should be damped due to the forces of friction.

Discussion

The default value is `0.0`. Increasing the value increases the energy loss with each oscillation: there will be fewer and smaller oscillations and time taken for the spring to settle will decrease.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointSpring/damping

func (SKPhysicsJointSpring) Frequency

func (p SKPhysicsJointSpring) Frequency() float64

Defines the frequency or stiffness characteristics of the spring.

Discussion

The default value is `0.0`, creating a rigid joint between the spring’s two bodies. Setting the frequency to a low value, for example `0.5`, creates a spring with slow oscillations that will settle slowly. Setting the frequency to a high value, for example `10.0`, creates a stiffer spring with faster and fewer oscillations.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointSpring/frequency

func (SKPhysicsJointSpring) Init

Init initializes the instance.

func (SKPhysicsJointSpring) SetDamping

func (p SKPhysicsJointSpring) SetDamping(value float64)

func (SKPhysicsJointSpring) SetFrequency

func (p SKPhysicsJointSpring) SetFrequency(value float64)

type SKPhysicsJointSpringClass

type SKPhysicsJointSpringClass struct {
	// contains filtered or unexported fields
}

func GetSKPhysicsJointSpringClass

func GetSKPhysicsJointSpringClass() SKPhysicsJointSpringClass

GetSKPhysicsJointSpringClass returns the class object for SKPhysicsJointSpring.

func (SKPhysicsJointSpringClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKPhysicsJointSpringClass) Class

Class returns the underlying Objective-C class pointer.

func (SKPhysicsJointSpringClass) JointWithBodyABodyBAnchorAAnchorB

func (_SKPhysicsJointSpringClass SKPhysicsJointSpringClass) JointWithBodyABodyBAnchorAAnchorB(bodyA ISKPhysicsBody, bodyB ISKPhysicsBody, anchorA corefoundation.CGPoint, anchorB corefoundation.CGPoint) SKPhysicsJointSpring

Creates a new spring joint.

bodyA: The first body to connect. The body must be connected to a node that is already part of the scene’s node tree.

bodyB: The second body to connect. The body must be connected to a node that is already part of the scene’s node tree.

anchorA: The connection point on the first body in the scene’s coordinate system.

anchorB: The connection point on the second body in the scene’s coordinate system.

Return Value

A new spring joint.

Discussion

You must add the joint to a physics world associated with the scene before it takes effect.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsJointSpring/joint(withBodyA:bodyB:anchorA:anchorB:)

type SKPhysicsWorld

type SKPhysicsWorld struct {
	objectivec.Object
}

The driver of the physics engine in a scene; it exposes the ability for you to configure and query the physics system.

Overview

SKPhysicsWorld runs the physics engine of a scene and is the place that contact detection occurs. Do not create a SKPhysicsWorld directly; the system creates a physics world and adds it to the scene’s SKScene.PhysicsWorld property.

The physics world allows you to:

- Set important properties like SKPhysicsWorld.Gravity - Join two physics bodies using an SKPhysicsJoint - Respond to collision between two physics bodies using SKPhysicsWorld.ContactDelegate - Do custom collisions detection or hit testing

Configuring the Physics World

Joining Physics Bodies with Joints

Detecting Collisions

Searching the Scene for Physics Bodies

Sampling Physics Fields

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld

func NewSKPhysicsWorld

func NewSKPhysicsWorld() SKPhysicsWorld

NewSKPhysicsWorld creates a new SKPhysicsWorld instance.

func SKPhysicsWorldFromID

func SKPhysicsWorldFromID(id objc.ID) SKPhysicsWorld

SKPhysicsWorldFromID constructs a SKPhysicsWorld from an objc.ID.

The driver of the physics engine in a scene; it exposes the ability for you to configure and query the physics system.

func (SKPhysicsWorld) AddJoint

func (p SKPhysicsWorld) AddJoint(joint ISKPhysicsJoint)

Adds a joint to the physics world.

joint: The joint to add.

Discussion

For a joint to take effect, it must be added to the physics world.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld/add(_:)

func (SKPhysicsWorld) Autorelease

func (p SKPhysicsWorld) Autorelease() SKPhysicsWorld

Autorelease adds the receiver to the current autorelease pool.

func (SKPhysicsWorld) BodyAlongRayStartEnd

func (p SKPhysicsWorld) BodyAlongRayStartEnd(start corefoundation.CGPoint, end corefoundation.CGPoint) ISKPhysicsBody

Searches for the first physics body that intersects a ray.

start: The starting point for the ray in scene coordinates.

end: The ending point for the ray in scene coordinates.

Return Value

The first physics body discovered that intersects the ray. This may be any body along the ray; it is not guaranteed to be the closest physics body. If no body intersects the ray, this method returns `nil`.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld/body(alongRayStart:end:)

func (SKPhysicsWorld) BodyAtPoint

func (p SKPhysicsWorld) BodyAtPoint(point corefoundation.CGPoint) ISKPhysicsBody

Searches for the first physics body that contains a point.

point: A point in scene coordinates.

Return Value

The first physics body discovered that contains the point. If no body contains the point, this method returns `nil`.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld/body(at:)

func (SKPhysicsWorld) BodyInRect

Searches for the first physics body that intersects the specified rectangle.

rect: A rectangle in scene coordinates.

Return Value

The first physics body discovered that intersects the rectangle. If no body intersects the rectangle, this method returns `nil`.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld/body(in:)

func (SKPhysicsWorld) ContactDelegate

func (p SKPhysicsWorld) ContactDelegate() SKPhysicsContactDelegate

A delegate that is called when two physics bodies come in contact with each other.

Discussion

A contact is created when two physics bodies overlap and one of the physics bodies has a SKPhysicsBody.ContactTestBitMask property that overlaps with the other body’s SKPhysicsBody.CategoryBitMask property. By default, a physics body’s SKPhysicsBody.ContactTestBitMask is set to all bits cleared.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld/contactDelegate

func (SKPhysicsWorld) EncodeWithCoder

func (p SKPhysicsWorld) EncodeWithCoder(coder foundation.INSCoder)

func (SKPhysicsWorld) EnumerateBodiesAlongRayStartEndUsingBlock

func (p SKPhysicsWorld) EnumerateBodiesAlongRayStartEndUsingBlock(start corefoundation.CGPoint, end corefoundation.CGPoint, block SKPhysicsBodyCGPointCGVectorBoolHandler)

Enumerates all the physics bodies in the scene that intersect a ray.

start: The starting point for the ray in scene coordinates.

end: The ending point for the ray in scene coordinates.

block: A block to be called for each physics body that the ray touches. The block takes the following parameters:

body: The physics body that the ray intersected. point: The point in scene coordinates where the ray contacted the physics body. normal: The normal vector for the physics body at the point of contact. stop: A pointer to a Boolean variable. Your block can set this to true to terminate the enumeration.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld/enumerateBodies(alongRayStart:end:using:)

func (SKPhysicsWorld) EnumerateBodiesAtPointUsingBlock

func (p SKPhysicsWorld) EnumerateBodiesAtPointUsingBlock(point corefoundation.CGPoint, block SKPhysicsBodyBoolHandler)

Enumerates all the physics bodies in the scene that contain a point.

point: A point in scene coordinates.

block: A block to be called for each physics body that contains the point. The block takes the following parameters:

body: The physics body that the ray intersected. stop: A pointer to a Boolean variable. Your block can set this to true to terminate the enumeration.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld/enumerateBodies(at:using:)

func (SKPhysicsWorld) EnumerateBodiesInRectUsingBlock

func (p SKPhysicsWorld) EnumerateBodiesInRectUsingBlock(rect corefoundation.CGRect, block SKPhysicsBodyBoolHandler)

Enumerates all the physics bodies in the scene that intersect the specified rectangle.

rect: A rectangle in scene coordinates.

block: A block to be called for each physics body that contains the point. The block takes the following parameters:

body: The physics body that intersected the rectangle. stop: A pointer to a Boolean variable. Your block can set this to true to terminate the enumeration.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld/enumerateBodies(in:using:)

func (SKPhysicsWorld) Gravity

A vector that specifies the gravitational acceleration applied to physics bodies in the physics world.

Discussion

The components of this property are measured in meters per second. The default value is `(0.0,-9.8)`, which represent’s Earth’s gravity.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld/gravity

func (SKPhysicsWorld) Init

func (p SKPhysicsWorld) Init() SKPhysicsWorld

Init initializes the instance.

func (SKPhysicsWorld) RemoveAllJoints

func (p SKPhysicsWorld) RemoveAllJoints()

Removes all joints from the physics world.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld/removeAllJoints()

func (SKPhysicsWorld) RemoveJoint

func (p SKPhysicsWorld) RemoveJoint(joint ISKPhysicsJoint)

Removes a specific joint from the physics world.

joint: The joint to remove.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld/remove(_:)

func (SKPhysicsWorld) SampleFieldsAt

func (p SKPhysicsWorld) SampleFieldsAt(position Vector_float3) Vector_float3

Samples all of the field nodes in the scene and returns the summation of their forces at that point.

position: A position in scene coordinates.

Return Value

The summation of forces exerted on that point.

Discussion

The sample is calculated as if a physics body is placed at that position in the scene. The body is assumed to have a mass of `1.0`, with no charge or velocity. The body is affected by all field nodes.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld/sampleFields(at:)

func (SKPhysicsWorld) SetContactDelegate

func (p SKPhysicsWorld) SetContactDelegate(value SKPhysicsContactDelegate)

func (SKPhysicsWorld) SetGravity

func (p SKPhysicsWorld) SetGravity(value corefoundation.CGVector)

func (SKPhysicsWorld) SetSpeed

func (p SKPhysicsWorld) SetSpeed(value float64)

func (SKPhysicsWorld) Speed

func (p SKPhysicsWorld) Speed() float64

The rate at which the simulation executes.

Discussion

The default value is `1.0`, which means the simulation runs at normal speed. A value other than the default changes the rate at which time passes in the physics simulation. For example, a speed value of `2.0` indicates that time in the physics simulation passes twice as fast as the scene’s simulation time. A value of `0.0` pauses the physics simulation.

See: https://developer.apple.com/documentation/SpriteKit/SKPhysicsWorld/speed

type SKPhysicsWorldClass

type SKPhysicsWorldClass struct {
	// contains filtered or unexported fields
}

func GetSKPhysicsWorldClass

func GetSKPhysicsWorldClass() SKPhysicsWorldClass

GetSKPhysicsWorldClass returns the class object for SKPhysicsWorld.

func (SKPhysicsWorldClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKPhysicsWorldClass) Class

func (sc SKPhysicsWorldClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKRange

type SKRange struct {
	objectivec.Object
}

A definition of a range of floating-point values.

Overview

You typically use a SKRange to clamp a value so that it is within the specified range.

Creating a Range Object

Inspecting a Range Object’s Limits

See: https://developer.apple.com/documentation/SpriteKit/SKRange

func NewRangeWithConstantValue

func NewRangeWithConstantValue(value float64) SKRange

Creates and initializes a new range object that specifies a constant value.

value: A constant.

Return Value

A newly initialized range object whose minimum and maximum value are both equal to `value`.

See: https://developer.apple.com/documentation/SpriteKit/SKRange/init(constantValue:)

func NewRangeWithLowerLimit

func NewRangeWithLowerLimit(lower float64) SKRange

Creates and initializes a new range object that specifies only a minimum value.

lower: The minimum value for the range.

Return Value

A newly initialized range object whose minimum value is `lower` and whose maximum value is `+Inf`.

See: https://developer.apple.com/documentation/SpriteKit/SKRange/init(lowerLimit:)

func NewRangeWithLowerLimitUpperLimit

func NewRangeWithLowerLimitUpperLimit(lower float64, upper float64) SKRange

Initializes a new range object.

lower: The minimum value for the range.

upper: The maximum value for the range.

Return Value

A newly initialized range object.

See: https://developer.apple.com/documentation/SpriteKit/SKRange/init(lowerLimit:upperLimit:)

func NewRangeWithUpperLimit

func NewRangeWithUpperLimit(upper float64) SKRange

Creates and initializes a new range object that specifies only a maximum value.

upper: The maximum value for the range.

Return Value

A newly initialized range object whose minimum value is `-Inf` and whose maximum value is `upper`.

See: https://developer.apple.com/documentation/SpriteKit/SKRange/init(upperLimit:)

func NewRangeWithValueVariance

func NewRangeWithValueVariance(value float64, variance float64) SKRange

Creates and initializes a new range object using a value and a maximum distance from that value.

value: The midpoint for the range.

variance: The maximum amount that a value may differ from the midpoint.

Return Value

A newly initialized range object whose minimum value is `value-variance` and whose maximum value is `value+variance`.

See: https://developer.apple.com/documentation/SpriteKit/SKRange/init(value:variance:)

func NewSKRange

func NewSKRange() SKRange

NewSKRange creates a new SKRange instance.

func SKRangeFromID

func SKRangeFromID(id objc.ID) SKRange

SKRangeFromID constructs a SKRange from an objc.ID.

A definition of a range of floating-point values.

func (SKRange) Autorelease

func (r SKRange) Autorelease() SKRange

Autorelease adds the receiver to the current autorelease pool.

func (SKRange) EncodeWithCoder

func (r SKRange) EncodeWithCoder(coder foundation.INSCoder)

func (SKRange) Init

func (r SKRange) Init() SKRange

Init initializes the instance.

func (SKRange) InitWithLowerLimitUpperLimit

func (r SKRange) InitWithLowerLimitUpperLimit(lower float64, upper float64) SKRange

Initializes a new range object.

lower: The minimum value for the range.

upper: The maximum value for the range.

Return Value

A newly initialized range object.

See: https://developer.apple.com/documentation/SpriteKit/SKRange/init(lowerLimit:upperLimit:)

func (SKRange) LowerLimit

func (r SKRange) LowerLimit() float64

The minimum possible value.

See: https://developer.apple.com/documentation/SpriteKit/SKRange/lowerLimit

func (SKRange) SetLowerLimit

func (r SKRange) SetLowerLimit(value float64)

func (SKRange) SetUpperLimit

func (r SKRange) SetUpperLimit(value float64)

func (SKRange) UpperLimit

func (r SKRange) UpperLimit() float64

The maximum possible value.

See: https://developer.apple.com/documentation/SpriteKit/SKRange/upperLimit

type SKRangeClass

type SKRangeClass struct {
	// contains filtered or unexported fields
}

func GetSKRangeClass

func GetSKRangeClass() SKRangeClass

GetSKRangeClass returns the class object for SKRange.

func (SKRangeClass) Alloc

func (sc SKRangeClass) Alloc() SKRange

Alloc allocates memory for a new instance of the class.

func (SKRangeClass) Class

func (sc SKRangeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (SKRangeClass) RangeWithNoLimits

func (_SKRangeClass SKRangeClass) RangeWithNoLimits() SKRange

Creates and initializes a new range object that encompasses all possible values.

Return Value

A newly initialized range object whose minimum value is `—Inf` and whose maximum value is `+Inf`.

See: https://developer.apple.com/documentation/SpriteKit/SKRange/withNoLimits()

type SKReachConstraints

type SKReachConstraints struct {
	objectivec.Object
}

A specification of the degree of freedom when solving inverse kinematics.

Overview

An SKReachConstraints object is used to describe the range of motion for an SKNode object whenever an inverse kinematic (IK) action is executed. To use reach constraints, create an SKReachConstraints object and assign it to a node’s SKNode.ReachConstraints property. For more information on using reach actions to perform IK animations, see the SKAction class.

Working with Reach Constraints

See: https://developer.apple.com/documentation/SpriteKit/SKReachConstraints

func NewReachConstraintsWithLowerAngleLimitUpperAngleLimit

func NewReachConstraintsWithLowerAngleLimitUpperAngleLimit(lowerAngleLimit float64, upperAngleLimit float64) SKReachConstraints

Initializes a new reach constraint object.

lowerAngleLimit: The minimum angle that the node can have when it is rotated by a reach event.

upperAngleLimit: The maximum angle that the node can have when it is rotated by a reach event.

Return Value

A newly initialized reach constraint.

Discussion

When a reach action is executed, a node’s SKNode.ZRotation property may be changed by the action to satisfy the reach action. Any value calculated by the reach action for a node is always inside the range specified by the reach constraint attached to the node’s SKNode.ReachConstraints property.

See: https://developer.apple.com/documentation/SpriteKit/SKReachConstraints/init(lowerAngleLimit:upperAngleLimit:)

func NewSKReachConstraints

func NewSKReachConstraints() SKReachConstraints

NewSKReachConstraints creates a new SKReachConstraints instance.

func SKReachConstraintsFromID

func SKReachConstraintsFromID(id objc.ID) SKReachConstraints

SKReachConstraintsFromID constructs a SKReachConstraints from an objc.ID.

A specification of the degree of freedom when solving inverse kinematics.

func (SKReachConstraints) Autorelease

func (r SKReachConstraints) Autorelease() SKReachConstraints

Autorelease adds the receiver to the current autorelease pool.

func (SKReachConstraints) EncodeWithCoder

func (r SKReachConstraints) EncodeWithCoder(coder foundation.INSCoder)

func (SKReachConstraints) Init

Init initializes the instance.

func (SKReachConstraints) InitWithLowerAngleLimitUpperAngleLimit

func (r SKReachConstraints) InitWithLowerAngleLimitUpperAngleLimit(lowerAngleLimit float64, upperAngleLimit float64) SKReachConstraints

Initializes a new reach constraint object.

lowerAngleLimit: The minimum angle that the node can have when it is rotated by a reach event.

upperAngleLimit: The maximum angle that the node can have when it is rotated by a reach event.

Return Value

A newly initialized reach constraint.

Discussion

When a reach action is executed, a node’s SKNode.ZRotation property may be changed by the action to satisfy the reach action. Any value calculated by the reach action for a node is always inside the range specified by the reach constraint attached to the node’s SKNode.ReachConstraints property.

See: https://developer.apple.com/documentation/SpriteKit/SKReachConstraints/init(lowerAngleLimit:upperAngleLimit:)

func (SKReachConstraints) LowerAngleLimit

func (r SKReachConstraints) LowerAngleLimit() float64

The minimum angle that the node can have after it is rotated by a reach event.

See: https://developer.apple.com/documentation/SpriteKit/SKReachConstraints/lowerAngleLimit

func (SKReachConstraints) SetLowerAngleLimit

func (r SKReachConstraints) SetLowerAngleLimit(value float64)

func (SKReachConstraints) SetUpperAngleLimit

func (r SKReachConstraints) SetUpperAngleLimit(value float64)

func (SKReachConstraints) UpperAngleLimit

func (r SKReachConstraints) UpperAngleLimit() float64

The maximum angle that the node can have after it is rotated by a reach event.

See: https://developer.apple.com/documentation/SpriteKit/SKReachConstraints/upperAngleLimit

type SKReachConstraintsClass

type SKReachConstraintsClass struct {
	// contains filtered or unexported fields
}

func GetSKReachConstraintsClass

func GetSKReachConstraintsClass() SKReachConstraintsClass

GetSKReachConstraintsClass returns the class object for SKReachConstraints.

func (SKReachConstraintsClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKReachConstraintsClass) Class

func (sc SKReachConstraintsClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKReferenceNode

type SKReferenceNode struct {
	SKNode
}

A node that’s defined in an archived `XCUIElementTypeSks` file.

Overview

SKReferenceNode is used within an archived `XCUIElementTypeSks` file to refer to node defined in another `XCUIElementTypeSks` file without duplicating its definition. This way, a change to the referenced node propagates to all the references in other files.

As an example, you might want to share an enemy ship across two different levels, Scene1.sks and Scene2.sks, in a level-based game. Reference nodes allow you to do that without creating copies of the shared node and its properties.

To use a reference node:

- Create the shared content in a separate archive - Add references to the shared archive within your scene archives

When each scene is loaded, the reference nodes are resolved dynamically, and therefore you only need to configure a shared object in one place.

Initializers

Regenerating

Loading Callback

See: https://developer.apple.com/documentation/SpriteKit/SKReferenceNode

func NewReferenceNodeWithCoder

func NewReferenceNodeWithCoder(aDecoder foundation.INSCoder) SKReferenceNode

A method that initializes a reference node from an archive.

See: https://developer.apple.com/documentation/SpriteKit/SKReferenceNode/init(coder:)

func NewReferenceNodeWithFileNamed

func NewReferenceNodeWithFileNamed(fileName string) SKReferenceNode

Initializes a reference node from a file in the app’s main bundle.

fileName: The name of a file stored in the app’s main bundle.

Return Value

A newly initialized reference node.

Discussion

This initializer is for loading files that reside inside of the app bundle.

See: https://developer.apple.com/documentation/SpriteKit/SKReferenceNode/init(fileNamed:)-2yeh2

func NewReferenceNodeWithURL

func NewReferenceNodeWithURL(url foundation.NSURL) SKReferenceNode

Initializes a reference node from a URL.

url: The URL of the reference node.

Return Value

A newly initialized reference node.

Discussion

This intializer is for loading archives that reside outside of the app bundle.

See: https://developer.apple.com/documentation/SpriteKit/SKReferenceNode/init(url:)-429mo

func NewSKReferenceNode

func NewSKReferenceNode() SKReferenceNode

NewSKReferenceNode creates a new SKReferenceNode instance.

func SKReferenceNodeFromID

func SKReferenceNodeFromID(id objc.ID) SKReferenceNode

SKReferenceNodeFromID constructs a SKReferenceNode from an objc.ID.

A node that’s defined in an archived `XCUIElementTypeSks` file.

func (SKReferenceNode) Autorelease

func (r SKReferenceNode) Autorelease() SKReferenceNode

Autorelease adds the receiver to the current autorelease pool.

func (SKReferenceNode) DidLoadReferenceNode

func (r SKReferenceNode) DidLoadReferenceNode(node ISKNode)

A method called by SpriteKit after the reference node’s contents are loaded.

node: The deserialized content’s root node.

Discussion

This method is called after the referenced content is added as a child of the reference node. Override this method in a subclass to implement custom loading behavior.

See: https://developer.apple.com/documentation/SpriteKit/SKReferenceNode/didLoad(_:)

func (SKReferenceNode) Init

Init initializes the instance.

func (SKReferenceNode) InitWithFileNamed

func (r SKReferenceNode) InitWithFileNamed(fileName string) SKReferenceNode

Initializes a reference node from a file in the app’s main bundle.

fileName: The name of a file stored in the app’s main bundle.

Return Value

A newly initialized reference node.

Discussion

This initializer is for loading files that reside inside of the app bundle.

See: https://developer.apple.com/documentation/SpriteKit/SKReferenceNode/init(fileNamed:)-2yeh2

func (SKReferenceNode) InitWithURL

func (r SKReferenceNode) InitWithURL(url foundation.NSURL) SKReferenceNode

Initializes a reference node from a URL.

url: The URL of the reference node.

Return Value

A newly initialized reference node.

Discussion

This intializer is for loading archives that reside outside of the app bundle.

See: https://developer.apple.com/documentation/SpriteKit/SKReferenceNode/init(url:)-429mo

func (SKReferenceNode) ResolveReferenceNode

func (r SKReferenceNode) ResolveReferenceNode()

Loads the reference node’s content and adds it as a new child node.

Discussion

The archive is deserialized and the root node is added as a child of the reference node. If this method is called on a reference node whose content is already loaded, the existing node tree is discarded and replaced with a fresh copy of the archive’s data.

SpriteKit calls this method automatically if the scene renders the reference node and the reference node has not previously been loaded.

See: https://developer.apple.com/documentation/SpriteKit/SKReferenceNode/resolve()

type SKReferenceNodeClass

type SKReferenceNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKReferenceNodeClass

func GetSKReferenceNodeClass() SKReferenceNodeClass

GetSKReferenceNodeClass returns the class object for SKReferenceNode.

func (SKReferenceNodeClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKReferenceNodeClass) Class

func (sc SKReferenceNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (SKReferenceNodeClass) ReferenceNodeWithFileNamed

func (_SKReferenceNodeClass SKReferenceNodeClass) ReferenceNodeWithFileNamed(fileName string) SKReferenceNode

Creates a reference node from a file in the app’s main bundle.

fileName: The name of a file stored in the app’s main bundle.

Return Value

A newly initialized reference node.

Discussion

This initializer is for loading files that reside inside of the app bundle.

See: https://developer.apple.com/documentation/SpriteKit/SKReferenceNode/init(fileNamed:)-77gs0

func (SKReferenceNodeClass) ReferenceNodeWithURL

func (_SKReferenceNodeClass SKReferenceNodeClass) ReferenceNodeWithURL(referenceURL foundation.NSURL) SKReferenceNode

Creates a reference node from a URL.

referenceURL: The URL of the reference node.

Return Value

A newly initialized reference node.

Discussion

This intializer is for loading archives that reside outside of the app bundle.

See: https://developer.apple.com/documentation/SpriteKit/SKReferenceNode/init(url:)-3jryz

type SKRegion

type SKRegion struct {
	objectivec.Object
}

The definition of an arbitrary area.

Overview

An SKRegion object defines a mathematical shape and is typically used to determine whether a particular point lies inside this area. For example, regions are used to define the area that a physics field can affect. Regions are defined using paths and mathematical shapes and can also be combined using constructive solid geometry.

Creating and Initializing Region Objects

Interacting with a Region

  • SKRegion.Path: Returns a Core Graphics path that defines the region.
  • SKRegion.ContainsPoint: Returns a Boolean value that indicates whether a particular point is contained in the region.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion

func NewRegionWithPath

func NewRegionWithPath(path coregraphics.CGPathRef) SKRegion

Initializes a new region using a Core Graphics path.

path: A path that defines the new region’s shape. The path is assumed to use the even-odd winding rule.

Return Value

A newly initialized region.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion/init(path:)

func NewRegionWithRadius

func NewRegionWithRadius(radius float32) SKRegion

Initializes a new region with a circular area.

radius: The radius of the region in points.

Return Value

A newly initialized region. The region is circular and centered on the origin.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion/init(radius:)

func NewRegionWithSize

func NewRegionWithSize(size corefoundation.CGSize) SKRegion

Initializes a new region with a rectangular area.

size: The size of the rectangle in points.

Return Value

A newly initialized region. The region is rectangular and centered on the origin.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion/init(size:)

func NewSKRegion

func NewSKRegion() SKRegion

NewSKRegion creates a new SKRegion instance.

func SKRegionFromID

func SKRegionFromID(id objc.ID) SKRegion

SKRegionFromID constructs a SKRegion from an objc.ID.

The definition of an arbitrary area.

func (SKRegion) Autorelease

func (r SKRegion) Autorelease() SKRegion

Autorelease adds the receiver to the current autorelease pool.

func (SKRegion) ContainsPoint

func (r SKRegion) ContainsPoint(point corefoundation.CGPoint) bool

Returns a Boolean value that indicates whether a particular point is contained in the region.

point: A point.

Return Value

true if the point is contained in the region; otherwise, false.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion/contains(_:)

func (SKRegion) EncodeWithCoder

func (r SKRegion) EncodeWithCoder(coder foundation.INSCoder)

func (SKRegion) Init

func (r SKRegion) Init() SKRegion

Init initializes the instance.

func (SKRegion) InitWithPath

func (r SKRegion) InitWithPath(path coregraphics.CGPathRef) SKRegion

Initializes a new region using a Core Graphics path.

path: A path that defines the new region’s shape. The path is assumed to use the even-odd winding rule.

Return Value

A newly initialized region.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion/init(path:)

func (SKRegion) InitWithRadius

func (r SKRegion) InitWithRadius(radius float32) SKRegion

Initializes a new region with a circular area.

radius: The radius of the region in points.

Return Value

A newly initialized region. The region is circular and centered on the origin.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion/init(radius:)

func (SKRegion) InitWithSize

func (r SKRegion) InitWithSize(size corefoundation.CGSize) SKRegion

Initializes a new region with a rectangular area.

size: The size of the rectangle in points.

Return Value

A newly initialized region. The region is rectangular and centered on the origin.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion/init(size:)

func (SKRegion) InverseRegion

func (r SKRegion) InverseRegion() ISKRegion

Returns a new region that is the mathematical inverse of an existing region.

Return Value

A new region object whose contents include all points that are not in the current region.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion/inverse()

func (SKRegion) Path

func (r SKRegion) Path() coregraphics.CGPathRef

Returns a Core Graphics path that defines the region.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion/path

func (SKRegion) RegionByDifferenceFromRegion

func (r SKRegion) RegionByDifferenceFromRegion(region ISKRegion) ISKRegion

Returns a new region created by subtracting the contents of another region from this region.

region: The region to subtract.

Return Value

A new region whose contents include all points in the current region that are not also included in the second region.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion/byDifference(from:)

func (SKRegion) RegionByIntersectionWithRegion

func (r SKRegion) RegionByIntersectionWithRegion(region ISKRegion) ISKRegion

Returns a new region created by intersecting the contents of this region with another region.

region: The region to intersect.

Return Value

A new region whose contents include all points that are included in both regions.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion/byIntersection(with:)

func (SKRegion) RegionByUnionWithRegion

func (r SKRegion) RegionByUnionWithRegion(region ISKRegion) ISKRegion

Returns a new region created by combining the contents of this region with another region.

region: The region to combine with the current region.

Return Value

A new region whose contents include all points that are included in either region.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion/byUnion(with:)

type SKRegionClass

type SKRegionClass struct {
	// contains filtered or unexported fields
}

func GetSKRegionClass

func GetSKRegionClass() SKRegionClass

GetSKRegionClass returns the class object for SKRegion.

func (SKRegionClass) Alloc

func (sc SKRegionClass) Alloc() SKRegion

Alloc allocates memory for a new instance of the class.

func (SKRegionClass) Class

func (sc SKRegionClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (SKRegionClass) InfiniteRegion

func (_SKRegionClass SKRegionClass) InfiniteRegion() SKRegion

Returns a region that defines a region that includes all points.

Return Value

Returns a singleton region that covers an infinite area.

See: https://developer.apple.com/documentation/SpriteKit/SKRegion/infinite()

type SKRenderer

type SKRenderer struct {
	objectivec.Object
}

An object that renders a scene into a custom Metal rendering pipeline and drives the scene update cycle.

Overview

SKRenderer allows an app to mix SpriteKit and Metal content by rendering an SKScene into a Metal command buffer. The reasons an app may do this instead of displaying a scene in SKView are:

- Apps that are built in Metal can mix in SpriteKit content. While it’s possible to add SKView as a subview to a Metal view, plugging SKRenderer into their Metal pipeline allows layering SpriteKit content at a specific z-position. - You might be writing a SpriteKit app and decide later to take full control over some portion of renderering by implementing it with Metal, yet continue to use SpriteKit for the rest of the app. For example, you might write the environmental effects layer of your app that does fog, clouds, and rain, with custom Metal shaders, and continue to layer content below and above that with SpriteKit.

First Steps

Rendering the Scene

Driving the Scene’s Update Cycle

Enabling Visual Statistics for Debugging

See: https://developer.apple.com/documentation/SpriteKit/SKRenderer

func NewRendererWithDevice

func NewRendererWithDevice(device metal.MTLDevice) SKRenderer

Initializes with a specific GPU to render into.

device: A Metal device.

Return Value

A new renderer object.

Discussion

Pass in the same Metal device that is associated to the Metal command buffer passed into SKRenderer.RenderWithViewportCommandBufferRenderPassDescriptor.

See: https://developer.apple.com/documentation/SpriteKit/SKRenderer/init(device:)

func NewSKRenderer

func NewSKRenderer() SKRenderer

NewSKRenderer creates a new SKRenderer instance.

func SKRendererFromID

func SKRendererFromID(id objc.ID) SKRenderer

SKRendererFromID constructs a SKRenderer from an objc.ID.

An object that renders a scene into a custom Metal rendering pipeline and drives the scene update cycle.

func (SKRenderer) Autorelease

func (r SKRenderer) Autorelease() SKRenderer

Autorelease adds the receiver to the current autorelease pool.

func (SKRenderer) Init

func (r SKRenderer) Init() SKRenderer

Init initializes the instance.

func (SKRenderer) Scene

func (r SKRenderer) Scene() ISKScene

The scene this renderer will draw into the Metal command buffer.

See: https://developer.apple.com/documentation/SpriteKit/SKRenderer/scene

func (SKRenderer) SetIgnoresSiblingOrder

func (r SKRenderer) SetIgnoresSiblingOrder(value bool)

func (SKRenderer) SetScene

func (r SKRenderer) SetScene(value ISKScene)

func (SKRenderer) SetShouldCullNonVisibleNodes

func (r SKRenderer) SetShouldCullNonVisibleNodes(value bool)

func (SKRenderer) SetShowsDrawCount

func (r SKRenderer) SetShowsDrawCount(value bool)

func (SKRenderer) SetShowsFields

func (r SKRenderer) SetShowsFields(value bool)

func (SKRenderer) SetShowsNodeCount

func (r SKRenderer) SetShowsNodeCount(value bool)

func (SKRenderer) SetShowsPhysics

func (r SKRenderer) SetShowsPhysics(value bool)

func (SKRenderer) SetShowsQuadCount

func (r SKRenderer) SetShowsQuadCount(value bool)

func (SKRenderer) ShowsDrawCount

func (r SKRenderer) ShowsDrawCount() bool

A Boolean value that indicates whether the view displays the number of drawing passes it needed to render the view.

Discussion

Some operations in SpriteKit can require multiple rendering passes to draw a scene’s content. For example, an SKEffectNode object must render its children into a separate buffer, apply the effect, and then perform another pass to blend those results into its parent node. These additional rendering passes use more rendering resources, reducing your game’s frame rate or increasing its total power consumption. Use the draw count as another piece of data when you profile your game’s performance.

See: https://developer.apple.com/documentation/SpriteKit/SKRenderer/showsDrawCount

func (SKRenderer) ShowsFields

func (r SKRenderer) ShowsFields() bool

A Boolean value that indicates whether the view displays information about physics fields in the scene.

Discussion

When this debugging option is enabled, each time a frame is rendered, an image is drawn behind your scene that shows the effects of any physics fields contained in the scene.

See: https://developer.apple.com/documentation/SpriteKit/SKRenderer/showsFields

func (SKRenderer) ShowsNodeCount

func (r SKRenderer) ShowsNodeCount() bool

A Boolean value that indicates whether the view displays an overlay that shows physics bodies that are visible in the scene.

Discussion

When you enable this option, it shows the number of nodes currently in the scene’s node tree.

You may achieve additional performance gain by actually removing nodes from the node tree manually which are off screen. For example, in the case of SKRenderer.ShouldCullNonVisibleNodes, there would be less nodes for SpriteKit to test every frame whether they’re on screen.

See: https://developer.apple.com/documentation/SpriteKit/SKRenderer/showsNodeCount

func (SKRenderer) ShowsPhysics

func (r SKRenderer) ShowsPhysics() bool

A Boolean value that indicates whether the view displays physics-related debugging information.

Discussion

When this debugging option is enabled, each time a frame is rendered, an overlay image is drawn on top of your scene that shows the positions and shapes of any physics bodies visible in the scene.

See: https://developer.apple.com/documentation/SpriteKit/SKRenderer/showsPhysics

func (SKRenderer) ShowsQuadCount

func (r SKRenderer) ShowsQuadCount() bool

A Boolean value that indicates whether the view displays the number of rectangles used to render the scene.

Discussion

SpriteKit converts the node tree into one or more rendering passes. Each rendering pass is rendered using a series of textured rectangles (quads). The showsQuadCount property allows you to see the total number of quads that were used to render the scene’s contents. Use this as another piece of data when you profile your game’s performance. In most cases, fewer quads is better.

See: https://developer.apple.com/documentation/SpriteKit/SKRenderer/showsQuadCount

type SKRendererClass

type SKRendererClass struct {
	// contains filtered or unexported fields
}

func GetSKRendererClass

func GetSKRendererClass() SKRendererClass

GetSKRendererClass returns the class object for SKRenderer.

func (SKRendererClass) Alloc

func (sc SKRendererClass) Alloc() SKRenderer

Alloc allocates memory for a new instance of the class.

func (SKRendererClass) Class

func (sc SKRendererClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKRepeatMode

type SKRepeatMode int

See: https://developer.apple.com/documentation/SpriteKit/SKRepeatMode

const (
	// SKRepeatModeClamp: When a sample is calculated, the time value is clamped to the range of time values found in the sequence.
	SKRepeatModeClamp SKRepeatMode = 1
	// SKRepeatModeLoop: When a sample is calculated, the sequence loops back to the beginning of the sequence.
	SKRepeatModeLoop SKRepeatMode = 2
)

func (SKRepeatMode) String

func (e SKRepeatMode) String() string

type SKScene

type SKScene struct {
	SKEffectNode
}

An object that organizes all of the active SpriteKit content.

Overview

An SKScene object represents a scene of content in SpriteKit. A scene is the root node in a tree of SpriteKit nodes (SKNode). These nodes provide content that the scene animates and renders for display. To display a scene, you present it from an SKView, SKRenderer, or WKInterfaceSKScene.

SKScene is a subclass of SKEffectNode and enables certain effects to apply to the entire scene. Though applying effects to an entire scene can be an expensive operation, creativity, and ingenuity may help you find some interesting ways to use effects.

Creating a Scene Programmatically

Stretching Content to Fit the View

Configuring the Viewport

Responding to Loading and Resizing Events

Responding to Frame-Cycle Events

Configuring a Delegate

Setting the Background Appearance

Configuring Physics Properties

Adding Positional Audio

Converting Between Coordinate Systems

See: https://developer.apple.com/documentation/SpriteKit/SKScene

func NewSKScene

func NewSKScene() SKScene

NewSKScene creates a new SKScene instance.

func NewSceneNodeWithFileNamed

func NewSceneNodeWithFileNamed(filename string) SKScene

Creates a new node by loading an archive file from the game’s main bundle.

filename: The name of the file, without a file extension. The file must be in the app’s main bundle and have a `XCUIElementTypeSks` filename extension.

Return Value

The unarchived node object.

Discussion

If you call this method on a subclass of the SKScene class and the object in the archive is an SKScene object, the returned object is initialized as if it is a member of the subclass. You use this behavior to create scene layouts in the Xcode Editor and provide custom behaviors in your subclass.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(fileNamed:)

func NewSceneWithCoder

func NewSceneWithCoder(aDecoder foundation.INSCoder) SKScene

Called when a node is initialized from an .sks file.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(coder:)

func NewSceneWithSize

func NewSceneWithSize(size corefoundation.CGSize) SKScene

Initializes a new scene object.

size: The size of the scene in points.

Return Value

A newly initialized scene object.

Discussion

This is the class’s designated initializer method.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/init(size:)

func SKSceneFromID

func SKSceneFromID(id objc.ID) SKScene

SKSceneFromID constructs a SKScene from an objc.ID.

An object that organizes all of the active SpriteKit content.

func (SKScene) AnchorPoint

func (s SKScene) AnchorPoint() corefoundation.CGPoint

The point in the view’s frame that corresponds to the scene’s origin.

Discussion

When a scene is presented and a camera node has not been specified, the SKScene.Size and SKScene.AnchorPoint properties determine which part of the scene’s coordinate space is visible in the view.

You specify the value using the unit coordinate space. The default value is `(0,0)`, which corresponds to the lower-left corner of the view’s frame rectangle.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/anchorPoint

func (SKScene) AudioEngine

func (s SKScene) AudioEngine() avfaudio.AVAudioEngine

The AVFoundation audio engine used to play audio from audio nodes contained in the scene.

Discussion

An audio engine instance is automatically created for you when the scene is created. You can use methods and properties on a scene’s audio engine for overall control of all of its child audio nodes. The following code shows how a scene’s overall volume can be reduced from its default of 1.0 down to 0.2 and then paused:

See: https://developer.apple.com/documentation/SpriteKit/SKScene/audioEngine

func (SKScene) Autorelease

func (s SKScene) Autorelease() SKScene

Autorelease adds the receiver to the current autorelease pool.

func (SKScene) BackgroundColor

func (s SKScene) BackgroundColor() appkit.NSColor

The background color of the scene.

Discussion

The default value is a gray color (RGBA `0.15, 0.15, 0.15, 1.0)`.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/backgroundColor

func (SKScene) Camera

func (s SKScene) Camera() ISKCameraNode

The camera node in the scene that determines what part of the scene’s coordinate space is visible in the view.

Discussion

The default value of this property is `nil`, which means that the scene’s SKScene.AnchorPoint and SKScene.Size properties determine what portion of the scene is visible. If set to point to a camera node contained in the scene, the SKScene.AnchorPoint property is ignored and the scene is rendered using the camera node’s properties instead.

A camera must be added as a child of the scene for it to render that scene.

Listing 1 shows, in Swift, how to add a camera to an SKScene named `scene`. The camera is positioned in the center of the scene which gives the same result as rendering a camera-less scene with an SKScene.AnchorPoint of zero.

Listing 1. Adding a camera to a scene

For more information, see SKCameraNode.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/camera

func (SKScene) ConvertPointFromView

func (s SKScene) ConvertPointFromView(point corefoundation.CGPoint) corefoundation.CGPoint

Converts a point from view coordinates to scene coordinates.

point: A point in view coordinates.

Return Value

The same point in the scene’s coordinate system.

Discussion

The scene must be presented in a view before calling this method.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/convertPoint(fromView:)

func (SKScene) ConvertPointToView

func (s SKScene) ConvertPointToView(point corefoundation.CGPoint) corefoundation.CGPoint

Converts a point from scene coordinates to view coordinates.

point: A point in scene coordinates.

Return Value

The same point in the view’s coordinate system.

Discussion

The scene must be presented in a view before calling this method.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/convertPoint(toView:)

func (SKScene) Delegate

func (s SKScene) Delegate() SKSceneDelegate

A delegate to be called during the animation loop.

Discussion

When a delegate is present, when any of the animation loop methods steps are executed, your delegate is called. Typically, you use a delegate when you do not want to implement a scene subclass or if you want to dynamically change the scene behavior at runtime.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/delegate

func (SKScene) DidApplyConstraints

func (s SKScene) DidApplyConstraints()

Tells your app to peform any necessary logic after constraints are applied.

Discussion

Do not call this method directly; it is called exactly once per frame, so long as the scene is presented in a view and is not paused. By default, this method does nothing. Your scene subclass should override this method and perform any necessary updates to the scene.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/didApplyConstraints()

func (SKScene) DidChangeSize

func (s SKScene) DidChangeSize(oldSize corefoundation.CGSize)

Tells you when the scene’s size has changed.

oldSize: The old size of the scene, in points.

Discussion

This method is intended to be overridden in a subclass. Typically, you use this method to adjust the positions of nodes in the scene.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/didChangeSize(_:)

func (SKScene) DidEvaluateActions

func (s SKScene) DidEvaluateActions()

Tells your app to peform any necessary logic after scene actions are evaluated.

Discussion

Do not call this method directly; it is called by the system exactly once per frame, so long as the scene is presented in a view and is not paused. It is called after any actions have been evaluated by nodes in the scene but before any physics are simulated.

Any additional actions applied are not evaluated until the next update.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/didEvaluateActions()

func (SKScene) DidFinishUpdate

func (s SKScene) DidFinishUpdate()

Tells your app to peform any necessary logic after the scene has finished all of the steps required to process animations.

Discussion

Do not call this method directly; it is called by the system exactly once per frame, so long as the scene is presented in a view and is not paused. It is called after all update logic has been completed and before the scene is rendered.

Any additional actions applied are not evaluated until the next update.

Any changes to physics bodies are not simulated until the next update.

Any changes to constraints will not be applied until the next update.

No further update logic will be applied to the scene after this call. Any values set on nodes here will be used when the scene is rendered for the current frame.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/didFinishUpdate()

func (SKScene) DidMoveToView

func (s SKScene) DidMoveToView(view ISKView)

Tells you when the scene is presented by a view.

view: The view that is presenting the scene.

Discussion

This method is intended to be overridden in a subclass. You can use this method to implement any custom behavior for your scene when it is about to be presented by a view. For example, you might use this method to create the scene’s contents.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/didMove(to:)

func (SKScene) DidSimulatePhysics

func (s SKScene) DidSimulatePhysics()

Tells your app to peform any necessary logic after physics simulations are performed.

Discussion

Do not call this method directly; it is called by the system exactly once per frame, so long as the scene is presented in a view and is not paused. It is called after physics has been simulated in the scene.

Any additional actions applied are not evaluated until the next update.

Any changes to physics bodies are not simulated until the next update.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/didSimulatePhysics()

func (SKScene) Init

func (s SKScene) Init() SKScene

Init initializes the instance.

func (SKScene) InitWithSize

func (s SKScene) InitWithSize(size corefoundation.CGSize) SKScene

Initializes a new scene object.

size: The size of the scene in points.

Return Value

A newly initialized scene object.

Discussion

This is the class’s designated initializer method.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/init(size:)

func (SKScene) Listener

func (s SKScene) Listener() ISKNode

A node used to determine the position of the listener for positional audio in the scene.

Discussion

The default value is `nil`, which means that the scene’s origin is used as the listener position for audio effects played by SKAudioNode objects in the scene. If a non-`nil` value is specified, it must be a node in the scene.

Typically, you want the SKScene.Camera to be the listener so that audio nodes which are on screen are louder than off screen ones. In a game, the node that defines the player would likely be set as the `listener`.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/listener

func (SKScene) PhysicsWorld

func (s SKScene) PhysicsWorld() ISKPhysicsWorld

The physics simulation associated with the scene.

Discussion

Every scene automatically creates a physics world object to simulate physics on nodes in the scene. You use this property to access the scene’s global physics properties, such as gravity. To add physics to a particular node, see SKNode.PhysicsBody.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/physicsWorld

func (SKScene) ScaleMode

func (s SKScene) ScaleMode() SKSceneScaleMode

A setting that defines how the scene is mapped to the view that presents it.

Discussion

It is possible for a scene’s size to differ from the size of the view it is presented in. The scale mode determines how the visible portion of the scene is mapped to the view. The possible values are listed in SKSceneScaleMode. The default value is SKSceneScaleMode.fill.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/scaleMode

func (SKScene) SceneDidLoad

func (s SKScene) SceneDidLoad()

Tells you when the scene is presented.

Discussion

This method is intended to be overridden in a subclass. It is the preferred location to peform custom setup after the scene has been initialized or decoded.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/sceneDidLoad()

func (SKScene) SetAnchorPoint

func (s SKScene) SetAnchorPoint(value corefoundation.CGPoint)

func (SKScene) SetBackgroundColor

func (s SKScene) SetBackgroundColor(value appkit.NSColor)

func (SKScene) SetCamera

func (s SKScene) SetCamera(value ISKCameraNode)

func (SKScene) SetDelegate

func (s SKScene) SetDelegate(value SKSceneDelegate)

func (SKScene) SetListener

func (s SKScene) SetListener(value ISKNode)

func (SKScene) SetScaleMode

func (s SKScene) SetScaleMode(value SKSceneScaleMode)

func (SKScene) SetSize

func (s SKScene) SetSize(value corefoundation.CGSize)

func (SKScene) Size

func (s SKScene) Size() corefoundation.CGSize

The dimensions of the scene, in points.

Discussion

When a scene is first initialized, its size property is configured by the designated initializer. The size of the scene specifies the size of the visible portion of the scene in points. This is only used to specify the visible portion of the scene. Nodes in the tree can be positioned outside of this area; those nodes are still processed by the scene, but are ignored by the renderer.

When a scene is presented, the SKScene.Size and SKScene.AnchorPoint properties determine the portion of the scene’s coordinate space that is visible in the view.

If you set the SKScene.Size property to a new value, the scene’s SKScene.DidChangeSize method is called. This property can also change if the SKScene.ScaleMode property is set to SKSceneScaleMode.resizeFill and the presenting view is resized. After the scene’s size changes, future updates are rendered immediately at the new size.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/size

func (SKScene) Update

func (s SKScene) Update(currentTime foundation.NSTimeInterval)

Tells your app to perform any app-specific logic to update your scene.

currentTime: The current system time.

Discussion

Do not call this method directly; it is called by the system exactly once per frame, so long as the scene is presented in a view and is not paused. This is the first method called when animating the scene, before any actions are evaluated and before any physics are simulated.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/update(_:)

func (SKScene) View

func (s SKScene) View() ISKView

The view that is currently presenting the scene.

Discussion

To present a scene, you call the SKView.PresentScene method or SKView.PresentSceneTransition method on the SKView class. If the scene is not currently presented, this property holds `nil`.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/view

func (SKScene) WillMoveFromView

func (s SKScene) WillMoveFromView(view ISKView)

Tells you when the scene is about to be removed from a view.

view: The view that is presenting the scene.

Discussion

This method is intended to be overridden in a subclass. You can use this method to implement any custom behavior for your scene when it is about to be removed from the view.

See: https://developer.apple.com/documentation/SpriteKit/SKScene/willMove(from:)

type SKSceneClass

type SKSceneClass struct {
	// contains filtered or unexported fields
}

func GetSKSceneClass

func GetSKSceneClass() SKSceneClass

GetSKSceneClass returns the class object for SKScene.

func (SKSceneClass) Alloc

func (sc SKSceneClass) Alloc() SKScene

Alloc allocates memory for a new instance of the class.

func (SKSceneClass) Class

func (sc SKSceneClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKSceneDelegate

type SKSceneDelegate interface {
	objectivec.IObject
}

Methods that, when implemented, allow any class to participate in the SpriteKit render loop callbacks.

See: https://developer.apple.com/documentation/SpriteKit/SKSceneDelegate

type SKSceneDelegateConfig

type SKSceneDelegateConfig struct {

	// Other Methods
	// UpdateForScene — Tells you to perform any app specific logic to update your scene.
	UpdateForScene func(currentTime foundation.NSTimeInterval, scene SKScene)
	// DidEvaluateActionsForScene — Tells you to peform any necessary logic after scene actions are evaluated.
	DidEvaluateActionsForScene func(scene SKScene)
	// DidSimulatePhysicsForScene — Tells you to peform any necessary logic after physics simulations are performed.
	DidSimulatePhysicsForScene func(scene SKScene)
	// DidApplyConstraintsForScene — Tells you to peform any necessary logic after constraints are applied.
	DidApplyConstraintsForScene func(scene SKScene)
	// DidFinishUpdateForScene — Tells you to peform any necessary logic after the scene has finished all of the steps required to process animations.
	DidFinishUpdateForScene func(scene SKScene)
}

SKSceneDelegateConfig holds optional typed callbacks for SKSceneDelegate methods. Set non-nil fields to register the corresponding Objective-C delegate method. Methods with nil callbacks are not registered, so [NSObject.RespondsToSelector] returns false for them — matching the Objective-C delegate pattern exactly.

See Apple Documentation for protocol details.

type SKSceneDelegateObject

type SKSceneDelegateObject struct {
	objectivec.Object
}

SKSceneDelegateObject wraps an existing Objective-C object that conforms to the SKSceneDelegate protocol.

func NewSKSceneDelegate

func NewSKSceneDelegate(config SKSceneDelegateConfig) SKSceneDelegateObject

NewSKSceneDelegate creates an Objective-C object implementing the SKSceneDelegate protocol.

Each call registers a unique Objective-C class containing only the methods set in config. This means [NSObject.RespondsToSelector] works correctly for optional delegate methods — only non-nil callbacks are registered.

The returned SKSceneDelegateObject satisfies the SKSceneDelegate interface and can be passed directly to SetDelegate and similar methods.

See Apple Documentation for protocol details.

func SKSceneDelegateObjectFromID

func SKSceneDelegateObjectFromID(id objc.ID) SKSceneDelegateObject

SKSceneDelegateObjectFromID constructs a SKSceneDelegateObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (SKSceneDelegateObject) BaseObject

func (o SKSceneDelegateObject) BaseObject() objectivec.Object

func (SKSceneDelegateObject) DidApplyConstraintsForScene

func (o SKSceneDelegateObject) DidApplyConstraintsForScene(scene ISKScene)

Tells you to peform any necessary logic after constraints are applied.

scene: The scene that is being animated.

Discussion

Do not call this method directly; it is called by the system exactly once per frame, so long as the scene is presented in a view and is not paused. It is called after any enabled constraints in the scene have been applied.

Any additional actions applied are not evaluated until the next update.

Any changes to physics bodies is not simulated until the next update.

Any changes to constraints will not be applied until the next update.

See: https://developer.apple.com/documentation/SpriteKit/SKSceneDelegate/didApplyConstraints(for:)

func (SKSceneDelegateObject) DidEvaluateActionsForScene

func (o SKSceneDelegateObject) DidEvaluateActionsForScene(scene ISKScene)

Tells you to peform any necessary logic after scene actions are evaluated.

scene: The scene that is being animated.

Discussion

Do not call this method directly; it is called by the system exactly once per frame, so long as the scene is presented in a view and is not paused. It is called after any actions have been evaluated by nodes in the scene but before any physics are simulated.

Any additional actions applied are not evaluated until the next update.

See: https://developer.apple.com/documentation/SpriteKit/SKSceneDelegate/didEvaluateActions(for:)

func (SKSceneDelegateObject) DidFinishUpdateForScene

func (o SKSceneDelegateObject) DidFinishUpdateForScene(scene ISKScene)

Tells you to peform any necessary logic after the scene has finished all of the steps required to process animations.

scene: The scene that is being animated.

Discussion

Do not call this method directly; it is called by the system exactly once per frame, so long as the scene is presented in a view and is not paused. It is called after all update logic has been completed and before the scene is rendered.

Any additional actions applied are not evaluated until the next update.

Any changes to physics bodies are not simulated until the next update.

Any changes to constraints will not be applied until the next update.

No further update logic will be applied to the scene after this call. Any values set on nodes here will be used when the scene is rendered for the current frame.

See: https://developer.apple.com/documentation/SpriteKit/SKSceneDelegate/didFinishUpdate(for:)

func (SKSceneDelegateObject) DidSimulatePhysicsForScene

func (o SKSceneDelegateObject) DidSimulatePhysicsForScene(scene ISKScene)

Tells you to peform any necessary logic after physics simulations are performed.

scene: The scene that is being animated.

Discussion

Do not call this method directly; it is called by the system exactly once per frame, so long as the scene is presented in a view and is not paused. It is called after physics has been simulated in the scene.

Any additional actions applied are not evaluated until the next update.

Any changes to physics bodies are not simulated until the next update.

See: https://developer.apple.com/documentation/SpriteKit/SKSceneDelegate/didSimulatePhysics(for:)

func (SKSceneDelegateObject) UpdateForScene

func (o SKSceneDelegateObject) UpdateForScene(currentTime foundation.NSTimeInterval, scene ISKScene)

Tells you to perform any app specific logic to update your scene.

currentTime: The current system time.

scene: The scene that is being animated.

Discussion

Do not call this method directly; it is called by the system exactly once per frame, so long as the scene is presented in a view and is not paused. This is the first method called when animating the scene, before any actions are evaluated and before any physics are simulated.

See: https://developer.apple.com/documentation/SpriteKit/SKSceneDelegate/update(_:for:)

type SKSceneScaleMode

type SKSceneScaleMode int

See: https://developer.apple.com/documentation/SpriteKit/SKSceneScaleMode

const (
	// SKSceneScaleModeAspectFill: The scaling factor of each dimension is calculated and the larger of the two is chosen.
	SKSceneScaleModeAspectFill SKSceneScaleMode = 1
	// SKSceneScaleModeAspectFit: The scaling factor of each dimension is calculated and the smaller of the two is chosen.
	SKSceneScaleModeAspectFit SKSceneScaleMode = 2
	// SKSceneScaleModeFill: Each axis of the scene is scaled independently so that each axis in the scene exactly maps to the length of that axis in the view.
	SKSceneScaleModeFill SKSceneScaleMode = 0
	// SKSceneScaleModeResizeFill: The scene is not scaled to match the view.
	SKSceneScaleModeResizeFill SKSceneScaleMode = 3
)

func (SKSceneScaleMode) String

func (e SKSceneScaleMode) String() string

type SKShader

type SKShader struct {
	objectivec.Object
}

An object that allows you to apply a custom fragment shader.

Overview

An SKShader object holds a custom OpenGL ES fragment shader. Shader objects are used to customize the drawing behavior of many different kinds of nodes in SpriteKit.

To use a custom shader, create an SKShader object and provide the source for the custom fragment shader. If your shader needs to provide uniform data to the shader, create one or more SKUniform objects and associate them with the shader object. If your shader needs to provide per-node data to the shader, create one or more SKAttribute objects and associate them with the relevant nodes. Then, assign the shader object to the SKSpriteNode.Shader property of any sprites that need the custom behavior.

Compiling a shader and the uniform data associated with it can be expensive. Because of this, you should:

- Initialize shader objects when your game launches, not while the game is running. - Avoid changing the shader’s source or changing the list of uniforms or attributes while your game is running. Either of these things recompiles the shader. - Share shader objects whenever possible. If multiple sprites need the same behavior, create one shader object and associate it with every sprite that needs that behavior. Do not create a separate shader for each sprite.

Creating a Shader

Providing Uniform Data to a Shader

Providing Attribute Data to a Shader

Accessing or Setting a Shader’s Source Code

See: https://developer.apple.com/documentation/SpriteKit/SKShader

func NewSKShader

func NewSKShader() SKShader

NewSKShader creates a new SKShader instance.

func NewShaderWithFileNamed

func NewShaderWithFileNamed(name string) SKShader

Creates a new shader object by loading the source for a fragment shader from a file stored in the app’s bundle.

name: The name of the fragment shader to load. The file must be present in your app bundle with the same name and a `XCUIElementTypeFsh` file extension.

Return Value

A newly initialized shader object whose initial source is loaded from the shader file.

See: https://developer.apple.com/documentation/SpriteKit/SKShader/init(fileNamed:)

func NewShaderWithSource

func NewShaderWithSource(source string) SKShader

Initializes a new shader object using the specified source code.

source: A string that holds the initial source for the shader.

Return Value

An initialized shader object.

See: https://developer.apple.com/documentation/SpriteKit/SKShader/init(source:)

func NewShaderWithSourceUniforms

func NewShaderWithSourceUniforms(source string, uniforms []SKUniform) SKShader

Initializes a new shader object using the specified source and uniform data.

source: A string that holds the initial source for the shader.

uniforms: A list of uniforms to add to the shader object.

Return Value

An initialized shader object.

See: https://developer.apple.com/documentation/SpriteKit/SKShader/init(source:uniforms:)

func SKShaderFromID

func SKShaderFromID(id objc.ID) SKShader

SKShaderFromID constructs a SKShader from an objc.ID.

An object that allows you to apply a custom fragment shader.

func (SKShader) AddUniform

func (s SKShader) AddUniform(uniform ISKUniform)

Adds a uniform to the shader.

uniform: The new uniform object to add. The uniform object’s name must not already be in use by another uniform attached to the shader.

Discussion

The uniform variable is automatically accessible inside your shader; do not add a declaration for it in your shader’s source code. The uniform must be accessed in the fragment shader.

See: https://developer.apple.com/documentation/SpriteKit/SKShader/addUniform(_:)

func (SKShader) Attributes

func (s SKShader) Attributes() []SKAttribute

The list of attributes associated with the shader.

Discussion

This property is not read-only, so you can also use it to provide all of the attributes in a single operation. Each of the attributes should be uniquely named.

See: https://developer.apple.com/documentation/SpriteKit/SKShader/attributes

func (SKShader) Autorelease

func (s SKShader) Autorelease() SKShader

Autorelease adds the receiver to the current autorelease pool.

func (SKShader) EncodeWithCoder

func (s SKShader) EncodeWithCoder(coder foundation.INSCoder)

func (SKShader) Init

func (s SKShader) Init() SKShader

Init initializes the instance.

func (SKShader) InitWithSource

func (s SKShader) InitWithSource(source string) SKShader

Initializes a new shader object using the specified source code.

source: A string that holds the initial source for the shader.

Return Value

An initialized shader object.

See: https://developer.apple.com/documentation/SpriteKit/SKShader/init(source:)

func (SKShader) InitWithSourceUniforms

func (s SKShader) InitWithSourceUniforms(source string, uniforms []SKUniform) SKShader

Initializes a new shader object using the specified source and uniform data.

source: A string that holds the initial source for the shader.

uniforms: A list of uniforms to add to the shader object.

Return Value

An initialized shader object.

See: https://developer.apple.com/documentation/SpriteKit/SKShader/init(source:uniforms:)

func (SKShader) RemoveUniformNamed

func (s SKShader) RemoveUniformNamed(name string)

Removes a uniform from the shader.

name: The name of the uniform to remove.

Discussion

If a uniform with that name does not exist in the shader, nothing happens.

See: https://developer.apple.com/documentation/SpriteKit/SKShader/removeUniformNamed(_:)

func (SKShader) SetAttributes

func (s SKShader) SetAttributes(value []SKAttribute)

func (SKShader) SetSource

func (s SKShader) SetSource(value string)

func (SKShader) SetUniforms

func (s SKShader) SetUniforms(value []SKUniform)

func (SKShader) Source

func (s SKShader) Source() string

The source code for the shader.

Discussion

The source code for a shader object can be updated at runtime. However, recompiling the fragment shader can be an expensive operation.

See: https://developer.apple.com/documentation/SpriteKit/SKShader/source

func (SKShader) UniformNamed

func (s SKShader) UniformNamed(name string) ISKUniform

Returns the uniform object corresponding to a particular uniform variable.

name: The name of the uniform to search for.

Return Value

The uniform object corresponding to the name, or `nil` if that uniform cannot be found.

See: https://developer.apple.com/documentation/SpriteKit/SKShader/uniformNamed(_:)

func (SKShader) Uniforms

func (s SKShader) Uniforms() []SKUniform

The list of uniforms associated with the shader.

Discussion

This property is not read-only, so you can also use it to provide all of the uniforms in a single operation. Each of the uniforms should be uniquely named.

See: https://developer.apple.com/documentation/SpriteKit/SKShader/uniforms

type SKShaderClass

type SKShaderClass struct {
	// contains filtered or unexported fields
}

func GetSKShaderClass

func GetSKShaderClass() SKShaderClass

GetSKShaderClass returns the class object for SKShader.

func (SKShaderClass) Alloc

func (sc SKShaderClass) Alloc() SKShader

Alloc allocates memory for a new instance of the class.

func (SKShaderClass) Class

func (sc SKShaderClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKShapeNode

type SKShapeNode struct {
	SKNode
}

A mathematical shape that can be stroked or filled.

Overview

SKShapeNode allows you to create onscreen graphical elements from mathematical points, lines, and curves. The advantage this has over rasterized graphics, such as those displayed by textures, is that shapes are rasterized dynamically at runtime to produce crisp detail and smoother edges.

Creating a Shape from a Path

Filling a Shape

Stroking a Shape

Configuring Alpha Blending

Controlling or Animating Sroke Length

Customizing Stroking or Fill Drawing

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode

func NewSKShapeNode

func NewSKShapeNode() SKShapeNode

NewSKShapeNode creates a new SKShapeNode instance.

func NewShapeNodeWithCircleOfRadius

func NewShapeNodeWithCircleOfRadius(radius float64) SKShapeNode

Creates a shape node with a circular path centered on the node’s origin.

radius: The radius of the circle.

Return Value

A new shape node.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/init(circleOfRadius:)

func NewShapeNodeWithCoder

func NewShapeNodeWithCoder(aDecoder foundation.INSCoder) SKShapeNode

Called when a node is initialized from an .sks file.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(coder:)

func NewShapeNodeWithEllipseInRect

func NewShapeNodeWithEllipseInRect(rect corefoundation.CGRect) SKShapeNode

Creates a shape node with an elliptical path that fills the specified rectangle.

rect: A rectangle, relative to the node’s origin.

Return Value

A new shape node.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/init(ellipseIn:)

func NewShapeNodeWithEllipseOfSize

func NewShapeNodeWithEllipseOfSize(size corefoundation.CGSize) SKShapeNode

Creates a shape node with an elliptical path centered on the node’s origin.

size: The height and width of the ellipse.

Return Value

A new shape node.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/init(ellipseOf:)

func NewShapeNodeWithFileNamed

func NewShapeNodeWithFileNamed(filename string) SKShapeNode

Creates a new node by loading an archive file from the game’s main bundle.

filename: The name of the file, without a file extension. The file must be in the app’s main bundle and have a `XCUIElementTypeSks` filename extension.

Return Value

The unarchived node object.

Discussion

If you call this method on a subclass of the SKScene class and the object in the archive is an SKScene object, the returned object is initialized as if it is a member of the subclass. You use this behavior to create scene layouts in the Xcode Editor and provide custom behaviors in your subclass.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(fileNamed:)

func NewShapeNodeWithPath

func NewShapeNodeWithPath(path coregraphics.CGPathRef) SKShapeNode

Creates a shape node from a Core Graphics path.

path: The Core Graphics path to use. The path is relative to the node’s origin.

Return Value

A new shape node.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/init(path:)

func NewShapeNodeWithPathCentered

func NewShapeNodeWithPathCentered(path coregraphics.CGPathRef, centered bool) SKShapeNode

Creates a shape node from a Core Graphics path, centered around its position.

path: The Core Graphics path to use.

centered: If true, the path is translated so that the center of the path’s bounding box is at the node’s origin; otherwise the path is relative to the node’s origin.

Return Value

A new shape node.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/init(path:centered:)

func NewShapeNodeWithPointsCount

func NewShapeNodeWithPointsCount(points []corefoundation.CGPoint, numPoints uintptr) SKShapeNode

Creates a shape node from a series of points.

points: An array of Core Graphics points. The points are relative to the node’s origin.

numPoints: The number of points in the array.

Return Value

A new shape node. The node is created with a path that starts at the first point in the array, joining each adjacent pair of points with a line segment.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/init(points:count:)

func NewShapeNodeWithRect

func NewShapeNodeWithRect(rect corefoundation.CGRect) SKShapeNode

Creates a shape node with a rectangular path.

rect: A rectangle, relative to the node’s origin.

Return Value

A new shape node.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/init(rect:)

func NewShapeNodeWithRectCornerRadius

func NewShapeNodeWithRectCornerRadius(rect corefoundation.CGRect, cornerRadius float64) SKShapeNode

Creates a shape with a rectangular path that has rounded corners.

rect: A rectangle, relative to the node’s origin.

cornerRadius: The radius of the rounded corners. The radius should not be a negative number. The value should be no larger than half of the rectangle’s width or height, whichever is smaller.

Return Value

A new shape node.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/init(rect:cornerRadius:)

func NewShapeNodeWithRectOfSize

func NewShapeNodeWithRectOfSize(size corefoundation.CGSize) SKShapeNode

Creates a shape node with a rectangular path centered on the node’s origin.

size: The size of the rectangle.

Return Value

A new shape node.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/init(rectOf:)

func NewShapeNodeWithRectOfSizeCornerRadius

func NewShapeNodeWithRectOfSizeCornerRadius(size corefoundation.CGSize, cornerRadius float64) SKShapeNode

Creates a shape with a rectangular path that has rounded corners centered on the node’s position.

size: The size of the rectangle.

cornerRadius: The radius of the rounded corners. The radius should not be a negative number. The value should be no larger than half of the rectangle’s width or height, whichever is smaller.

Return Value

A new shape node.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/init(rectOf:cornerRadius:)

func NewShapeNodeWithSplinePointsCount

func NewShapeNodeWithSplinePointsCount(points []corefoundation.CGPoint, numPoints uintptr) SKShapeNode

Creates a shape node from a series of spline points.

points: An array of Core Graphics points.

numPoints: The number of points in the array.

Return Value

A new shape node is created. The node is created with a path that starts at the first point in the array, joining each pair of points with a quadratic curve. The control points are calculated automatically based on previous points in the array.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/init(splinePoints:count:)

func SKShapeNodeFromID

func SKShapeNodeFromID(id objc.ID) SKShapeNode

SKShapeNodeFromID constructs a SKShapeNode from an objc.ID.

A mathematical shape that can be stroked or filled.

func (SKShapeNode) AttributeValues

func (s SKShapeNode) AttributeValues() foundation.INSDictionary

The values of each attribute associated with the node’s attached shader.

Discussion

All nodes have their own copy of an attribute value and therefore the attribute values can be different across the same SKShader. If instead you need all nodes to share the same value, use SKUniform. Uniforms can change values every frame, but uniforms cannot vary per-node like attributes can.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/attributeValues

func (SKShapeNode) Autorelease

func (s SKShapeNode) Autorelease() SKShapeNode

Autorelease adds the receiver to the current autorelease pool.

func (SKShapeNode) BlendMode

func (s SKShapeNode) BlendMode() SKBlendMode

The blend mode used to blend the shape into the parent’s framebuffer.

Discussion

The default value is SKBlendMode.alpha.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/blendMode

func (SKShapeNode) FillColor

func (s SKShapeNode) FillColor() appkit.NSColor

The color used to fill the shape.

Discussion

The default fill color is `[SKColor clearColor]`, which means the shape is not filled.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/fillColor

func (SKShapeNode) FillShader

func (s SKShapeNode) FillShader() ISKShader

A custom shader used to determine the color of the filled portion of the shape node.

Discussion

The default value is `nil`. If a `fillShader` is specified, when the shape node is drawn, the shader is used to determine the output colors for any part of the shape node that’s fillled. SpriteKit implements many fill features using a default shader, such as:

- Fill color. - Animations on SKNode.Alpha. - Light cast by SKLightNode.

If you supply a custom value for `fillShader`, your custom shader overrides the default shader which neutralizes the default features. It is the responsibility of your custom fillShader to implement any of the features your shape requires.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/fillShader

func (SKShapeNode) FillTexture

func (s SKShapeNode) FillTexture() ISKTexture

The texture used to fill the shape.

Discussion

The default value is `nil`. If a fill texture is specified, the shape node is rendered using that texture blended with the SKShapeNode.FillColor.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/fillTexture

func (SKShapeNode) GlowWidth

func (s SKShapeNode) GlowWidth() float64

A glow that extends outward from the stroked line.

Discussion

The default value is `0.0`, which means no glow is added. The glow color is determined by SKShapeNode.StrokeColor.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/glowWidth

func (SKShapeNode) Init

func (s SKShapeNode) Init() SKShapeNode

Init initializes the instance.

func (SKShapeNode) IsAntialiased

func (s SKShapeNode) IsAntialiased() bool

A Boolean value that determines whether the stroked path is smoothed when drawn.

Discussion

The default value is true.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/isAntialiased

func (SKShapeNode) LineCap

func (s SKShapeNode) LineCap() int32

The style used to render the endpoints of the stroked portion of the shape node.

Discussion

The default value is CGLineCap.butt. See CGLineCap.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/lineCap

func (SKShapeNode) LineJoin

func (s SKShapeNode) LineJoin() int32

The junction type used when the stroked portion of the shape node is rendered.

Discussion

The default value is CGLineJoin.bevel. See CGLineJoin.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/lineJoin

func (SKShapeNode) LineLength

func (s SKShapeNode) LineLength() float64

The length of the line defined by the shape node.

Discussion

This property takes effect only when the shape has a stroke. The valid range is between `[0.1]` where one indicates that the shape is fully stroked, and zero indicates that the shape is not stroked at all. By interpolating this value over time (for example, in your scene’s SKScene.Update callback), you can animate the shape as if it were drawn in real time.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/lineLength

func (SKShapeNode) LineWidth

func (s SKShapeNode) LineWidth() float64

The width used to stroke the path.

Discussion

A line width larger than `2.0` may cause rendering artifacts in the final rendered image. The default value is `1.0`.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/lineWidth

func (SKShapeNode) MiterLimit

func (s SKShapeNode) MiterLimit() float64

The miter limit to use when the line is stroked using a miter join style.

Discussion

If the line join style is set to CGLineJoin.miter, SpriteKit uses the miter limit to determine whether the lines should be joined with a bevel instead of a miter. SpriteKit divides the length of the miter by the line width. If the result is greater than the miter limit, SpriteKit converts the style to a bevel.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/miterLimit

func (SKShapeNode) Path

The path that defines the shape.

Discussion

The path is defined in the node’s coordinate space.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/path

func (SKShapeNode) SetAntialiased

func (s SKShapeNode) SetAntialiased(value bool)

func (SKShapeNode) SetAttributeValues

func (s SKShapeNode) SetAttributeValues(value foundation.INSDictionary)

func (SKShapeNode) SetBlendMode

func (s SKShapeNode) SetBlendMode(value SKBlendMode)

func (SKShapeNode) SetFillColor

func (s SKShapeNode) SetFillColor(value appkit.NSColor)

func (SKShapeNode) SetFillShader

func (s SKShapeNode) SetFillShader(value ISKShader)

func (SKShapeNode) SetFillTexture

func (s SKShapeNode) SetFillTexture(value ISKTexture)

func (SKShapeNode) SetGlowWidth

func (s SKShapeNode) SetGlowWidth(value float64)

func (SKShapeNode) SetLineCap

func (s SKShapeNode) SetLineCap(value int32)

func (SKShapeNode) SetLineJoin

func (s SKShapeNode) SetLineJoin(value int32)

func (SKShapeNode) SetLineWidth

func (s SKShapeNode) SetLineWidth(value float64)

func (SKShapeNode) SetMiterLimit

func (s SKShapeNode) SetMiterLimit(value float64)

func (SKShapeNode) SetPath

func (s SKShapeNode) SetPath(value coregraphics.CGPathRef)

func (SKShapeNode) SetStrokeColor

func (s SKShapeNode) SetStrokeColor(value appkit.NSColor)

func (SKShapeNode) SetStrokeShader

func (s SKShapeNode) SetStrokeShader(value ISKShader)

func (SKShapeNode) SetStrokeTexture

func (s SKShapeNode) SetStrokeTexture(value ISKTexture)

func (SKShapeNode) SetValueForAttributeNamed

func (s SKShapeNode) SetValueForAttributeNamed(value ISKAttributeValue, key string)

Sets an attribute value for an attached shader.

value: An attribute value object containing the scalar or vector value to set in the attached shader.

key: The attribute name.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/setValue(_:forAttribute:)

func (SKShapeNode) StrokeColor

func (s SKShapeNode) StrokeColor() appkit.NSColor

The color used to stroke the shape.

Discussion

The default stroke color is `[SKColor whiteColor]`. If you do not want to stroke the shape, use `[SKColor clearColor].`

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/strokeColor

func (SKShapeNode) StrokeShader

func (s SKShapeNode) StrokeShader() ISKShader

A custom shader used to determine the color of the stroked portion of the shape node.

Discussion

The default value is `nil`. If a `strokeShader` is specified, when the shape node is drawn, the shader is used to determine the output colors for any part of the shape node that’s stroked. SpriteKit implements many stroke features using a default shader, such as:

- lineCap - SKShapeNode.GlowWidth - SKShapeNode.StrokeColor

If you supply a custom value for `strokeShader`, your custom shader overrides the default shader which neutralizes the default features. It is the responsibility of your custom `strokeShader` to implement any of the features your shape requires.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/strokeShader

func (SKShapeNode) StrokeTexture

func (s SKShapeNode) StrokeTexture() ISKTexture

The texture used to stroke the shape.

Discussion

The default value is `nil`. If a stroke texture is specified, the SKShapeNode.StrokeColor property is ignored and the stroked portion of the shape node is rendered using the texture instead.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/strokeTexture

func (SKShapeNode) ValueForAttributeNamed

func (s SKShapeNode) ValueForAttributeNamed(key string) ISKAttributeValue

The value of a shader attribute.

key: The attribute name.

Return Value

An attribute value object containing the scalar or vector value or `nil` if no such attribute exists.

See: https://developer.apple.com/documentation/SpriteKit/SKShapeNode/value(forAttributeNamed:)

type SKShapeNodeClass

type SKShapeNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKShapeNodeClass

func GetSKShapeNodeClass() SKShapeNodeClass

GetSKShapeNodeClass returns the class object for SKShapeNode.

func (SKShapeNodeClass) Alloc

func (sc SKShapeNodeClass) Alloc() SKShapeNode

Alloc allocates memory for a new instance of the class.

func (SKShapeNodeClass) Class

func (sc SKShapeNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKSpriteNode

type SKSpriteNode struct {
	SKNode
}

An image or solid color.

Overview

SKSpriteNode is an onscreen graphical element that can be initialized from an image or a solid color. SpriteKit adds functionality to its ability to display images using the functions discussed below.

Creating a Sprite from an Image Filename

Creating a Sprite from a Texture

Creating a Solid-Color Sprite

Setting a Sprite’s Size and Position

Scaling a Sprite in Nine Parts

Tinting a Sprite

Configuring Alpha Blendling

Lighting a Sprite

Adding a Custom Shader to a Sprite

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode

func NewSKSpriteNode

func NewSKSpriteNode() SKSpriteNode

NewSKSpriteNode creates a new SKSpriteNode instance.

func NewSpriteNodeWithCoder

func NewSpriteNodeWithCoder(aDecoder foundation.INSCoder) SKSpriteNode

Tells you when to initialize a sprite from an archive.

Discussion

Don’t call this function directly; the system calls this function when you should initialize your sprite from the argument archived data.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/init(coder:)

func NewSpriteNodeWithColorSize

func NewSpriteNodeWithColorSize(color appkit.NSColor, size corefoundation.CGSize) SKSpriteNode

Initializes a single-color sprite node.

color: The color for the resulting sprite node.

size: The size of the sprite node in points.

Return Value

A newly initialized sprite node.

Discussion

Although textured nodes are the most common way to use the SKSpriteNode class, you can also create sprite nodes without a texture. The behavior of the class changes when the node lacks a texture:

- The sprite node that is returned from this method has its SKSpriteNode.Texture property set to `nil`. - There is no texture to stretch, so the SKSpriteNode.CenterRect parameter is ignored. - There is no colorization step; the SKSpriteNode.Color property is used as the sprite’s color. - The sprite node’s SKNode.Alpha component is used to determine how it is blended into the buffer.

Listing 1 shows how to create a red sprite node `100 x 100` points in size.

Listing 1. Creating a non-textured sprite node

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/init(color:size:)

func NewSpriteNodeWithFileNamed

func NewSpriteNodeWithFileNamed(filename string) SKSpriteNode

Creates a new node by loading an archive file from the game’s main bundle.

filename: The name of the file, without a file extension. The file must be in the app’s main bundle and have a `XCUIElementTypeSks` filename extension.

Return Value

The unarchived node object.

Discussion

If you call this method on a subclass of the SKScene class and the object in the archive is an SKScene object, the returned object is initialized as if it is a member of the subclass. You use this behavior to create scene layouts in the Xcode Editor and provide custom behaviors in your subclass.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(fileNamed:)

func NewSpriteNodeWithImageNamed

func NewSpriteNodeWithImageNamed(name string) SKSpriteNode

Initializes a textured sprite using an image file.

name: The name of an image file stored in the app bundle.

Return Value

A newly initialized sprite object.

Discussion

This method creates a new texture object from the image file and assigns that texture to the SKSpriteNode.Texture property, the SKSpriteNode.NormalTexture properties is set to `nil`. The SKSpriteNode.Size property of the sprite is set to the dimensions of the image. The SKSpriteNode.Color property is set to white with an alpha of zero `(1.0,1.0,1.0,0.0)`.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/init(imageNamed:)

func NewSpriteNodeWithImageNamedNormalMapped

func NewSpriteNodeWithImageNamedNormalMapped(name string, generateNormalMap bool) SKSpriteNode

Initializes a textured sprite using an image file, optionally adding a normal map to simulate 3D lighting.

name: The name of an image file stored in the app bundle.

generateNormalMap: If true, a normal map is generated from the image texture without applying any filter to it (SKTextureNormalMapFilteringTypeNone). If false, no normal map is generated (matching the behavior of the spriteNodeWithImageNamed: class method).

Return Value

A newly initialized sprite object.

Discussion

The normal map is used only when lighting is enabled in the scene. For more information, see SKSpriteNode and SKLightNode.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/init(imageNamed:normalMapped:)

func NewSpriteNodeWithTexture

func NewSpriteNodeWithTexture(texture ISKTexture) SKSpriteNode

Initializes a textured sprite using an existing texture object.

texture: A SpriteKit texture.

Return Value

A newly initialized sprite object.

Discussion

The SKSpriteNode.Size property of the sprite is set to the dimensions of the texture. The SKSpriteNode.Color property is set to white with an alpha of zero `(1.0,1.0,1.0,0.0)`.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/init(texture:)

func NewSpriteNodeWithTextureColorSize

func NewSpriteNodeWithTextureColorSize(texture ISKTexture, color appkit.NSColor, size corefoundation.CGSize) SKSpriteNode

Initializes a textured sprite in color using an existing texture object.

texture: A texture to apply to the sprite.

color: The color for the new sprite.

size: The size for the new sprite.

Return Value

A newly initialized sprite object.

Discussion

To colorize your texture, you also need to set the SKSpriteNode.ColorBlendFactor property of the sprite.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/init(texture:color:size:)

func NewSpriteNodeWithTextureNormalMap

func NewSpriteNodeWithTextureNormalMap(texture ISKTexture, normalMap ISKTexture) SKSpriteNode

Initializes a textured sprite with a normal map to simulate 3D lighting.

texture: A SpriteKit texture used to draw the sprite.

normalMap: A SpriteKit texture used to add lighting behavior to the sprite.

Return Value

A newly initialized sprite object.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/init(texture:normalMap:)

func NewSpriteNodeWithTextureSize

func NewSpriteNodeWithTextureSize(texture ISKTexture, size corefoundation.CGSize) SKSpriteNode

Initializes a textured sprite using an existing texture object but with a specified size.

texture: A SpriteKit texture.

size: The size of the sprite in points.

Return Value

A newly initialized sprite object.

Discussion

The sprite is initialized using the texture, but the texture’s dimensions are not used. Instead, the size passed into the constructor method is used.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/init(texture:size:)

func SKSpriteNodeFromID

func SKSpriteNodeFromID(id objc.ID) SKSpriteNode

SKSpriteNodeFromID constructs a SKSpriteNode from an objc.ID.

An image or solid color.

func (SKSpriteNode) AnchorPoint

func (s SKSpriteNode) AnchorPoint() corefoundation.CGPoint

Defines the point in the sprite that corresponds to the node’s position.

Discussion

You specify the value for this property in the unit coordinate space. The default value is `(0.5,0.5)`, which means that the sprite is centered on its position.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/anchorPoint

func (SKSpriteNode) AttributeValues

func (s SKSpriteNode) AttributeValues() foundation.INSDictionary

The values of each attribute associated with the node’s attached shader.

Discussion

All nodes have their own copy of an attribute value and therefore the attribute values can be different per-node across the same SKShader. If instead you need all nodes to share the same value, use SKUniform. Uniforms can change values every frame, but uniforms cannot vary per-node like attributes can.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/attributeValues

func (SKSpriteNode) Autorelease

func (s SKSpriteNode) Autorelease() SKSpriteNode

Autorelease adds the receiver to the current autorelease pool.

func (SKSpriteNode) BlendMode

func (s SKSpriteNode) BlendMode() SKBlendMode

The blend mode used to draw the sprite into the parent’s framebuffer.

Discussion

The default value is SKBlendMode.alpha.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/blendMode

func (SKSpriteNode) CenterRect

func (s SKSpriteNode) CenterRect() corefoundation.CGRect

Enable nine-part stretching of the sprite’s texture.

Discussion

Controls how the texture is stretched to fill the SKSpriteNode.

The argument rectangle is in the unit coordinate space with a default value of `(0,0)-(1.0,1.0)`, which indicates that the entire texture is stretched to fill the sprite.

If instead you define a different rectangle, its coordinates are used to break the texture into a 3 x 3 grid that is scaled like the following:

- The four corners of this grid are applied without performing any scaling. - The upper and lower-middle parts are scaled horizontally - The left and right-middle parts are scaled vertically - The center is scaled in all directions.

This is what’s referred to as a 9-part scaling algorithm.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/centerRect

func (SKSpriteNode) Color

func (s SKSpriteNode) Color() appkit.NSColor

The sprite’s color.

Discussion

If the SKSpriteNode.Texture property is non-`nil`, the red, green, and blue values of the color property are blended with the texture before the texture is drawn and the alpha property is ignored. If the SKSpriteNode.Texture property is `nil`, the color (including the alpha component) is used to draw a single-color rectangle.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/color

func (SKSpriteNode) ColorBlendFactor

func (s SKSpriteNode) ColorBlendFactor() float64

A floating-point value that describes how the color is blended with the sprite’s texture.

Discussion

The value must be a number between `0.0` and `1.0`, inclusive. The default value (`0.0`) indicates the color property is ignored and that the texture’s values should be used unmodified. For values greater than `0.0`, the texture is blended with the color before being drawn to the scene.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/colorBlendFactor

func (SKSpriteNode) Init

func (s SKSpriteNode) Init() SKSpriteNode

Init initializes the instance.

func (SKSpriteNode) InitWithColorSize

func (s SKSpriteNode) InitWithColorSize(color appkit.NSColor, size corefoundation.CGSize) SKSpriteNode

Initializes a single-color sprite node.

color: The color for the resulting sprite node.

size: The size of the sprite node in points.

Return Value

A newly initialized sprite node.

Discussion

Although textured nodes are the most common way to use the SKSpriteNode class, you can also create sprite nodes without a texture. The behavior of the class changes when the node lacks a texture:

- The sprite node that is returned from this method has its SKSpriteNode.Texture property set to `nil`. - There is no texture to stretch, so the SKSpriteNode.CenterRect parameter is ignored. - There is no colorization step; the SKSpriteNode.Color property is used as the sprite’s color. - The sprite node’s SKNode.Alpha component is used to determine how it is blended into the buffer.

Listing 1 shows how to create a red sprite node `100 x 100` points in size.

Listing 1. Creating a non-textured sprite node

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/init(color:size:)

func (SKSpriteNode) InitWithImageNamed

func (s SKSpriteNode) InitWithImageNamed(name string) SKSpriteNode

Initializes a textured sprite using an image file.

name: The name of an image file stored in the app bundle.

Return Value

A newly initialized sprite object.

Discussion

This method creates a new texture object from the image file and assigns that texture to the SKSpriteNode.Texture property, the SKSpriteNode.NormalTexture properties is set to `nil`. The SKSpriteNode.Size property of the sprite is set to the dimensions of the image. The SKSpriteNode.Color property is set to white with an alpha of zero `(1.0,1.0,1.0,0.0)`.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/init(imageNamed:)

func (SKSpriteNode) InitWithTexture

func (s SKSpriteNode) InitWithTexture(texture ISKTexture) SKSpriteNode

Initializes a textured sprite using an existing texture object.

texture: A SpriteKit texture.

Return Value

A newly initialized sprite object.

Discussion

The SKSpriteNode.Size property of the sprite is set to the dimensions of the texture. The SKSpriteNode.Color property is set to white with an alpha of zero `(1.0,1.0,1.0,0.0)`.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/init(texture:)

func (SKSpriteNode) InitWithTextureColorSize

func (s SKSpriteNode) InitWithTextureColorSize(texture ISKTexture, color appkit.NSColor, size corefoundation.CGSize) SKSpriteNode

Initializes a textured sprite in color using an existing texture object.

texture: A texture to apply to the sprite.

color: The color for the new sprite.

size: The size for the new sprite.

Return Value

A newly initialized sprite object.

Discussion

To colorize your texture, you also need to set the SKSpriteNode.ColorBlendFactor property of the sprite.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/init(texture:color:size:)

func (SKSpriteNode) LightingBitMask

func (s SKSpriteNode) LightingBitMask() uint32

A mask that defines how this sprite is lit by light nodes in the scene.

Discussion

To determine whether this sprite is lit by a light node, the sprite’s SKSpriteNode.LightingBitMask property is tested against the light’s categoryBitMask property by performing a logical AND operation. If the comparison results in a nonzero value, the sprite is lit by this light.

The default value is 0x00000000 (all bits cleared).

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/lightingBitMask

func (SKSpriteNode) NormalTexture

func (s SKSpriteNode) NormalTexture() ISKTexture

A texture that specifies the normal map for the sprite.

Discussion

A normal map texture is used when a sprite is lit, giving it a more realistic look with shadows and specular highlights. The texture must be a normal map texture.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/normalTexture

func (SKSpriteNode) ScaleToSize

func (s SKSpriteNode) ScaleToSize(size corefoundation.CGSize)

Scales the sprite node to a specified size.

Discussion

This method works by setting the sprite node’s SKNode.XScale and SKNode.YScale to achieve the specified size in its parent’s coordinate space.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/scale(to:)

func (SKSpriteNode) SetAnchorPoint

func (s SKSpriteNode) SetAnchorPoint(value corefoundation.CGPoint)

func (SKSpriteNode) SetAttributeValues

func (s SKSpriteNode) SetAttributeValues(value foundation.INSDictionary)

func (SKSpriteNode) SetBlendMode

func (s SKSpriteNode) SetBlendMode(value SKBlendMode)

func (SKSpriteNode) SetCenterRect

func (s SKSpriteNode) SetCenterRect(value corefoundation.CGRect)

func (SKSpriteNode) SetColor

func (s SKSpriteNode) SetColor(value appkit.NSColor)

func (SKSpriteNode) SetColorBlendFactor

func (s SKSpriteNode) SetColorBlendFactor(value float64)

func (SKSpriteNode) SetLightingBitMask

func (s SKSpriteNode) SetLightingBitMask(value uint32)

func (SKSpriteNode) SetNormalTexture

func (s SKSpriteNode) SetNormalTexture(value ISKTexture)

func (SKSpriteNode) SetShader

func (s SKSpriteNode) SetShader(value ISKShader)

func (SKSpriteNode) SetShadowCastBitMask

func (s SKSpriteNode) SetShadowCastBitMask(value uint32)

func (SKSpriteNode) SetShadowedBitMask

func (s SKSpriteNode) SetShadowedBitMask(value uint32)

func (SKSpriteNode) SetSize

func (s SKSpriteNode) SetSize(value corefoundation.CGSize)

func (SKSpriteNode) SetSubdivisionLevels

func (o SKSpriteNode) SetSubdivisionLevels(value int)

The maximum number of subdivision iterations used to generate the final vertices.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpable/subdivisionLevels

func (SKSpriteNode) SetTexture

func (s SKSpriteNode) SetTexture(value ISKTexture)

func (SKSpriteNode) SetValueForAttributeNamed

func (s SKSpriteNode) SetValueForAttributeNamed(value ISKAttributeValue, key string)

Sets an attribute value for an attached shader.

value: An attribute value object containing the scalar or vector value to set in the attached shader.

key: The attribute name.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/setValue(_:forAttribute:)

func (SKSpriteNode) SetWarpGeometry

func (o SKSpriteNode) SetWarpGeometry(value ISKWarpGeometry)

The warp geometry used to define the distortion.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpable/warpGeometry

func (SKSpriteNode) Shader

func (s SKSpriteNode) Shader() ISKShader

A text file that defines code that does custom per-pixel drawing or colorization.

Discussion

The default value is `nil`, which means the default behavior for sprite rendering is performed. SpriteKit implements many sprite features using a default shader, such as:

- Animations on SKNode.Alpha. - SKTexture SKTexture.FilteringMode. - Light from SKLightNode.

If you supply a custom value for `shader`, your custom shader overrides the default shader which neutralizes the default features. It is the responsibility of your custom shader to implement any of the features your sprites require.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/shader

func (SKSpriteNode) ShadowCastBitMask

func (s SKSpriteNode) ShadowCastBitMask() uint32

A mask that defines which lights are occluded by this sprite.

Discussion

To determine whether this sprite blocks the light (casting a shadow), the sprite’s SKSpriteNode.ShadowedBitMask property is tested against the light’s categoryBitMask property by performing a logical AND operation. If the comparison results in a nonzero value, the sprite casts a shadow past itself.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/shadowCastBitMask

func (SKSpriteNode) ShadowedBitMask

func (s SKSpriteNode) ShadowedBitMask() uint32

A mask that defines which lights add shadows to the sprite.

Discussion

To determine whether this sprite is affected by being a shadow generated by a light, its SKSpriteNode.ShadowCastBitMask property is tested against the light’s categoryBitMask property by performing a logical AND operation. If the comparison results in a nonzero value, the sprite is drawn using a shadowed effect.

The default value is 0x00000000 (all bits cleared).

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/shadowedBitMask

func (SKSpriteNode) Size

The dimensions of the sprite, in points.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/size

func (SKSpriteNode) SubdivisionLevels

func (s SKSpriteNode) SubdivisionLevels() int

The maximum number of subdivision iterations used to generate the final vertices.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpable/subdivisionLevels

func (SKSpriteNode) Texture

func (s SKSpriteNode) Texture() ISKTexture

The texture used to draw the sprite.

Discussion

If the value is `nil`, the sprite is drawn as a single-color rectangle using its SKSpriteNode.Color property. Otherwise, the texture is used to draw the sprite. The related properties affect how the texture is applied.

SpriteKit automatically generates a texture for sprites when they are initialized with SKSpriteNode.InitWithImageNamed.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/texture

func (SKSpriteNode) ValueForAttributeNamed

func (s SKSpriteNode) ValueForAttributeNamed(key string) ISKAttributeValue

Sets the value of a shader attribute.

key: The attribute name.

Return Value

An attribute value object containing the scalar or vector value or `nil` if no such attribute exists.

See: https://developer.apple.com/documentation/SpriteKit/SKSpriteNode/value(forAttributeNamed:)

func (SKSpriteNode) WarpGeometry

func (s SKSpriteNode) WarpGeometry() ISKWarpGeometry

The warp geometry used to define the distortion.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpable/warpGeometry

type SKSpriteNodeClass

type SKSpriteNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKSpriteNodeClass

func GetSKSpriteNodeClass() SKSpriteNodeClass

GetSKSpriteNodeClass returns the class object for SKSpriteNode.

func (SKSpriteNodeClass) Alloc

func (sc SKSpriteNodeClass) Alloc() SKSpriteNode

Alloc allocates memory for a new instance of the class.

func (SKSpriteNodeClass) Class

func (sc SKSpriteNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKTexture

type SKTexture struct {
	objectivec.Object
}

An image, decoded on the GPU, that can be used to render various SpriteKit objects.

Overview

An SKTexture object is an image that can be applied to SKSpriteNode and SKShapeNode objects, particles created by an SKEmitterNode object, or tiles used in an SKTileMapNode. A texture object manages the texture data and graphics resources that are needed to render the image. Most texture objects are created from source images stored in your app bundle—your game’s artwork. Once created, a texture object’s contents are immutable. Multiple sprites can share the same texture object, sharing a single resource.

Deallocating a Texture

After a texture is loaded into the graphics hardware memory, it stays in memory until the referencing SKTexture object is deleted. This means that between levels (or in a dynamic game), you may need to make sure a texture object is deleted. Delete a SKTexture object by removing any strong references to it, including:

- All texture references from SKSpriteNode and SKEffectNode objects in your game - Any strong references to the texture in your own code - An SKTextureAtlas object that was used to create the texture object

Reading a Texture’s Size and Optional Source Location

Configuring a Texture’s Behavior for Scaling

Getting a Texture’s Underlying Image

Preloading a Texture for Performance

See: https://developer.apple.com/documentation/SpriteKit/SKTexture

func NewSKTexture

func NewSKTexture() SKTexture

NewSKTexture creates a new SKTexture instance.

func SKTextureFromID

func SKTextureFromID(id objc.ID) SKTexture

SKTextureFromID constructs a SKTexture from an objc.ID.

An image, decoded on the GPU, that can be used to render various SpriteKit objects.

func (SKTexture) Autorelease

func (t SKTexture) Autorelease() SKTexture

Autorelease adds the receiver to the current autorelease pool.

func (SKTexture) CGImage

func (t SKTexture) CGImage() coregraphics.CGImageRef

Returns the texture’s image data as a Quartz 2D image.

Discussion

The SKTexture.CGImage property returns the contents of a texture as a Quartz Image.

As an example use, you can create an image from a portion of your scene and save it to disk by doing the following:

- Use the SKView.TextureFromNode method to render the scene’s contents to a texture. - Call SKTexture.CGImage on the result. - Use CGImageDestination to write the [CGImage] out to disk.

See: https://developer.apple.com/documentation/SpriteKit/SKTexture/cgImage()

func (SKTexture) EncodeWithCoder

func (t SKTexture) EncodeWithCoder(coder foundation.INSCoder)

func (SKTexture) FilteringMode

func (t SKTexture) FilteringMode() SKTextureFilteringMode

The filtering mode used when the size of a sprite drawn with the texture is not drawn at the texture’s native size.

Discussion

The possible values for this property are listed in SKTextureFilteringMode. The default value is SKTextureFilteringMode.linear where each pixel is drawn by using a linear filter of multiple texels in the texture. The other option is SKTextureFilteringMode.nearest where each pixel is drawn using the nearest point in the texture.

The figure below shows the effect of different filtering modes. The rabbit texture (original on left) has been scaled up five times. Node 1 has been scaled using SKTextureFilteringMode.nearest and node 2 has been scaled with SKTextureFilteringMode.linear.

[media-2668828]

See: https://developer.apple.com/documentation/SpriteKit/SKTexture/filteringMode

func (SKTexture) Init

func (t SKTexture) Init() SKTexture

Init initializes the instance.

func (SKTexture) Preload

func (t SKTexture) Preload(ctx context.Context) error

Preload is a synchronous wrapper around SKTexture.PreloadWithCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (SKTexture) PreloadWithCompletionHandler

func (t SKTexture) PreloadWithCompletionHandler(completionHandler VoidHandler)

Load texture data into memory, calling a completion handler after the task completes.

completionHandler: A block called after the texture data is loaded.

Discussion

SpriteKit creates a background task to load the texture data from the associated file, then returns control to your game. After the texture data is loaded, your completion handler is called. Typically, you use this method when you want to guarantee that a particular texture is in memory before accessing it.

If you need to preload multiple textures at once, use the SKTextureClass.PreloadTexturesWithCompletionHandler method instead.

See: https://developer.apple.com/documentation/SpriteKit/SKTexture/preload(completionHandler:)

func (SKTexture) SetFilteringMode

func (t SKTexture) SetFilteringMode(value SKTextureFilteringMode)

func (SKTexture) SetUsesMipmaps

func (t SKTexture) SetUsesMipmaps(value bool)

func (SKTexture) Size

func (t SKTexture) Size() corefoundation.CGSize

Gets the size of the texture.

Return Value

The dimensions of the texture, measured in points.

Discussion

If the texture was created using an image file and that image file hasn’t been loaded, calling this method forces the texture data to be loaded from the file.

See: https://developer.apple.com/documentation/SpriteKit/SKTexture/size()

func (SKTexture) TextureRect

func (t SKTexture) TextureRect() corefoundation.CGRect

Gets a rectangle that defines the portion of the texture used to render its image.

Return Value

A rectangle in the unit coordinate space.

Discussion

The default value is a rectangle that covers the entire texture `(0,0)` - `(1,1)`. You cannot set this value directly; to use only a portion of a texture, use the init(rect:in:) method to create a new texture.

See: https://developer.apple.com/documentation/SpriteKit/SKTexture/textureRect()

func (SKTexture) UsesMipmaps

func (t SKTexture) UsesMipmaps() bool

A Boolean value that indicates whether the texture attempts to generate mipmaps.

Discussion

The default value is false. If you set this to true, Sprite Kit creates mipmaps for the texture when it prepares the texture for rendering. Mipmaps take up additional memory (usually one-third more) but can improve rendering quality and performance when the texture is reduced in size (such as when you reduce the scale of a sprite rendered using the texture).

You can only request mipmaps if both of the texture’s dimensions are a power of two.

See: https://developer.apple.com/documentation/SpriteKit/SKTexture/usesMipmaps

type SKTextureAtlas

type SKTextureAtlas struct {
	objectivec.Object
}

A collection of textures optimized for storage and drawing performance.

Overview

An SKTextureAtlas is a collection of textures that were either created from an `XCUIElementTypeAtlas` folder in the app bundle, or created at runtime. Texture atlases improve memory usage and rendering performance by reducing draw calls. Whenever you have textures that are always used together, store them in an atlas for best results.

SpriteKit implicitly loads an atlas when one of the atlas’s textures is accessed. Use SKTextureAtlas.TextureNamed when you want to explicitly access a texture atlas’s contents.

The preferred place to create a texture atlas is within an asset catalog (see Creating a Sprite Atlas), but you can also put your source textures in an `XCUIElementTypeAtlas` folder in the app bundle.

Accessing Textures

Preloading Textures

Reading Source Image Filenames

See: https://developer.apple.com/documentation/SpriteKit/SKTextureAtlas

func NewSKTextureAtlas

func NewSKTextureAtlas() SKTextureAtlas

NewSKTextureAtlas creates a new SKTextureAtlas instance.

func NewTextureAtlasNamed

func NewTextureAtlasNamed(name string) SKTextureAtlas

Creates a texture atlas from data stored in the app bundle.

name: The name of the texture atlas, without the `XCUIElementTypeAtlas` extension.

Return Value

A new texture atlas object.

Discussion

If the texture atlas cannot be found, an exception is thrown.

See: https://developer.apple.com/documentation/SpriteKit/SKTextureAtlas/init(named:)

func NewTextureAtlasWithDictionary

func NewTextureAtlasWithDictionary(properties foundation.INSDictionary) SKTextureAtlas

Creates a texture atlas from a set of image files.

properties: A dictionary that defines which textures are to be merged into the atlas.

Return Value

A new texture atlas object.

Discussion

Normally, Xcode creates texture atlases at compile time from the image files included in your project. These atlases are compiled and installed inside the app bundle. However, sometimes the assets needed to create a texture atlas are not available at compile time. For example, those assets might be procedurally generated or downloaded from the network. However, you still want the benefit of texture atlases to reduce the number of state changes required in the hardware. You can use this method to generate an atlas object at runtime. This is a potentially expensive operation best performed when your game loop is not running.

The keys in the dictionary represent the names of the individual textures. The associated object for each key can be:

- An NSString object that contains a file system path to a file that contains the texture - An NSURL object that contains a file system path to a file that contains the texture - A UIImage object - An NSImage object

See: https://developer.apple.com/documentation/SpriteKit/SKTextureAtlas/init(dictionary:)

func SKTextureAtlasFromID

func SKTextureAtlasFromID(id objc.ID) SKTextureAtlas

SKTextureAtlasFromID constructs a SKTextureAtlas from an objc.ID.

A collection of textures optimized for storage and drawing performance.

func (SKTextureAtlas) Autorelease

func (t SKTextureAtlas) Autorelease() SKTextureAtlas

Autorelease adds the receiver to the current autorelease pool.

func (SKTextureAtlas) EncodeWithCoder

func (t SKTextureAtlas) EncodeWithCoder(coder foundation.INSCoder)

func (SKTextureAtlas) Init

func (t SKTextureAtlas) Init() SKTextureAtlas

Init initializes the instance.

func (SKTextureAtlas) Preload

func (t SKTextureAtlas) Preload(ctx context.Context) error

Preload is a synchronous wrapper around SKTextureAtlas.PreloadWithCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (SKTextureAtlas) PreloadWithCompletionHandler

func (t SKTextureAtlas) PreloadWithCompletionHandler(completionHandler VoidHandler)

Loads an atlas object’s textures into memory, calling a completion handler after the task completes.

completionHandler: A block called after the texture atlas is loaded.

Discussion

SpriteKit creates a background task that loads the texture data from the atlas object. Then, SpriteKit returns control to your game. After the texture atlas is loaded, your completion handler is called.

If you need to preload multiple texture atlas objects immediately, use the SKTextureAtlasClass.PreloadTextureAtlasesWithCompletionHandler method instead.

See: https://developer.apple.com/documentation/SpriteKit/SKTextureAtlas/preload(completionHandler:)

func (SKTextureAtlas) TextureNamed

func (t SKTextureAtlas) TextureNamed(name string) ISKTexture

Creates a texture from data stored in the texture atlas.

name: The name of a texture stored in the atlas object.

Return Value

The SpriteKit texture associated with the name. If the specified image does not exist in the atlas object, SpriteKit returns a placeholder texture image.

See: https://developer.apple.com/documentation/SpriteKit/SKTextureAtlas/textureNamed(_:)

func (SKTextureAtlas) TextureNames

func (t SKTextureAtlas) TextureNames() []string

The names of the texture images stored in the atlas.

Discussion

The property holds an array of NSString objects. Each string is the name of a texture stored in the atlas. The count of the array is the number of textures stored in the atlas.

If the atlas is not currently loaded into memory, this method forces it to be loaded from the app bundle. Your game blocks until the atlas is loaded.

See: https://developer.apple.com/documentation/SpriteKit/SKTextureAtlas/textureNames

type SKTextureAtlasArrayErrorHandler

type SKTextureAtlasArrayErrorHandler = func(*[]SKTextureAtlas, error)

SKTextureAtlasArrayErrorHandler handles A block called after all of the texture atlases are loaded. The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.

Used by:

  • [SKTextureAtlas.PreloadTextureAtlasesNamedWithCompletionHandler]

type SKTextureAtlasClass

type SKTextureAtlasClass struct {
	// contains filtered or unexported fields
}

func GetSKTextureAtlasClass

func GetSKTextureAtlasClass() SKTextureAtlasClass

GetSKTextureAtlasClass returns the class object for SKTextureAtlas.

func (SKTextureAtlasClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKTextureAtlasClass) Class

func (sc SKTextureAtlasClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (SKTextureAtlasClass) PreloadTextureAtlasesNamedWithCompletionHandler

func (_SKTextureAtlasClass SKTextureAtlasClass) PreloadTextureAtlasesNamedWithCompletionHandler(atlasNames []string, completionHandler SKTextureAtlasArrayErrorHandler)

Loads the textures of multiple atlases into memory, calling a completion handler after the task completes.

atlasNames: An array containing the atlas names to preload.

completionHandler: A block called after all of the texture atlases are loaded.

Discussion

SpriteKit creates a background task that loads the texture data from all of the specified atlas objects. Then, SpriteKit returns control to your game. After the atlases are loaded, your completion handler is called.

See: https://developer.apple.com/documentation/SpriteKit/SKTextureAtlas/preloadTextureAtlasesNamed(_:withCompletionHandler:)

func (SKTextureAtlasClass) PreloadTextureAtlasesWithCompletionHandler

func (_SKTextureAtlasClass SKTextureAtlasClass) PreloadTextureAtlasesWithCompletionHandler(textureAtlases []SKTextureAtlas, completionHandler VoidHandler)

Loads the textures of multiple atlas objects into memory, calling a completion handler after the task completes.

textureAtlases: An array of SKTextureAtlas objects.

completionHandler: A block called after all of the texture atlases are loaded.

Discussion

SpriteKit creates a background task that loads the texture data from all of the specified atlas objects. Then, SpriteKit returns control to your game. After the atlas objects are loaded, your completion handler is called.

See: https://developer.apple.com/documentation/SpriteKit/SKTextureAtlas/preloadTextureAtlases(_:withCompletionHandler:)

type SKTextureClass

type SKTextureClass struct {
	// contains filtered or unexported fields
}

func GetSKTextureClass

func GetSKTextureClass() SKTextureClass

GetSKTextureClass returns the class object for SKTexture.

func (SKTextureClass) Alloc

func (sc SKTextureClass) Alloc() SKTexture

Alloc allocates memory for a new instance of the class.

func (SKTextureClass) Class

func (sc SKTextureClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (SKTextureClass) PreloadTexturesWithCompletionHandler

func (_SKTextureClass SKTextureClass) PreloadTexturesWithCompletionHandler(textures []SKTexture, completionHandler VoidHandler)

Load the data of multiple textures into memory.

textures: An array of SKTexture objects.

completionHandler: A block called after all of the textures are loaded.

Discussion

SpriteKit creates a background task that loads the texture data for all of the textures in the array, then returns control to your game. Your completion handler is called after all of the textures are loaded.

See: https://developer.apple.com/documentation/SpriteKit/SKTexture/preload(_:withCompletionHandler:)

type SKTextureFilteringMode

type SKTextureFilteringMode int

See: https://developer.apple.com/documentation/SpriteKit/SKTextureFilteringMode

const (
	// SKTextureFilteringLinear: Each pixel is drawn by using a linear filter of multiple texels in the texture.
	SKTextureFilteringLinear SKTextureFilteringMode = 1
	// SKTextureFilteringNearest: Each pixel is drawn using the nearest point in the texture.
	SKTextureFilteringNearest SKTextureFilteringMode = 0
)

func (SKTextureFilteringMode) String

func (e SKTextureFilteringMode) String() string

type SKTileAdjacencyMask

type SKTileAdjacencyMask uint

See: https://developer.apple.com/documentation/SpriteKit/SKTileAdjacencyMask

const (
	SKTileAdjacencyAll                 SKTileAdjacencyMask = 255
	SKTileAdjacencyDown                SKTileAdjacencyMask = 16
	SKTileAdjacencyDownEdge            SKTileAdjacencyMask = 199
	SKTileAdjacencyLeft                SKTileAdjacencyMask = 64
	SKTileAdjacencyLeftEdge            SKTileAdjacencyMask = 31
	SKTileAdjacencyLowerLeft           SKTileAdjacencyMask = 32
	SKTileAdjacencyLowerLeftCorner     SKTileAdjacencyMask = 253
	SKTileAdjacencyLowerLeftEdge       SKTileAdjacencyMask = 7
	SKTileAdjacencyLowerRight          SKTileAdjacencyMask = 8
	SKTileAdjacencyLowerRightCorner    SKTileAdjacencyMask = 127
	SKTileAdjacencyLowerRightEdge      SKTileAdjacencyMask = 193
	SKTileAdjacencyRight               SKTileAdjacencyMask = 4
	SKTileAdjacencyRightEdge           SKTileAdjacencyMask = 241
	SKTileAdjacencyUp                  SKTileAdjacencyMask = 1
	SKTileAdjacencyUpEdge              SKTileAdjacencyMask = 124
	SKTileAdjacencyUpperLeft           SKTileAdjacencyMask = 128
	SKTileAdjacencyUpperLeftCorner     SKTileAdjacencyMask = 247
	SKTileAdjacencyUpperLeftEdge       SKTileAdjacencyMask = 28
	SKTileAdjacencyUpperRight          SKTileAdjacencyMask = 2
	SKTileAdjacencyUpperRightCorner    SKTileAdjacencyMask = 223
	SKTileAdjacencyUpperRightEdge      SKTileAdjacencyMask = 112
	SKTileHexFlatAdjacencyAll          SKTileAdjacencyMask = 63
	SKTileHexFlatAdjacencyDown         SKTileAdjacencyMask = 8
	SKTileHexFlatAdjacencyLowerLeft    SKTileAdjacencyMask = 16
	SKTileHexFlatAdjacencyLowerRight   SKTileAdjacencyMask = 4
	SKTileHexFlatAdjacencyUp           SKTileAdjacencyMask = 1
	SKTileHexFlatAdjacencyUpperLeft    SKTileAdjacencyMask = 32
	SKTileHexFlatAdjacencyUpperRight   SKTileAdjacencyMask = 2
	SKTileHexPointyAdjacencyAdd        SKTileAdjacencyMask = 63
	SKTileHexPointyAdjacencyLeft       SKTileAdjacencyMask = 32
	SKTileHexPointyAdjacencyLowerLeft  SKTileAdjacencyMask = 16
	SKTileHexPointyAdjacencyLowerRight SKTileAdjacencyMask = 8
	SKTileHexPointyAdjacencyRight      SKTileAdjacencyMask = 4
	SKTileHexPointyAdjacencyUpperLeft  SKTileAdjacencyMask = 1
	SKTileHexPointyAdjacencyUpperRight SKTileAdjacencyMask = 2
)

func (SKTileAdjacencyMask) String

func (e SKTileAdjacencyMask) String() string

type SKTileDefinition

type SKTileDefinition struct {
	objectivec.Object
}

A single tile that can be repeated in a tile map.

Overview

To define the visual representation of a single tile, you create an SKTileDefinition object with texture and size information. Tile definitions support separate normal textures, for simulating 3D lighting, and arrays of textures for animation with speed controlled by the SKTileDefinition.TimePerFrame property. Textures can be rotated in 90˚ increments or flipped either vertically or horizontally.

Once a tile definition has been created, you encapsulate it in a SKTileGroup which is added to a SKTileSet which, in turn, is displayed in the scene with a SKTileMapNode.

Creating a Tile with a Texture

Creating a Tile with a Normal Texture

Creating a Tile with a Size

Creating an Animated Tile

Flipping a Tile Vertically or Horizontally

Rotating a Tile

Configure Animated Tile Properties

Reading or Adding a Tile’s Custom Data

Reading or Adjusting a Tile’s Instance Properties

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition

func NewSKTileDefinition

func NewSKTileDefinition() SKTileDefinition

NewSKTileDefinition creates a new SKTileDefinition instance.

func NewTileDefinitionWithTexture

func NewTileDefinitionWithTexture(texture ISKTexture) SKTileDefinition

Initializes a new tile definition with a single texture.

texture: The texture to reference for the definition’s size and content.

Return Value

A new tile definition.

Discussion

The size of the newly created tile definition will be the same as the texture used to initialize it.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/init(texture:)

func NewTileDefinitionWithTextureNormalTextureSize

func NewTileDefinitionWithTextureNormalTextureSize(texture ISKTexture, normalTexture ISKTexture, size corefoundation.CGSize) SKTileDefinition

Initializes a new tile definition with a single texture and separate normal texture for simulating 3D lighting.

texture: The texture to reference for the definition’s content.

normalTexture: The texture to reference for generating normals to simulate 3D lighting.

size: The size of the tile in points.

Return Value

A new tile definition.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/init(texture:normalTexture:size:)

func NewTileDefinitionWithTextureSize

func NewTileDefinitionWithTextureSize(texture ISKTexture, size corefoundation.CGSize) SKTileDefinition

Initializes a new tile definition of a specified size with a single texture.

texture: The texture to reference for the definition’s content.

size: The size of the tile in points.

Return Value

A new tile definition.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/init(texture:size:)

func NewTileDefinitionWithTexturesNormalTexturesSizeTimePerFrame

func NewTileDefinitionWithTexturesNormalTexturesSizeTimePerFrame(textures []SKTexture, normalTextures []SKTexture, size corefoundation.CGSize, timePerFrame float64) SKTileDefinition

Initializes a new tile definition with arrays of textures and normal textures for animation.

textures: An array of textures to reference for the definition’s content.

normalTextures: An array of textures to reference for generating normals to simulate 3D lighting.

size: The size of the tile in points.

timePerFrame: The duration, in seconds, that each texture is displayed.

Return Value

A new tile definition.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/init(textures:normalTextures:size:timePerFrame:)

func NewTileDefinitionWithTexturesSizeTimePerFrame

func NewTileDefinitionWithTexturesSizeTimePerFrame(textures []SKTexture, size corefoundation.CGSize, timePerFrame float64) SKTileDefinition

Initializes a new tile definition with an array of textures for animation.

textures: An array of textures to reference for the definition’s size and content.

size: The size of the tile in points.

timePerFrame: The duration, in seconds, that each texture is displayed.

Return Value

A new tile definition.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/init(textures:size:timePerFrame:)

func SKTileDefinitionFromID

func SKTileDefinitionFromID(id objc.ID) SKTileDefinition

SKTileDefinitionFromID constructs a SKTileDefinition from an objc.ID.

A single tile that can be repeated in a tile map.

func (SKTileDefinition) Autorelease

func (t SKTileDefinition) Autorelease() SKTileDefinition

Autorelease adds the receiver to the current autorelease pool.

func (SKTileDefinition) EncodeWithCoder

func (t SKTileDefinition) EncodeWithCoder(coder foundation.INSCoder)

func (SKTileDefinition) FlipHorizontally

func (t SKTileDefinition) FlipHorizontally() bool

A Boolean that flips the definition’s image vertically.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/flipHorizontally

func (SKTileDefinition) FlipVertically

func (t SKTileDefinition) FlipVertically() bool

A Boolean that flips the definition’s image horizontally.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/flipVertically

func (SKTileDefinition) Init

Init initializes the instance.

func (SKTileDefinition) InitWithTexture

func (t SKTileDefinition) InitWithTexture(texture ISKTexture) SKTileDefinition

Initializes a new tile definition with a single texture.

texture: The texture to reference for the definition’s size and content.

Return Value

A new tile definition.

Discussion

The size of the newly created tile definition will be the same as the texture used to initialize it.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/init(texture:)

func (SKTileDefinition) InitWithTextureNormalTextureSize

func (t SKTileDefinition) InitWithTextureNormalTextureSize(texture ISKTexture, normalTexture ISKTexture, size corefoundation.CGSize) SKTileDefinition

Initializes a new tile definition with a single texture and separate normal texture for simulating 3D lighting.

texture: The texture to reference for the definition’s content.

normalTexture: The texture to reference for generating normals to simulate 3D lighting.

size: The size of the tile in points.

Return Value

A new tile definition.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/init(texture:normalTexture:size:)

func (SKTileDefinition) InitWithTextureSize

func (t SKTileDefinition) InitWithTextureSize(texture ISKTexture, size corefoundation.CGSize) SKTileDefinition

Initializes a new tile definition of a specified size with a single texture.

texture: The texture to reference for the definition’s content.

size: The size of the tile in points.

Return Value

A new tile definition.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/init(texture:size:)

func (SKTileDefinition) InitWithTexturesNormalTexturesSizeTimePerFrame

func (t SKTileDefinition) InitWithTexturesNormalTexturesSizeTimePerFrame(textures []SKTexture, normalTextures []SKTexture, size corefoundation.CGSize, timePerFrame float64) SKTileDefinition

Initializes a new tile definition with arrays of textures and normal textures for animation.

textures: An array of textures to reference for the definition’s content.

normalTextures: An array of textures to reference for generating normals to simulate 3D lighting.

size: The size of the tile in points.

timePerFrame: The duration, in seconds, that each texture is displayed.

Return Value

A new tile definition.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/init(textures:normalTextures:size:timePerFrame:)

func (SKTileDefinition) InitWithTexturesSizeTimePerFrame

func (t SKTileDefinition) InitWithTexturesSizeTimePerFrame(textures []SKTexture, size corefoundation.CGSize, timePerFrame float64) SKTileDefinition

Initializes a new tile definition with an array of textures for animation.

textures: An array of textures to reference for the definition’s size and content.

size: The size of the tile in points.

timePerFrame: The duration, in seconds, that each texture is displayed.

Return Value

A new tile definition.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/init(textures:size:timePerFrame:)

func (SKTileDefinition) Name

func (t SKTileDefinition) Name() string

A name associated with the tile definition.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/name

func (SKTileDefinition) NormalTextures

func (t SKTileDefinition) NormalTextures() []SKTexture

An array of SKTexture objects used to generate the normals for the tile to simulate 3D lighting.

Discussion

If the tile is non-animated, this will be an array containing one texture.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/normalTextures

func (SKTileDefinition) PlacementWeight

func (t SKTileDefinition) PlacementWeight() uint

The placement weight of the tile definition.

Discussion

This value is used to determine how likely this tile definition is to be chosen for placement when a SKTileGroupRule has multiple tile definitions assigned to it. A higher value relative to the other definitions assigned to the rule make it more likely for this definition to be selected; lower values make it less likely. Defaults to 1. When set to 0, the definition will never be chosen as long as there is at least one other definition with a SKTileDefinition.PlacementWeight above 0.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/placementWeight

func (SKTileDefinition) Rotation

The rotation of the tile definition in 90˚ increments.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/rotation

func (SKTileDefinition) SetFlipHorizontally

func (t SKTileDefinition) SetFlipHorizontally(value bool)

func (SKTileDefinition) SetFlipVertically

func (t SKTileDefinition) SetFlipVertically(value bool)

func (SKTileDefinition) SetName

func (t SKTileDefinition) SetName(value string)

func (SKTileDefinition) SetNormalTextures

func (t SKTileDefinition) SetNormalTextures(value []SKTexture)

func (SKTileDefinition) SetPlacementWeight

func (t SKTileDefinition) SetPlacementWeight(value uint)

func (SKTileDefinition) SetRotation

func (t SKTileDefinition) SetRotation(value SKTileDefinitionRotation)

func (SKTileDefinition) SetSize

func (t SKTileDefinition) SetSize(value corefoundation.CGSize)

func (SKTileDefinition) SetTextures

func (t SKTileDefinition) SetTextures(value []SKTexture)

func (SKTileDefinition) SetTimePerFrame

func (t SKTileDefinition) SetTimePerFrame(value float64)

func (SKTileDefinition) SetUserData

func (t SKTileDefinition) SetUserData(value foundation.INSDictionary)

func (SKTileDefinition) Size

The size of the tile definition in points.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/size

func (SKTileDefinition) Textures

func (t SKTileDefinition) Textures() []SKTexture

An array of SKTexture objects that defines the tile definition object’s content.

Discussion

If the tile is non-animated, this will be an array containing one textures.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/textures

func (SKTileDefinition) TimePerFrame

func (t SKTileDefinition) TimePerFrame() float64

The duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/timePerFrame

func (SKTileDefinition) UserData

A dictionary containing arbitrary data.

Discussion

You use this property to store your own data in a tile definition. For example, you might use this property to specify whether this tile is a platform that a player can land on.

SpriteKit doesn’t do anything with this data. However, the data is archived when the tile definition is archived.

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinition/userData

type SKTileDefinitionClass

type SKTileDefinitionClass struct {
	// contains filtered or unexported fields
}

func GetSKTileDefinitionClass

func GetSKTileDefinitionClass() SKTileDefinitionClass

GetSKTileDefinitionClass returns the class object for SKTileDefinition.

func (SKTileDefinitionClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKTileDefinitionClass) Class

func (sc SKTileDefinitionClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKTileDefinitionRotation

type SKTileDefinitionRotation uint

See: https://developer.apple.com/documentation/SpriteKit/SKTileDefinitionRotation

const (
	SKTileDefinitionRotation0   SKTileDefinitionRotation = 0
	SKTileDefinitionRotation180 SKTileDefinitionRotation = 2
	SKTileDefinitionRotation270 SKTileDefinitionRotation = 3
	SKTileDefinitionRotation90  SKTileDefinitionRotation = 1
)

func (SKTileDefinitionRotation) String

func (e SKTileDefinitionRotation) String() string

type SKTileGroup

type SKTileGroup struct {
	objectivec.Object
}

A set of tiles that collectively define one type of terrain.

Overview

An SKTileGroup object contains either the definition of a single tile or an array of SKTileGroupRule objects that define adjacency rules.

You supply a tile group with either:

- The definition of a single tile that can be used to populate a tile map node with a single texture. - An array of one or more tile group rules that allow for the automatic placement of textures dependent on their adjacency and the placement weights of their definitions. For example, a tile group may contain nine tile group rules containing the definitions of the central tile and eight edge tiles that, when placed adjacently, appear as a single object.

The preferred method to create tile groups is to use the editor tools in Xcode. However, to work with SpriteKit’s tile support programmatically, see the following articles.

Creating Tile Groups

Accessing or Setting a Tile Group’s Properties

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroup

func NewSKTileGroup

func NewSKTileGroup() SKTileGroup

NewSKTileGroup creates a new SKTileGroup instance.

func NewTileGroupWithRules

func NewTileGroupWithRules(rules []SKTileGroupRule) SKTileGroup

Creates and initializes a tile group with the specified tile group rules.

rules: The tile group rules to determine tile placement.

Return Value

A new tile group.

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroup/init(rules:)

func NewTileGroupWithTileDefinition

func NewTileGroupWithTileDefinition(tileDefinition ISKTileDefinition) SKTileGroup

Creates and initializes a simple tile group with a single tile definition.

tileDefinition: The tile definition to place in a tile map.

Return Value

A new tile group.

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroup/init(tileDefinition:)

func SKTileGroupFromID

func SKTileGroupFromID(id objc.ID) SKTileGroup

SKTileGroupFromID constructs a SKTileGroup from an objc.ID.

A set of tiles that collectively define one type of terrain.

func (SKTileGroup) Autorelease

func (t SKTileGroup) Autorelease() SKTileGroup

Autorelease adds the receiver to the current autorelease pool.

func (SKTileGroup) EncodeWithCoder

func (t SKTileGroup) EncodeWithCoder(coder foundation.INSCoder)

func (SKTileGroup) Init

func (t SKTileGroup) Init() SKTileGroup

Init initializes the instance.

func (SKTileGroup) InitWithRules

func (t SKTileGroup) InitWithRules(rules []SKTileGroupRule) SKTileGroup

Creates and initializes a tile group with the specified tile group rules.

rules: The tile group rules to determine tile placement.

Return Value

A new tile group.

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroup/init(rules:)

func (SKTileGroup) InitWithTileDefinition

func (t SKTileGroup) InitWithTileDefinition(tileDefinition ISKTileDefinition) SKTileGroup

Creates and initializes a simple tile group with a single tile definition.

tileDefinition: The tile definition to place in a tile map.

Return Value

A new tile group.

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroup/init(tileDefinition:)

func (SKTileGroup) Name

func (t SKTileGroup) Name() string

The receiver’s name.

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroup/name

func (SKTileGroup) Rules

func (t SKTileGroup) Rules() []SKTileGroupRule

An array of SKTileGroupRule objects that the tile group uses to determine tile placement.

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroup/rules

func (SKTileGroup) SetName

func (t SKTileGroup) SetName(value string)

func (SKTileGroup) SetRules

func (t SKTileGroup) SetRules(value []SKTileGroupRule)

type SKTileGroupClass

type SKTileGroupClass struct {
	// contains filtered or unexported fields
}

func GetSKTileGroupClass

func GetSKTileGroupClass() SKTileGroupClass

GetSKTileGroupClass returns the class object for SKTileGroup.

func (SKTileGroupClass) Alloc

func (sc SKTileGroupClass) Alloc() SKTileGroup

Alloc allocates memory for a new instance of the class.

func (SKTileGroupClass) Class

func (sc SKTileGroupClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (SKTileGroupClass) EmptyTileGroup

func (_SKTileGroupClass SKTileGroupClass) EmptyTileGroup() SKTileGroup

Creates an empty tile that erases the existing tile at that location on a tile map.

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroup/empty()

type SKTileGroupRule

type SKTileGroupRule struct {
	objectivec.Object
}

Rules that describe how various tiles should be placed in a map.

Overview

When a tile is filled in a tile map, the tile group rule defines how neighboring tiles are populated based on adjacency rules. A rule with multiple definitions uses the placement weights of the definitions to randomly select which to use.

Creating a Tile Group Rule

Accessing or Setting Tile Group Rule Properties

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroupRule

func NewSKTileGroupRule

func NewSKTileGroupRule() SKTileGroupRule

NewSKTileGroupRule creates a new SKTileGroupRule instance.

func NewTileGroupRuleWithAdjacencyTileDefinitions

func NewTileGroupRuleWithAdjacencyTileDefinitions(adjacency SKTileAdjacencyMask, tileDefinitions []SKTileDefinition) SKTileGroupRule

Initializes a new tile group rule with adjacency rules and tile definitions.

adjacency: The adjacency requirements for this rule.

tileDefinitions: The tile definitions used for this rule.

Return Value

A new tile group rule.

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroupRule/init(adjacency:tileDefinitions:)

func SKTileGroupRuleFromID

func SKTileGroupRuleFromID(id objc.ID) SKTileGroupRule

SKTileGroupRuleFromID constructs a SKTileGroupRule from an objc.ID.

Rules that describe how various tiles should be placed in a map.

func (SKTileGroupRule) Adjacency

func (t SKTileGroupRule) Adjacency() SKTileAdjacencyMask

The adjacency requirement for this rule.

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroupRule/adjacency

func (SKTileGroupRule) Autorelease

func (t SKTileGroupRule) Autorelease() SKTileGroupRule

Autorelease adds the receiver to the current autorelease pool.

func (SKTileGroupRule) EncodeWithCoder

func (t SKTileGroupRule) EncodeWithCoder(coder foundation.INSCoder)

func (SKTileGroupRule) Init

Init initializes the instance.

func (SKTileGroupRule) InitWithAdjacencyTileDefinitions

func (t SKTileGroupRule) InitWithAdjacencyTileDefinitions(adjacency SKTileAdjacencyMask, tileDefinitions []SKTileDefinition) SKTileGroupRule

Initializes a new tile group rule with adjacency rules and tile definitions.

adjacency: The adjacency requirements for this rule.

tileDefinitions: The tile definitions used for this rule.

Return Value

A new tile group rule.

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroupRule/init(adjacency:tileDefinitions:)

func (SKTileGroupRule) Name

func (t SKTileGroupRule) Name() string

A name associated with the tile group rule.

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroupRule/name

func (SKTileGroupRule) SetAdjacency

func (t SKTileGroupRule) SetAdjacency(value SKTileAdjacencyMask)

func (SKTileGroupRule) SetName

func (t SKTileGroupRule) SetName(value string)

func (SKTileGroupRule) SetTileDefinitions

func (t SKTileGroupRule) SetTileDefinitions(value []SKTileDefinition)

func (SKTileGroupRule) TileDefinitions

func (t SKTileGroupRule) TileDefinitions() []SKTileDefinition

The tile definitions used for this rule.

Discussion

When this rule is evaluated and its conditions met, one of the definitions is randomly selected for placement based on their placement weights.

See: https://developer.apple.com/documentation/SpriteKit/SKTileGroupRule/tileDefinitions

type SKTileGroupRuleClass

type SKTileGroupRuleClass struct {
	// contains filtered or unexported fields
}

func GetSKTileGroupRuleClass

func GetSKTileGroupRuleClass() SKTileGroupRuleClass

GetSKTileGroupRuleClass returns the class object for SKTileGroupRule.

func (SKTileGroupRuleClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKTileGroupRuleClass) Class

func (sc SKTileGroupRuleClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKTileMapNode

type SKTileMapNode struct {
	SKNode
}

A two-dimensional array of images.

Overview

SKTileMapNode does the work of laying out predefined tiles in a grid of any size. Typically, you configure 9-slice images (tile groups) in Xcode’s SpriteKit scene editor and paint the look of your tile map ahead of time versus configuring the tile map in code.

As with sprite nodes, you can layer tile maps with different blend modes or control it with actions and physics, for example, for the purpose of parallax scrolling. The rendered tile map can be post processed with an SKShader to add effects such as motion blur or atmospheric perspective.

To work with a tile map programmatically, you supply SKTileMapNode with a tile set that defines the tile definitions it can render. Then, fill each tile in the tile map with the fill(with:) method and set individual tiles with setTileGroup(_:andTileDefinition:forColumn:row:).

Controlling a Tile Map’s On-Screen Position Relative to its Origin

Reading or Manually Configuring the Tile Map’s Size

Querying the Tile Map’s Properties

Tinting a Tile Map

Lighting a Tile Map

Configuring How Alpha Values Blend the Sprite

Working with Custom Shaders

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode

func NewSKTileMapNode

func NewSKTileMapNode() SKTileMapNode

NewSKTileMapNode creates a new SKTileMapNode instance.

func NewTileMapNodeWithCoder

func NewTileMapNodeWithCoder(aDecoder foundation.INSCoder) SKTileMapNode

Called when a node is initialized from an .sks file.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(coder:)

func NewTileMapNodeWithFileNamed

func NewTileMapNodeWithFileNamed(filename string) SKTileMapNode

Creates a new node by loading an archive file from the game’s main bundle.

filename: The name of the file, without a file extension. The file must be in the app’s main bundle and have a `XCUIElementTypeSks` filename extension.

Return Value

The unarchived node object.

Discussion

If you call this method on a subclass of the SKScene class and the object in the archive is an SKScene object, the returned object is initialized as if it is a member of the subclass. You use this behavior to create scene layouts in the Xcode Editor and provide custom behaviors in your subclass.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(fileNamed:)

func SKTileMapNodeFromID

func SKTileMapNodeFromID(id objc.ID) SKTileMapNode

SKTileMapNodeFromID constructs a SKTileMapNode from an objc.ID.

A two-dimensional array of images.

func (SKTileMapNode) AnchorPoint

func (t SKTileMapNode) AnchorPoint() corefoundation.CGPoint

Defines the point in the tile map that corresponds to its SKNode.Position.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/anchorPoint

func (SKTileMapNode) AttributeValues

func (t SKTileMapNode) AttributeValues() foundation.INSDictionary

The values of each attribute associated with the node’s attached shader.

Discussion

All nodes have their own copy of an attribute value and therefore the attribute values can be different per-node across the same SKShader. If instead you need all nodes to share the same value, use SKUniform. Uniforms can change values every frame, but uniforms cannot vary per-node like attributes can.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/attributeValues

func (SKTileMapNode) Autorelease

func (t SKTileMapNode) Autorelease() SKTileMapNode

Autorelease adds the receiver to the current autorelease pool.

func (SKTileMapNode) BlendMode

func (t SKTileMapNode) BlendMode() SKBlendMode

Defines the blend mode to use when compositing the tile map over other nodes.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/blendMode

func (SKTileMapNode) CenterOfTileAtColumnRow

func (t SKTileMapNode) CenterOfTileAtColumnRow(column uint, row uint) corefoundation.CGPoint

column: The column index of the tile.

row: The row index of the tile.

Return Value

The coordinates in points of the center of the tile for a given column and row.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/centerOfTile(atColumn:row:)

func (SKTileMapNode) Color

func (t SKTileMapNode) Color() appkit.NSColor

The base color for the tile map. The influence of the color over the tile map node’s textures is controlled by SKTileMapNode.ColorBlendFactor.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/color

func (SKTileMapNode) ColorBlendFactor

func (t SKTileMapNode) ColorBlendFactor() float64

Controls the blending between the texture and the tile map object’s SKTileMapNode.Color. Values are clamped between zero and one where zero has no color blending and one has the maximum color blending.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/colorBlendFactor

func (SKTileMapNode) EnableAutomapping

func (t SKTileMapNode) EnableAutomapping() bool

When creating a tile map node programmatically, specifies whether the tile map uses automapping behavior like the scene editor.

See: https://developer.apple.com/documentation/spritekit/sktilemapnode/enableautomapping

func (SKTileMapNode) Init

func (t SKTileMapNode) Init() SKTileMapNode

Init initializes the instance.

func (SKTileMapNode) LightingBitMask

func (t SKTileMapNode) LightingBitMask() uint32

A mask that defines how the tile map is lit by light nodes in the scene.

Discussion

To determine whether this sprite is lit by a light node, the sprite’s `lightingBitMask` property is tested against the light’s categoryBitMask property by performing a logical AND operation. If the comparison results in a nonzero value, the sprite is lit by this light.

The default value is 0x00000000 (all bits cleared).

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/lightingBitMask

func (SKTileMapNode) MapSize

func (t SKTileMapNode) MapSize() corefoundation.CGSize

The overall size of the tile map.

Discussion

For a grid set type, the overall size, in points, of the node will be SKTileMapNode.NumberOfColumns `*` SKTileMapNode.TileSize `.` width wide and SKWarpGeometryGrid.NumberOfRows `*` SKTileMapNode.TileSize `.` height high.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/mapSize

func (SKTileMapNode) NumberOfColumns

func (t SKTileMapNode) NumberOfColumns() uint

The number of columns in the tile map

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/numberOfColumns

func (SKTileMapNode) NumberOfRows

func (t SKTileMapNode) NumberOfRows() uint

The number of rows in the tile map.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/numberOfRows

func (SKTileMapNode) SetAnchorPoint

func (t SKTileMapNode) SetAnchorPoint(value corefoundation.CGPoint)

func (SKTileMapNode) SetAttributeValues

func (t SKTileMapNode) SetAttributeValues(value foundation.INSDictionary)

func (SKTileMapNode) SetBlendMode

func (t SKTileMapNode) SetBlendMode(value SKBlendMode)

func (SKTileMapNode) SetColor

func (t SKTileMapNode) SetColor(value appkit.NSColor)

func (SKTileMapNode) SetColorBlendFactor

func (t SKTileMapNode) SetColorBlendFactor(value float64)

func (SKTileMapNode) SetEnableAutomapping

func (t SKTileMapNode) SetEnableAutomapping(value bool)

func (SKTileMapNode) SetLightingBitMask

func (t SKTileMapNode) SetLightingBitMask(value uint32)

func (SKTileMapNode) SetNumberOfColumns

func (t SKTileMapNode) SetNumberOfColumns(value uint)

func (SKTileMapNode) SetNumberOfRows

func (t SKTileMapNode) SetNumberOfRows(value uint)

func (SKTileMapNode) SetShader

func (t SKTileMapNode) SetShader(value ISKShader)

func (SKTileMapNode) SetTileSet

func (t SKTileMapNode) SetTileSet(value ISKTileSet)

func (SKTileMapNode) SetTileSize

func (t SKTileMapNode) SetTileSize(value corefoundation.CGSize)

func (SKTileMapNode) SetValueForAttributeNamed

func (t SKTileMapNode) SetValueForAttributeNamed(value ISKAttributeValue, key string)

Sets an attribute value for an attached shader.

value: An attribute value object containing the scalar or vector value to set in the attached shader.

key: The attribute name.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/setValue(_:forAttribute:)

func (SKTileMapNode) Shader

func (t SKTileMapNode) Shader() ISKShader

Defines a shader which is applied to each tile of the tile map.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/shader

func (SKTileMapNode) TileColumnIndexFromPosition

func (t SKTileMapNode) TileColumnIndexFromPosition(position corefoundation.CGPoint) uint

position: The position in the tile map to check.

Return Value

The tile map node object’s tile column index for the specified position.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/tileColumnIndex(fromPosition:)

func (SKTileMapNode) TileDefinitionAtColumnRow

func (t SKTileMapNode) TileDefinitionAtColumnRow(column uint, row uint) ISKTileDefinition

column: The column index of the tile.

row: The row index of the tile.

Return Value

The tile definition for the tile at the specified column and row.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/tileDefinition(atColumn:row:)

func (SKTileMapNode) TileGroupAtColumnRow

func (t SKTileMapNode) TileGroupAtColumnRow(column uint, row uint) ISKTileGroup

column: The column index of the tile.

row: The row index of the tile.

Return Value

The tile group for the tile at the specified column and row.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/tileGroup(atColumn:row:)

func (SKTileMapNode) TileRowIndexFromPosition

func (t SKTileMapNode) TileRowIndexFromPosition(position corefoundation.CGPoint) uint

Returns the tile map node object’s tile row index for the specified position in points.

position: The position in the tile map to check.

Return Value

The tile map node object’s tile row index for the specified position.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/tileRowIndex(fromPosition:)

func (SKTileMapNode) TileSet

func (t SKTileMapNode) TileSet() ISKTileSet

The tile set being used by this tile map. The tile map object can only display tiles that exist in this set.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/tileSet

func (SKTileMapNode) TileSize

func (t SKTileMapNode) TileSize() corefoundation.CGSize

The size of each tile in points.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/tileSize

func (SKTileMapNode) ValueForAttributeNamed

func (t SKTileMapNode) ValueForAttributeNamed(key string) ISKAttributeValue

The value of a shader attribute.

key: The attribute name.

Return Value

An attribute value object containing the scalar or vector value or `nil` if no such attribute exists.

See: https://developer.apple.com/documentation/SpriteKit/SKTileMapNode/value(forAttributeNamed:)

type SKTileMapNodeClass

type SKTileMapNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKTileMapNodeClass

func GetSKTileMapNodeClass() SKTileMapNodeClass

GetSKTileMapNodeClass returns the class object for SKTileMapNode.

func (SKTileMapNodeClass) Alloc

func (sc SKTileMapNodeClass) Alloc() SKTileMapNode

Alloc allocates memory for a new instance of the class.

func (SKTileMapNodeClass) Class

func (sc SKTileMapNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKTileSet

type SKTileSet struct {
	objectivec.Object
}

A container for related tile groups.

Overview

An SKTileSet object contains an array of tile groups that define which tile definitions are available for use in a tile map.

Tile sets also define the arrangement of tiles within a tile map. In addition to the default rectangular grid layout, tile sets can also define hexagonal and isometric layouts.

Creating a Tile Set Programmatically

Accessing or Reading a Tile Set’s Properties

See: https://developer.apple.com/documentation/SpriteKit/SKTileSet

func NewSKTileSet

func NewSKTileSet() SKTileSet

NewSKTileSet creates a new SKTileSet instance.

func NewTileSetFromURL

func NewTileSetFromURL(url foundation.NSURL) SKTileSet

Initializes a tile set from a URL to an archived .sks file.

url: The URL of a tile set file.

Return Value

A new tile set or `nil` if the URL doesn’t point to a valid tile set file.

See: https://developer.apple.com/documentation/SpriteKit/SKTileSet/init(from:)

func NewTileSetNamed

func NewTileSetNamed(name string) SKTileSet

Initializes a tile set by searching the app bundle for an archived `XCUIElementTypeSks` file by name.

name: The name of the tile set to search for.

Return Value

A new tile set or `nil` if a tile set with a matching name cannot be found.

See: https://developer.apple.com/documentation/SpriteKit/SKTileSet/init(named:)

func NewTileSetWithTileGroups

func NewTileSetWithTileGroups(tileGroups []SKTileGroup) SKTileSet

Initializes a new tile set with an array of tile groups and rectangular grid layout.

tileGroups: An array of SKTileGroup objects from which to create the tile set from.

Return Value

A new tile set.

See: https://developer.apple.com/documentation/SpriteKit/SKTileSet/init(tileGroups:)

func NewTileSetWithTileGroupsTileSetType

func NewTileSetWithTileGroupsTileSetType(tileGroups []SKTileGroup, tileSetType SKTileSetType) SKTileSet

Initializes a new tile set with an array of tile groups and specified layout.

tileGroups: An array of SKTileGroup objects from which to create the tile set from.

tileSetType: The arrangement of the tiles.

Return Value

A new tile set.

See: https://developer.apple.com/documentation/SpriteKit/SKTileSet/init(tileGroups:tileSetType:)

func SKTileSetFromID

func SKTileSetFromID(id objc.ID) SKTileSet

SKTileSetFromID constructs a SKTileSet from an objc.ID.

A container for related tile groups.

func (SKTileSet) Autorelease

func (t SKTileSet) Autorelease() SKTileSet

Autorelease adds the receiver to the current autorelease pool.

func (SKTileSet) DefaultTileGroup

func (t SKTileSet) DefaultTileGroup() ISKTileGroup

The tile set’s default tile group.

Discussion

With auto-mapping enabled, it is possible for some tiles to be removed because there is either no valid rule or a missing tile group for the required adjacency rule. In this situation, those tiles are replaced by the tile group specified by SKTileSet.DefaultTileGroup.

See: https://developer.apple.com/documentation/SpriteKit/SKTileSet/defaultTileGroup

func (SKTileSet) DefaultTileSize

func (t SKTileSet) DefaultTileSize() corefoundation.CGSize

The tile set’s default tile size.

Discussion

The default tile size an SKTileMapNode will use for its tiles

See: https://developer.apple.com/documentation/SpriteKit/SKTileSet/defaultTileSize

func (SKTileSet) EncodeWithCoder

func (t SKTileSet) EncodeWithCoder(coder foundation.INSCoder)

func (SKTileSet) Init

func (t SKTileSet) Init() SKTileSet

Init initializes the instance.

func (SKTileSet) InitWithTileGroups

func (t SKTileSet) InitWithTileGroups(tileGroups []SKTileGroup) SKTileSet

Initializes a new tile set with an array of tile groups and rectangular grid layout.

tileGroups: An array of SKTileGroup objects from which to create the tile set from.

Return Value

A new tile set.

See: https://developer.apple.com/documentation/SpriteKit/SKTileSet/init(tileGroups:)

func (SKTileSet) InitWithTileGroupsTileSetType

func (t SKTileSet) InitWithTileGroupsTileSetType(tileGroups []SKTileGroup, tileSetType SKTileSetType) SKTileSet

Initializes a new tile set with an array of tile groups and specified layout.

tileGroups: An array of SKTileGroup objects from which to create the tile set from.

tileSetType: The arrangement of the tiles.

Return Value

A new tile set.

See: https://developer.apple.com/documentation/SpriteKit/SKTileSet/init(tileGroups:tileSetType:)

func (SKTileSet) Name

func (t SKTileSet) Name() string

A name associated with the tile set.

See: https://developer.apple.com/documentation/SpriteKit/SKTileSet/name

func (SKTileSet) SetDefaultTileGroup

func (t SKTileSet) SetDefaultTileGroup(value ISKTileGroup)

func (SKTileSet) SetDefaultTileSize

func (t SKTileSet) SetDefaultTileSize(value corefoundation.CGSize)

func (SKTileSet) SetName

func (t SKTileSet) SetName(value string)

func (SKTileSet) SetTileGroups

func (t SKTileSet) SetTileGroups(value []SKTileGroup)

func (SKTileSet) SetType

func (t SKTileSet) SetType(value SKTileSetType)

func (SKTileSet) TileGroups

func (t SKTileSet) TileGroups() []SKTileGroup

The tile set’s array of tile group objects.

See: https://developer.apple.com/documentation/SpriteKit/SKTileSet/tileGroups

func (SKTileSet) Type

func (t SKTileSet) Type() SKTileSetType

The tile set’s type.

Discussion

The tile set’s type specifies how the tiles in the set will be arranged when placed in a tile map.

See: https://developer.apple.com/documentation/SpriteKit/SKTileSet/type

type SKTileSetClass

type SKTileSetClass struct {
	// contains filtered or unexported fields
}

func GetSKTileSetClass

func GetSKTileSetClass() SKTileSetClass

GetSKTileSetClass returns the class object for SKTileSet.

func (SKTileSetClass) Alloc

func (sc SKTileSetClass) Alloc() SKTileSet

Alloc allocates memory for a new instance of the class.

func (SKTileSetClass) Class

func (sc SKTileSetClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKTileSetType

type SKTileSetType uint

See: https://developer.apple.com/documentation/SpriteKit/SKTileSetType

const (
	SKTileSetTypeGrid            SKTileSetType = 0
	SKTileSetTypeHexagonalFlat   SKTileSetType = 2
	SKTileSetTypeHexagonalPointy SKTileSetType = 3
	SKTileSetTypeIsometric       SKTileSetType = 1
)

func (SKTileSetType) String

func (e SKTileSetType) String() string

type SKTransformNode

type SKTransformNode struct {
	SKNode
}

A node that allows its children to rotate in 3D.

Overview

[SKTranformNode] adds the ability to rotate nodes across the x and y axes. When combined with SKNode’s SKNode.ZRotation property, nodes added as children to a transform node have the ability to rotate in 3D.

Rotating Child Nodes

Reading the Current Rotation

See: https://developer.apple.com/documentation/SpriteKit/SKTransformNode

func NewSKTransformNode

func NewSKTransformNode() SKTransformNode

NewSKTransformNode creates a new SKTransformNode instance.

func NewTransformNodeWithCoder

func NewTransformNodeWithCoder(aDecoder foundation.INSCoder) SKTransformNode

Called when a node is initialized from an .sks file.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(coder:)

func NewTransformNodeWithFileNamed

func NewTransformNodeWithFileNamed(filename string) SKTransformNode

Creates a new node by loading an archive file from the game’s main bundle.

filename: The name of the file, without a file extension. The file must be in the app’s main bundle and have a `XCUIElementTypeSks` filename extension.

Return Value

The unarchived node object.

Discussion

If you call this method on a subclass of the SKScene class and the object in the archive is an SKScene object, the returned object is initialized as if it is a member of the subclass. You use this behavior to create scene layouts in the Xcode Editor and provide custom behaviors in your subclass.

See: https://developer.apple.com/documentation/SpriteKit/SKNode/init(fileNamed:)

func SKTransformNodeFromID

func SKTransformNodeFromID(id objc.ID) SKTransformNode

SKTransformNodeFromID constructs a SKTransformNode from an objc.ID.

A node that allows its children to rotate in 3D.

func (SKTransformNode) Autorelease

func (t SKTransformNode) Autorelease() SKTransformNode

Autorelease adds the receiver to the current autorelease pool.

func (SKTransformNode) Init

Init initializes the instance.

func (SKTransformNode) SetXRotation

func (t SKTransformNode) SetXRotation(value float64)

func (SKTransformNode) SetYRotation

func (t SKTransformNode) SetYRotation(value float64)

type SKTransformNodeClass

type SKTransformNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKTransformNodeClass

func GetSKTransformNodeClass() SKTransformNodeClass

GetSKTransformNodeClass returns the class object for SKTransformNode.

func (SKTransformNodeClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKTransformNodeClass) Class

func (sc SKTransformNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKTransition

type SKTransition struct {
	objectivec.Object
}

An object used to perform an animated transition to a new scene.

Overview

Scenes are the basic building blocks of games. Typically, you design self-contained scenes for the parts of your game, and then transition between these scenes as necessary. For example, you might create different scene classes to represent any or all of the following concepts:

- A loading scene to display while other content is loaded - A main menu scene to choose what kind of game the user wants to play - A scene to configure the details of the specific kind of game the user chose - A scene that provides the gameplay - A scene displayed when gameplay ends

When you present a new scene in a view that is already presenting a scene, you have the option of using a transition to animate the change from the old scene to the new scene. Using a transition provides continuity so that the scene change is not quite so abrupt.

Pausing

See: https://developer.apple.com/documentation/SpriteKit/SKTransition

func NewSKTransition

func NewSKTransition() SKTransition

NewSKTransition creates a new SKTransition instance.

func NewTransitionWithCIFilterDuration

func NewTransitionWithCIFilterDuration(filter *coreimage.CIFilter, sec foundation.NSTimeInterval) SKTransition

Creates a transition that uses a Core Image filter to perform the transition.

filter: A Core Image filter.

sec: The duration of the transition.

Return Value

A new transition.

Discussion

The filter used to perform the transition must a be filter that requires only two image parameters (`inputImage`, `inputTargetImage`) and generates a single image (`outputImage`). The transition automatically sets the filter’s `inputImage`, `inputTargetImage`, and `inputTime` properties. You must set up any other filter properties before creating the transition.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/init(ciFilter:duration:)

func SKTransitionFromID

func SKTransitionFromID(id objc.ID) SKTransition

SKTransitionFromID constructs a SKTransition from an objc.ID.

An object used to perform an animated transition to a new scene.

func (SKTransition) Autorelease

func (t SKTransition) Autorelease() SKTransition

Autorelease adds the receiver to the current autorelease pool.

func (SKTransition) Init

func (t SKTransition) Init() SKTransition

Init initializes the instance.

func (SKTransition) PausesIncomingScene

func (t SKTransition) PausesIncomingScene() bool

A Boolean value that determines whether the incoming scene is paused during the transition.

Discussion

The default value is true.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/pausesIncomingScene

func (SKTransition) PausesOutgoingScene

func (t SKTransition) PausesOutgoingScene() bool

A Boolean value that determines whether the outgoing scene is paused during the transition.

Discussion

The default value is true.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/pausesOutgoingScene

func (SKTransition) SetPausesIncomingScene

func (t SKTransition) SetPausesIncomingScene(value bool)

func (SKTransition) SetPausesOutgoingScene

func (t SKTransition) SetPausesOutgoingScene(value bool)

type SKTransitionClass

type SKTransitionClass struct {
	// contains filtered or unexported fields
}

func GetSKTransitionClass

func GetSKTransitionClass() SKTransitionClass

GetSKTransitionClass returns the class object for SKTransition.

func (SKTransitionClass) Alloc

func (sc SKTransitionClass) Alloc() SKTransition

Alloc allocates memory for a new instance of the class.

func (SKTransitionClass) Class

func (sc SKTransitionClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (SKTransitionClass) CrossFadeWithDuration

func (_SKTransitionClass SKTransitionClass) CrossFadeWithDuration(sec foundation.NSTimeInterval) SKTransition

Creates a cross fade transition.

sec: The duration of the transition.

Return Value

A new transition.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/crossFade(withDuration:)

func (SKTransitionClass) DoorsCloseHorizontalWithDuration

func (_SKTransitionClass SKTransitionClass) DoorsCloseHorizontalWithDuration(sec foundation.NSTimeInterval) SKTransition

Creates a transition where the new scene appears as a pair of closing horizontal doors.

sec: The duration of the transition.

Return Value

A new transition.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/doorsCloseHorizontal(withDuration:)

func (SKTransitionClass) DoorsCloseVerticalWithDuration

func (_SKTransitionClass SKTransitionClass) DoorsCloseVerticalWithDuration(sec foundation.NSTimeInterval) SKTransition

Creates a transition where the new scene appears as a pair of closing vertical doors.

sec: The duration of the transition.

Return Value

A new transition.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/doorsCloseVertical(withDuration:)

func (SKTransitionClass) DoorsOpenHorizontalWithDuration

func (_SKTransitionClass SKTransitionClass) DoorsOpenHorizontalWithDuration(sec foundation.NSTimeInterval) SKTransition

Creates a transition where the new scene appears as a pair of opening horizontal doors.

sec: The duration of the transition.

Return Value

A new transition.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/doorsOpenHorizontal(withDuration:)

func (SKTransitionClass) DoorsOpenVerticalWithDuration

func (_SKTransitionClass SKTransitionClass) DoorsOpenVerticalWithDuration(sec foundation.NSTimeInterval) SKTransition

Creates a transition where the new scene appears as a pair of opening vertical doors.

sec: The duration of the transition.

Return Value

A new transition.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/doorsOpenVertical(withDuration:)

func (SKTransitionClass) DoorwayWithDuration

func (_SKTransitionClass SKTransitionClass) DoorwayWithDuration(sec foundation.NSTimeInterval) SKTransition

Creates a transition where the previous scene disappears as a pair of opening doors.

sec: The duration of the transition.

Return Value

A new transition.

Discussion

The new scene starts in the background and moves closer as the doors open.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/doorway(withDuration:)

func (SKTransitionClass) FadeWithColorDuration

func (_SKTransitionClass SKTransitionClass) FadeWithColorDuration(color appkit.NSColor, sec foundation.NSTimeInterval) SKTransition

Creates a transition that first fades to a constant color and then fades to the new scene.

color: The color to use as the fade color.

sec: The duration of the transition.

Return Value

A new transition.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/fade(with:duration:)

func (SKTransitionClass) FadeWithDuration

func (_SKTransitionClass SKTransitionClass) FadeWithDuration(sec foundation.NSTimeInterval) SKTransition

Creates a transition that first fades to black and then fades to the new scene.

sec: The duration of the transition.

Return Value

A new transition.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/fade(withDuration:)

func (SKTransitionClass) FlipHorizontalWithDuration

func (_SKTransitionClass SKTransitionClass) FlipHorizontalWithDuration(sec foundation.NSTimeInterval) SKTransition

Creates a transition where the two scenes are flipped across a horizontal line running through the center of the view.

sec: The duration of the transition.

Return Value

A new transition.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/flipHorizontal(withDuration:)

func (SKTransitionClass) FlipVerticalWithDuration

func (_SKTransitionClass SKTransitionClass) FlipVerticalWithDuration(sec foundation.NSTimeInterval) SKTransition

Creates a transition where the two scenes are flipped across a vertical line running through the center of the view.

sec: The duration of the transition.

Return Value

A new transition.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/flipVertical(withDuration:)

func (SKTransitionClass) MoveInWithDirectionDuration

func (_SKTransitionClass SKTransitionClass) MoveInWithDirectionDuration(direction SKTransitionDirection, sec foundation.NSTimeInterval) SKTransition

Creates a transition where the new scene moves in on top of the old scene.

direction: The direction of the move. Possible values are described in SKTransitionDirection.

sec: The duration of the transition.

Return Value

A new transition.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/moveIn(with:duration:)

func (SKTransitionClass) PushWithDirectionDuration

func (_SKTransitionClass SKTransitionClass) PushWithDirectionDuration(direction SKTransitionDirection, sec foundation.NSTimeInterval) SKTransition

Creates a transition where the new scene moves in, pushing the old scene out of the view.

direction: The direction of the push. Possible values are described in SKTransitionDirection.

sec: The duration of the transition.

Return Value

A new transition.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/push(with:duration:)

func (SKTransitionClass) RevealWithDirectionDuration

func (_SKTransitionClass SKTransitionClass) RevealWithDirectionDuration(direction SKTransitionDirection, sec foundation.NSTimeInterval) SKTransition

Creates a transition where the old scene moves out of the view, revealing the new scene underneath it.

direction: The direction of the reveal. Possible values are described in SKTransitionDirection.

sec: The duration of the transition.

Return Value

A new transition.

See: https://developer.apple.com/documentation/SpriteKit/SKTransition/reveal(with:duration:)

type SKTransitionDirection

type SKTransitionDirection int

See: https://developer.apple.com/documentation/SpriteKit/SKTransitionDirection

const (
	// SKTransitionDirectionDown: The transition goes down.
	SKTransitionDirectionDown SKTransitionDirection = 1
	// SKTransitionDirectionLeft: The transition goes left.
	SKTransitionDirectionLeft SKTransitionDirection = 3
	// SKTransitionDirectionRight: The transition goes right.
	SKTransitionDirectionRight SKTransitionDirection = 2
	// SKTransitionDirectionUp: The transition goes up.
	SKTransitionDirectionUp SKTransitionDirection = 0
)

func (SKTransitionDirection) String

func (e SKTransitionDirection) String() string

type SKUniform

type SKUniform struct {
	objectivec.Object
}

A container for uniform shader data.

Overview

An SKUniform object is used to hold uniform data for a custom OpenGL or OpenGL ES shader. The uniform data is accessible from all shaders that include the uniform.To use a uniform variable in your shader, create the SKUniform object and set its initial value. Once its value is specified, the SKUniform.UniformType property changes to match the type of the initial value you provided and can never change afterward. To use the uniform object, add it to an SKShader object that needs to access the uniform variable. To update the uniform variable’s value, choose the appropriate property on the uniform object based on the data type it encapsulates.

Creating and Initializing Uniform Objects

Reading Information About a Uniform

Reading and Writing an Uniform Object’s Value

Initializers

Instance Properties

See: https://developer.apple.com/documentation/SpriteKit/SKUniform

func NewSKUniform

func NewSKUniform() SKUniform

NewSKUniform creates a new SKUniform instance.

func NewUniformWithName

func NewUniformWithName(name string) SKUniform

Initializes a new uniform object.

name: The name used to identify the uniform variable; you use this name inside your shader to read the uniform variable’s value.

Return Value

An initialized uniform object.

Discussion

A uniform initialized with this method has no initial type and cannot be used in a shader until it is given an initial value. To set the initial value, use one of the properties defined in SKUniform. After its value is set, its SKUniform.UniformType property is set to match the uniform’s new type. Once set, the type may not be changed.

See: https://developer.apple.com/documentation/SpriteKit/SKUniform/init(name:)

func NewUniformWithNameFloat

func NewUniformWithNameFloat(name string, value float32) SKUniform

Initializes a new uniform object that holds a floating-point number.

name: The name used to identify the uniform variable; you use this name inside your shader to read the uniform variable’s value.

value: The initial floating-point value for the uniform variable.

Return Value

An initialized uniform object whose type is set to SKUniformType.float.

See: https://developer.apple.com/documentation/SpriteKit/SKUniform/init(name:float:)-48rln

func NewUniformWithNameTexture

func NewUniformWithNameTexture(name string, texture ISKTexture) SKUniform

Initializes a new uniform object that holds a reference to a texture.

name: The name used to identify the uniform variable; you use this name inside your shader to read the uniform variable’s value.

texture: The initial texture to use for the uniform variable.

Return Value

An initialized uniform object whose type is set to SKUniformType.texture.

See: https://developer.apple.com/documentation/SpriteKit/SKUniform/init(name:texture:)

func SKUniformFromID

func SKUniformFromID(id objc.ID) SKUniform

SKUniformFromID constructs a SKUniform from an objc.ID.

A container for uniform shader data.

func (SKUniform) Autorelease

func (u SKUniform) Autorelease() SKUniform

Autorelease adds the receiver to the current autorelease pool.

func (SKUniform) EncodeWithCoder

func (u SKUniform) EncodeWithCoder(coder foundation.INSCoder)

func (SKUniform) FloatValue

func (u SKUniform) FloatValue() float32

The receiver’s value as a floating-point value.

See: https://developer.apple.com/documentation/SpriteKit/SKUniform/floatValue

func (SKUniform) Init

func (u SKUniform) Init() SKUniform

Init initializes the instance.

func (SKUniform) InitWithName

func (u SKUniform) InitWithName(name string) SKUniform

Initializes a new uniform object.

name: The name used to identify the uniform variable; you use this name inside your shader to read the uniform variable’s value.

Return Value

An initialized uniform object.

Discussion

A uniform initialized with this method has no initial type and cannot be used in a shader until it is given an initial value. To set the initial value, use one of the properties defined in SKUniform. After its value is set, its SKUniform.UniformType property is set to match the uniform’s new type. Once set, the type may not be changed.

See: https://developer.apple.com/documentation/SpriteKit/SKUniform/init(name:)

func (SKUniform) InitWithNameFloat

func (u SKUniform) InitWithNameFloat(name string, value float32) SKUniform

Initializes a new uniform object that holds a floating-point number.

name: The name used to identify the uniform variable; you use this name inside your shader to read the uniform variable’s value.

value: The initial floating-point value for the uniform variable.

Return Value

An initialized uniform object whose type is set to SKUniformType.float.

See: https://developer.apple.com/documentation/SpriteKit/SKUniform/init(name:float:)-48rln

func (SKUniform) InitWithNameTexture

func (u SKUniform) InitWithNameTexture(name string, texture ISKTexture) SKUniform

Initializes a new uniform object that holds a reference to a texture.

name: The name used to identify the uniform variable; you use this name inside your shader to read the uniform variable’s value.

texture: The initial texture to use for the uniform variable.

Return Value

An initialized uniform object whose type is set to SKUniformType.texture.

See: https://developer.apple.com/documentation/SpriteKit/SKUniform/init(name:texture:)

func (SKUniform) Name

func (u SKUniform) Name() string

The uniform’s name.

Discussion

Your custom fragment shader uses this name to identify the variable. SpriteKit automatically declares the uniform variable for your shader.

See: https://developer.apple.com/documentation/SpriteKit/SKUniform/name

func (SKUniform) SetFloatValue

func (u SKUniform) SetFloatValue(value float32)

func (SKUniform) SetMatrixFloat2x2Value

func (u SKUniform) SetMatrixFloat2x2Value(value [2][2]float32)

func (SKUniform) SetMatrixFloat3x3Value

func (u SKUniform) SetMatrixFloat3x3Value(value [3][4]float32)

func (SKUniform) SetMatrixFloat4x4Value

func (u SKUniform) SetMatrixFloat4x4Value(value [4][4]float32)

func (SKUniform) SetTextureValue

func (u SKUniform) SetTextureValue(value ISKTexture)

func (SKUniform) SetVectorFloat2Value

func (u SKUniform) SetVectorFloat2Value(value [2]float32)

func (SKUniform) SetVectorFloat3Value

func (u SKUniform) SetVectorFloat3Value(value Vector_float3)

func (SKUniform) SetVectorFloat4Value

func (u SKUniform) SetVectorFloat4Value(value [4]float32)

func (SKUniform) TextureValue

func (u SKUniform) TextureValue() ISKTexture

The receiver’s value as a SpriteKit texture.

See: https://developer.apple.com/documentation/SpriteKit/SKUniform/textureValue

func (SKUniform) UniformType

func (u SKUniform) UniformType() SKUniformType

The uniform object’s data type.

Discussion

A uniform object’s type is set to SKUniformType.none until the first time that the uniform variable’s value is set; this happens automatically if you use an initialization method that provides an initial type and value. Once the uniform object is given an initial value, its type changes to that value’s type and thereafter cannot be changed.

See: https://developer.apple.com/documentation/SpriteKit/SKUniform/uniformType

type SKUniformClass

type SKUniformClass struct {
	// contains filtered or unexported fields
}

func GetSKUniformClass

func GetSKUniformClass() SKUniformClass

GetSKUniformClass returns the class object for SKUniform.

func (SKUniformClass) Alloc

func (sc SKUniformClass) Alloc() SKUniform

Alloc allocates memory for a new instance of the class.

func (SKUniformClass) Class

func (sc SKUniformClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKUniformType

type SKUniformType int

See: https://developer.apple.com/documentation/SpriteKit/SKUniformType

const (
	// SKUniformTypeFloat: Indicates that the uniform variable holds a 32-bit floating-point value.
	SKUniformTypeFloat SKUniformType = 1
	// SKUniformTypeFloatMatrix2: Indicates that the uniform variable holds a  matrix of four 32-bit floating-point values.
	SKUniformTypeFloatMatrix2 SKUniformType = 5
	// SKUniformTypeFloatMatrix3: Indicates that the uniform variable holds a  matrix of four 32-bit floating-point values.
	SKUniformTypeFloatMatrix3 SKUniformType = 6
	// SKUniformTypeFloatMatrix4: Indicates that the uniform variable holds a  matrix of four 32-bit floating-point values.
	SKUniformTypeFloatMatrix4 SKUniformType = 7
	// SKUniformTypeFloatVector2: Indicates that the uniform variable holds a vector of two 32-bit floating-point values.
	SKUniformTypeFloatVector2 SKUniformType = 2
	// SKUniformTypeFloatVector3: Indicates that the uniform variable holds a vector of three 32-bit floating-point values.
	SKUniformTypeFloatVector3 SKUniformType = 3
	// SKUniformTypeFloatVector4: Indicates that the uniform variable holds a vector of four 32-bit floating-point values.
	SKUniformTypeFloatVector4 SKUniformType = 4
	// SKUniformTypeNone: Indicates that the uniform variable does not currently hold any data.
	SKUniformTypeNone SKUniformType = 0
	// SKUniformTypeTexture: Indicates that the uniform variable holds a reference to a SpriteKit texture.
	SKUniformTypeTexture SKUniformType = 8
)

func (SKUniformType) String

func (e SKUniformType) String() string

type SKVideoNode

type SKVideoNode struct {
	SKNode
}

A graphical element that plays video content.

Overview

This class renders a video at a given size and location in your scene with no exposed player controls.

Creating a Video Node

Setting the Video Node’s Visual Properties

Controlling Video Playback

See: https://developer.apple.com/documentation/SpriteKit/SKVideoNode

func NewSKVideoNode

func NewSKVideoNode() SKVideoNode

NewSKVideoNode creates a new SKVideoNode instance.

func NewVideoNodeWithAVPlayer

func NewVideoNodeWithAVPlayer(player objectivec.IObject) SKVideoNode

Initializes a video node using an existing AVPlayer object.

player: A player object.

Return Value

An initialized video node.

Discussion

You can use the AVPlayer object to control playback.

Listing 1 shows, in Swift, how you can create a video node using the SKVideoNode.InitWithAVPlayer initializer.

Listing 1. Creating a video node with an AV Player

See: https://developer.apple.com/documentation/SpriteKit/SKVideoNode/init(avPlayer:)

func NewVideoNodeWithCoder

func NewVideoNodeWithCoder(aDecoder foundation.INSCoder) SKVideoNode

Tells you when to initialize a video node that was created from an archive.

Discussion

Do not call this initializer yourself; it is called by the system when you should intialize a video node that was created from an archive.

See: https://developer.apple.com/documentation/SpriteKit/SKVideoNode/init(coder:)

func NewVideoNodeWithFileNamed

func NewVideoNodeWithFileNamed(videoFile string) SKVideoNode

Initializes a video node using a video file stored in the app bundle.

videoFile: The name of the video file.

Return Value

An initialized video node.

See: https://developer.apple.com/documentation/SpriteKit/SKVideoNode/init(fileNamed:)

func NewVideoNodeWithURL

func NewVideoNodeWithURL(url foundation.NSURL) SKVideoNode

Initializes a video node using a URL.

url: The URL for the video to play.

Return Value

An initialized video node.

See: https://developer.apple.com/documentation/SpriteKit/SKVideoNode/init(url:)

func SKVideoNodeFromID

func SKVideoNodeFromID(id objc.ID) SKVideoNode

SKVideoNodeFromID constructs a SKVideoNode from an objc.ID.

A graphical element that plays video content.

func (SKVideoNode) AnchorPoint

func (v SKVideoNode) AnchorPoint() corefoundation.CGPoint

The point in the sprite that corresponds to the node’s position.

Discussion

You specify the anchor point using the unit coordinate space. The default value is `(0.5,0.5)`, which means that the video is centered on the node’s position.

See: https://developer.apple.com/documentation/SpriteKit/SKVideoNode/anchorPoint

func (SKVideoNode) Autorelease

func (v SKVideoNode) Autorelease() SKVideoNode

Autorelease adds the receiver to the current autorelease pool.

func (SKVideoNode) Init

func (v SKVideoNode) Init() SKVideoNode

Init initializes the instance.

func (SKVideoNode) InitWithAVPlayer

func (v SKVideoNode) InitWithAVPlayer(player objectivec.IObject) SKVideoNode

Initializes a video node using an existing AVPlayer object.

player: A player object.

player is a [*avfoundation.AVPlayer].

Return Value

An initialized video node.

Discussion

You can use the AVPlayer object to control playback.

Listing 1 shows, in Swift, how you can create a video node using the SKVideoNode.InitWithAVPlayer initializer.

Listing 1. Creating a video node with an AV Player

See: https://developer.apple.com/documentation/SpriteKit/SKVideoNode/init(avPlayer:)

func (SKVideoNode) InitWithFileNamed

func (v SKVideoNode) InitWithFileNamed(videoFile string) SKVideoNode

Initializes a video node using a video file stored in the app bundle.

videoFile: The name of the video file.

Return Value

An initialized video node.

See: https://developer.apple.com/documentation/SpriteKit/SKVideoNode/init(fileNamed:)

func (SKVideoNode) InitWithURL

func (v SKVideoNode) InitWithURL(url foundation.NSURL) SKVideoNode

Initializes a video node using a URL.

url: The URL for the video to play.

Return Value

An initialized video node.

See: https://developer.apple.com/documentation/SpriteKit/SKVideoNode/init(url:)

func (SKVideoNode) Pause

func (v SKVideoNode) Pause()

Pauses video playback.

See: https://developer.apple.com/documentation/SpriteKit/SKVideoNode/pause()

func (SKVideoNode) Play

func (v SKVideoNode) Play()

Starts video playback.

See: https://developer.apple.com/documentation/SpriteKit/SKVideoNode/play()

func (SKVideoNode) SetAnchorPoint

func (v SKVideoNode) SetAnchorPoint(value corefoundation.CGPoint)

func (SKVideoNode) SetSize

func (v SKVideoNode) SetSize(value corefoundation.CGSize)

func (SKVideoNode) Size

The dimensions of the video node, in points.

Discussion

The default value is the size of the video used to instantiate the node.

See: https://developer.apple.com/documentation/SpriteKit/SKVideoNode/size

type SKVideoNodeClass

type SKVideoNodeClass struct {
	// contains filtered or unexported fields
}

func GetSKVideoNodeClass

func GetSKVideoNodeClass() SKVideoNodeClass

GetSKVideoNodeClass returns the class object for SKVideoNode.

func (SKVideoNodeClass) Alloc

func (sc SKVideoNodeClass) Alloc() SKVideoNode

Alloc allocates memory for a new instance of the class.

func (SKVideoNodeClass) Class

func (sc SKVideoNodeClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKView

type SKView struct {
	appkit.NSView
}

A view subclass that renders a SpriteKit scene.

Overview

You present a scene by calling the view’s SKView.PresentScene method. When a scene is presented by the view, it alternates between running its simulation (which animates the content) and rendering the content for display. You can pause the scene by setting the view’s [SKView.Paused] property to true.

Displaying a Scene

Controlling the Timing of a Scene’s Rendering

Enabling Visual Statistics for Debugging

Converting Between View and Scene Coordinates

Snapshotting Nodes to a Texture

Instance Properties

See: https://developer.apple.com/documentation/SpriteKit/SKView

func NewSKView

func NewSKView() SKView

NewSKView creates a new SKView instance.

func SKViewFromID

func SKViewFromID(id objc.ID) SKView

SKViewFromID constructs a SKView from an objc.ID.

A view subclass that renders a SpriteKit scene.

func (SKView) AllowsTransparency

func (v SKView) AllowsTransparency() bool

A Boolean property that indicates whether the view is rendered using transparency.

Discussion

This property tells the drawing system as to how it should treat the view. If set to false, the drawing system treats the view as fully opaque, which allows the drawing system to optimize some drawing operations and improve performance. If set to true, the drawing system composites the view normally with other content. The default value of this property is false.

An opaque view is expected to fill its bounds with entirely opaque content—that is, the content should have an alpha value of 1.0. If the view is opaque and either does not fill its bounds or contains wholly or partially transparent content, the results are unpredictable. Always set the value of this property to false if the view is fully or partially transparent.

See: https://developer.apple.com/documentation/SpriteKit/SKView/allowsTransparency

func (SKView) Autorelease

func (v SKView) Autorelease() SKView

Autorelease adds the receiver to the current autorelease pool.

func (SKView) ConvertPointFromScene

func (v SKView) ConvertPointFromScene(point corefoundation.CGPoint, scene ISKScene) corefoundation.CGPoint

Converts a point from scene coordinates to view coordinates.

point: A point in scene coordinates.

scene: A scene.

Return Value

The same point in the view’s coordinate system.

Discussion

This method performs the coordinate conversion as if the scene is presented inside the view.

See: https://developer.apple.com/documentation/SpriteKit/SKView/convert(_:from:)

func (SKView) ConvertPointToScene

func (v SKView) ConvertPointToScene(point corefoundation.CGPoint, scene ISKScene) corefoundation.CGPoint

Converts a point from view coordinates to scene coordinates.

point: A point in view coordinates.

scene: A scene.

Return Value

The same point in the scene’s coordinate system.

Discussion

This method performs the coordinate conversion as if the scene is presented inside the view.

See: https://developer.apple.com/documentation/SpriteKit/SKView/convert(_:to:)

func (SKView) Delegate

func (v SKView) Delegate() objectivec.Object

A delegate that allows dynamic control of the view’s render rate.

See: https://developer.apple.com/documentation/SpriteKit/SKView/delegate

func (SKView) IgnoresSiblingOrder

func (v SKView) IgnoresSiblingOrder() bool

A Boolean value that indicates whether parent-child and sibling relationships affect the rendering order of nodes in the scene.

Discussion

The default value is false, which means that when multiple nodes share the same z position, those nodes are sorted and rendered in a deterministic order. Parents are rendered before their children, and siblings are rendered in array order. When this property is set to true, the position of the nodes in the tree is ignored when determining the rendering order. The rendering order of nodes at the same z position is arbitrary and may change every time a new frame is rendered. When sibling and parent order is ignored, SpriteKit applies additional optimizations to improve rendering performance. If you need nodes to be rendered in a specific and deterministic order, you must set the z position of those nodes.

See: https://developer.apple.com/documentation/SpriteKit/SKView/ignoresSiblingOrder

func (SKView) Init

func (v SKView) Init() SKView

Init initializes the instance.

func (SKView) IsAsynchronous

func (v SKView) IsAsynchronous() bool

A Boolean value that indicates whether the content is rendered asynchronously.

Discussion

The default value is true. If the value is false, the contents of this view are synchronized with Core Animation updates.

See: https://developer.apple.com/documentation/SpriteKit/SKView/isAsynchronous

func (SKView) IsPaused

func (v SKView) IsPaused() bool

A Boolean value that indicates whether the view’s scene animations are paused.

Discussion

If the value is true, the scene’s content is fixed onscreen. No actions are executed and no physics simulation is performed.

When an application moves from an active to an inactive state, [SKView.Paused] is automatically set to true. When an application returns to an active state, [SKView.Paused] is automatically set to its previous value.

See: https://developer.apple.com/documentation/SpriteKit/SKView/isPaused

func (SKView) PreferredFramesPerSecond

func (v SKView) PreferredFramesPerSecond() int

The animation frame rate that the view uses to render its scene.

Discussion

When your application sets its preferred frame rate, the view chooses a frame rate as close to that as possible based on the capabilities of the screen the view is displayed on. The actual frame rate chosen is usually a factor of the maximum refresh rate of the screen to provide a consistent frame rate. For example, if the maximum refresh rate of the screen is 60 frames per second, that is also the highest frame rate the view sets as the actual frame rate. However, if you ask for a lower frame rate, the view might choose 30, 20, or 15 frames per second, or another rate, as the actual frame rate.

Your application should choose a frame rate that it can consistently maintain.

The default value is 60 frames per second.

See: https://developer.apple.com/documentation/SpriteKit/SKView/preferredFramesPerSecond

func (SKView) PresentScene

func (v SKView) PresentScene(scene ISKScene)

Presents a scene.

scene: The scene to present.

Discussion

The new scene immediately replaces the current scene, if one exists.

See: https://developer.apple.com/documentation/SpriteKit/SKView/presentScene(_:)

func (SKView) PresentSceneTransition

func (v SKView) PresentSceneTransition(scene ISKScene, transition ISKTransition)

Transitions from the current scene to a new scene.

scene: The scene to present.

transition: A transition used to animate between the two scenes.

Discussion

If there is currently a scene presented by the view, the view’s SKView.Scene property is updated immediately, the transition is executed to swap between the scenes. Otherwise, the new scene is presented immediately and the transition property is ignored.

See: https://developer.apple.com/documentation/SpriteKit/SKView/presentScene(_:transition:)

func (SKView) Scene

func (v SKView) Scene() ISKScene

The scene currently presented by this view.

Discussion

The default value is `nil`.

You call SKView.PresentScene to assign a value to this property.

See: https://developer.apple.com/documentation/SpriteKit/SKView/scene

func (SKView) SetAllowsTransparency

func (v SKView) SetAllowsTransparency(value bool)

func (SKView) SetAsynchronous

func (v SKView) SetAsynchronous(value bool)

func (SKView) SetDelegate

func (v SKView) SetDelegate(value objectivec.Object)

func (SKView) SetDisableDepthStencilBuffer

func (v SKView) SetDisableDepthStencilBuffer(value bool)

func (SKView) SetIgnoresSiblingOrder

func (v SKView) SetIgnoresSiblingOrder(value bool)

func (SKView) SetPaused

func (v SKView) SetPaused(value bool)

func (SKView) SetPreferredFramesPerSecond

func (v SKView) SetPreferredFramesPerSecond(value int)

func (SKView) SetShouldCullNonVisibleNodes

func (v SKView) SetShouldCullNonVisibleNodes(value bool)

func (SKView) SetShowsDrawCount

func (v SKView) SetShowsDrawCount(value bool)

func (SKView) SetShowsFPS

func (v SKView) SetShowsFPS(value bool)

func (SKView) SetShowsFields

func (v SKView) SetShowsFields(value bool)

func (SKView) SetShowsNodeCount

func (v SKView) SetShowsNodeCount(value bool)

func (SKView) SetShowsPhysics

func (v SKView) SetShowsPhysics(value bool)

func (SKView) SetShowsQuadCount

func (v SKView) SetShowsQuadCount(value bool)

func (SKView) ShouldCullNonVisibleNodes

func (v SKView) ShouldCullNonVisibleNodes() bool

A Boolean value that indicates whether the view automatically culls non-visible nodes from the rendering tree.

Discussion

The default value is true, meaning that when the scene is rendered, the scene first searches the tree for invisible or offscreen nodes and culls them from the list of nodes to be rendered. Then the remaining (visible) nodes are processed and rendered. This is normally the desired behavior, because Scene Kit avoids expensive processing on nodes that cannot affect the final output. However, if your game is already managing the contents of the scene’s node tree (for example, by removing nodes from the tree when they are offscreen), you can set this to false to disable automatic scene culling. Disabling scene culling removes the performance overhead of this check, but each invisible or offscreen node present in the node tree reduces the performance of the renderer.

See: https://developer.apple.com/documentation/SpriteKit/SKView/shouldCullNonVisibleNodes

func (SKView) ShowsDrawCount

func (v SKView) ShowsDrawCount() bool

A Boolean value that indicates whether the view displays the number of drawing passes it needed to render the view.

Discussion

Some operations in SpriteKit can require multiple rendering passes to draw a scene’s content. For example, an SKEffectNode object must render its children into a separate buffer, apply the effect, and then perform another pass to blend those results into its parent node. These additional rendering passes use more rendering resources, reducing your game’s frame rate or increasing its total power consumption. Use the draw count as another piece of data when you profile your game’s performance.

See: https://developer.apple.com/documentation/SpriteKit/SKView/showsDrawCount

func (SKView) ShowsFPS

func (v SKView) ShowsFPS() bool

A Boolean value that indicates whether the view displays a frame rate indicator.

Discussion

The frame rate is a good indicator of the performance of your scene. Avoid creating scenes that have widely varying frame rates.

See: https://developer.apple.com/documentation/SpriteKit/SKView/showsFPS

func (SKView) ShowsFields

func (v SKView) ShowsFields() bool

A Boolean value that indicates whether the view displays information about physics fields in the scene.

Discussion

When this debugging option is enabled, each time a frame is rendered, an image is drawn behind your scene that shows the effects of any physics fields contained in the scene.

See: https://developer.apple.com/documentation/SpriteKit/SKView/showsFields

func (SKView) ShowsNodeCount

func (v SKView) ShowsNodeCount() bool

A Boolean value that indicates whether the view displays an overlay that shows physics bodies that are visible in the scene.

Discussion

When you enable this option, it shows the number of nodes currently in the scene’s node tree.

You may achieve additional performance gain by actually removing nodes from the node tree manually which are off screen. For example, in the case of SKView.ShouldCullNonVisibleNodes, there would be less nodes for SpriteKit to test every frame whether they’re on screen.

See: https://developer.apple.com/documentation/SpriteKit/SKView/showsNodeCount

func (SKView) ShowsPhysics

func (v SKView) ShowsPhysics() bool

A Boolean value that indicates whether the view displays physics-related debugging information.

Discussion

When this debugging option is enabled, each time a frame is rendered, an overlay image is drawn on top of your scene that shows the positions and shapes of any physics bodies visible in the scene.

See: https://developer.apple.com/documentation/SpriteKit/SKView/showsPhysics

func (SKView) ShowsQuadCount

func (v SKView) ShowsQuadCount() bool

A Boolean value that indicates whether the view displays the number of rectangles used to render the scene.

Discussion

SpriteKit converts the node tree into one or more rendering passes. Each rendering pass is rendered using a series of textured rectangles (quads). The SKView.ShowsQuadCount property allows you to see the total number of quads that were used to render the scene’s contents. Use this as another piece of data when you profile your game’s performance. In most cases, fewer quads is better.

See: https://developer.apple.com/documentation/SpriteKit/SKView/showsQuadCount

func (SKView) TextureFromNode

func (v SKView) TextureFromNode(node ISKNode) ISKTexture

Renders the contents of a node tree and returns the rendered image as a texture.

node: The node object that is the root node of the tree you want to render to the texture.

Return Value

A SpriteKit texture that holds the rendered image.

Discussion

The node being rendered does not need to appear in the view’s presented scene. The new texture is created with a size equal to the rectangle returned by the node’s SKNode.CalculateAccumulatedFrame method. If the node is not a scene node, it is rendered with a clear background color (`[“SKColor` `clear]`).

See: https://developer.apple.com/documentation/SpriteKit/SKView/texture(from:)

func (SKView) TextureFromNodeCrop

func (v SKView) TextureFromNodeCrop(node ISKNode, crop corefoundation.CGRect) ISKTexture

Renders a portion of a node’s contents and returns the rendered image as a texture.

node: The node object that is the root node of the tree you want to render to the texture.

crop: A rectangle in the node’s coordinate system that describes the area to be rendered.

Return Value

A SpriteKit texture that holds the rendered image.

Discussion

The node being rendered does not need to appear in the view’s presented scene. The new texture is created with a size equal to the size of the `crop` rectangle. If the node is not a scene node, it is rendered with a clear background color (`[“SKColor` `clear]`).

See: https://developer.apple.com/documentation/SpriteKit/SKView/texture(from:crop:)

type SKViewClass

type SKViewClass struct {
	// contains filtered or unexported fields
}

func GetSKViewClass

func GetSKViewClass() SKViewClass

GetSKViewClass returns the class object for SKView.

func (SKViewClass) Alloc

func (sc SKViewClass) Alloc() SKView

Alloc allocates memory for a new instance of the class.

func (SKViewClass) Class

func (sc SKViewClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKViewDelegate

type SKViewDelegate interface {
	objectivec.IObject
}

Methods to take custom control over the view’s render rate.

See: https://developer.apple.com/documentation/SpriteKit/SKViewDelegate

type SKViewDelegateConfig

type SKViewDelegateConfig struct {

	// Instance Methods
	// ViewShouldRenderAtTime — Specifies whether the view should render at the given time.
	ViewShouldRenderAtTime func(view SKView, time foundation.NSTimeInterval) bool
}

SKViewDelegateConfig holds optional typed callbacks for SKViewDelegate methods. Set non-nil fields to register the corresponding Objective-C delegate method. Methods with nil callbacks are not registered, so [NSObject.RespondsToSelector] returns false for them — matching the Objective-C delegate pattern exactly.

See Apple Documentation for protocol details.

type SKViewDelegateObject

type SKViewDelegateObject struct {
	objectivec.Object
}

SKViewDelegateObject wraps an existing Objective-C object that conforms to the SKViewDelegate protocol.

func NewSKViewDelegate

func NewSKViewDelegate(config SKViewDelegateConfig) SKViewDelegateObject

NewSKViewDelegate creates an Objective-C object implementing the SKViewDelegate protocol.

Each call registers a unique Objective-C class containing only the methods set in config. This means [NSObject.RespondsToSelector] works correctly for optional delegate methods — only non-nil callbacks are registered.

The returned SKViewDelegateObject satisfies the SKViewDelegate interface and can be passed directly to SetDelegate and similar methods.

See Apple Documentation for protocol details.

func SKViewDelegateObjectFromID

func SKViewDelegateObjectFromID(id objc.ID) SKViewDelegateObject

SKViewDelegateObjectFromID constructs a SKViewDelegateObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (SKViewDelegateObject) BaseObject

func (o SKViewDelegateObject) BaseObject() objectivec.Object

func (SKViewDelegateObject) ViewShouldRenderAtTime

func (o SKViewDelegateObject) ViewShouldRenderAtTime(view ISKView, time foundation.NSTimeInterval) bool

Specifies whether the view should render at the given time.

view: The SKView.

time: The target time.

Return Value

Return `true` to initiate an update and render for the target time. Return `false` to skip the update and render for the target time.

See: https://developer.apple.com/documentation/SpriteKit/SKViewDelegate/view(_:shouldRenderAtTime:)

type SKWarpGeometry

type SKWarpGeometry struct {
	objectivec.Object
}

A definition for a deformation of nodes that conform to SKWarpable.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpGeometry

func NewSKWarpGeometry

func NewSKWarpGeometry() SKWarpGeometry

NewSKWarpGeometry creates a new SKWarpGeometry instance.

func SKWarpGeometryFromID

func SKWarpGeometryFromID(id objc.ID) SKWarpGeometry

SKWarpGeometryFromID constructs a SKWarpGeometry from an objc.ID.

A definition for a deformation of nodes that conform to SKWarpable.

func (SKWarpGeometry) Autorelease

func (w SKWarpGeometry) Autorelease() SKWarpGeometry

Autorelease adds the receiver to the current autorelease pool.

func (SKWarpGeometry) EncodeWithCoder

func (w SKWarpGeometry) EncodeWithCoder(coder foundation.INSCoder)

func (SKWarpGeometry) Init

func (w SKWarpGeometry) Init() SKWarpGeometry

Init initializes the instance.

type SKWarpGeometryClass

type SKWarpGeometryClass struct {
	// contains filtered or unexported fields
}

func GetSKWarpGeometryClass

func GetSKWarpGeometryClass() SKWarpGeometryClass

GetSKWarpGeometryClass returns the class object for SKWarpGeometry.

func (SKWarpGeometryClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKWarpGeometryClass) Class

func (sc SKWarpGeometryClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKWarpGeometryGrid

type SKWarpGeometryGrid struct {
	SKWarpGeometry
}

A definition for a grid-based deformation of nodes that conform to SKWarpable.

Overview

An SKWarpGeometryGrid exposes a 2D array of source positions, and set of destination positions with matching size, that allow you to define which sections of a node should be translated from the source positions to the destination positions. Conceptually, this forms two grids—a source grid and a destination grid—where the visual warping is accomplished by stretching or shrinking each section of the node as the source positions of the grid interpolate to their corresponding destination positions.

Accessing or Setting Warp Geometry Grid Size

Accessing or Setting Grid Vertices

See: https://developer.apple.com/documentation/SpriteKit/SKWarpGeometryGrid

func NewSKWarpGeometryGrid

func NewSKWarpGeometryGrid() SKWarpGeometryGrid

NewSKWarpGeometryGrid creates a new SKWarpGeometryGrid instance.

func NewWarpGeometryGridWithCoder

func NewWarpGeometryGridWithCoder(aDecoder foundation.INSCoder) SKWarpGeometryGrid

Tells you when to intialize a grid that was loaded from an archive.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpGeometryGrid/init(coder:)

func NewWarpGeometryGridWithColumnsRows

func NewWarpGeometryGridWithColumnsRows(cols int, rows int) SKWarpGeometryGrid

Creates a warp geometry grid of a specified size.

cols: The number of columns in the grid.

rows: The number of rows in the grid.

Return Value

A new warp geometry grid object.

Discussion

Creating a warp geometry grid without explicit source and destination positions automatically generates the required position arrays. For example, a 2 column by 2 row grid would create two arrays containing nine positions each, beginning at `[0,0]` - for the bottom left position - and ending at `[1,1]` - for the top left position.

[Table data omitted]

See: https://developer.apple.com/documentation/SpriteKit/SKWarpGeometryGrid/init(columns:rows:)

func SKWarpGeometryGridFromID

func SKWarpGeometryGridFromID(id objc.ID) SKWarpGeometryGrid

SKWarpGeometryGridFromID constructs a SKWarpGeometryGrid from an objc.ID.

A definition for a grid-based deformation of nodes that conform to SKWarpable.

func (SKWarpGeometryGrid) Autorelease

func (w SKWarpGeometryGrid) Autorelease() SKWarpGeometryGrid

Autorelease adds the receiver to the current autorelease pool.

func (SKWarpGeometryGrid) DestPositionAtIndex

func (w SKWarpGeometryGrid) DestPositionAtIndex(index int) [2]float32

Returns the destination position of a vertex.

index: The index of the position vertex to query.

Return Value

The normalized position of the specified vertex in `destPositions`.

Discussion

The specified index must be between 0 and the warp geometry grid’s SKWarpGeometryGrid.VertexCount `- 1`.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpGeometryGrid/destPosition(at:)

func (SKWarpGeometryGrid) Init

Init initializes the instance.

func (SKWarpGeometryGrid) NumberOfColumns

func (w SKWarpGeometryGrid) NumberOfColumns() int

The object’s number of columns.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpGeometryGrid/numberOfColumns

func (SKWarpGeometryGrid) NumberOfRows

func (w SKWarpGeometryGrid) NumberOfRows() int

The object’s number of rows.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpGeometryGrid/numberOfRows

func (SKWarpGeometryGrid) SourcePositionAtIndex

func (w SKWarpGeometryGrid) SourcePositionAtIndex(index int) [2]float32

Returns the source position of a vertex.

index: The index of the position vertex to query.

Return Value

The normalized position of the specified vertex in `sourcePositions`.

Discussion

The specified index must be between 0 and the warp geometry grid’s SKWarpGeometryGrid.VertexCount `- 1`.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpGeometryGrid/sourcePosition(at:)

func (SKWarpGeometryGrid) VertexCount

func (w SKWarpGeometryGrid) VertexCount() int

The object’s total number of vertices.

Discussion

The number of vertices is the same as `(```numberOfColumns“ `+ 1) * (```numberOfRows“ `+ 1)`.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpGeometryGrid/vertexCount

type SKWarpGeometryGridClass

type SKWarpGeometryGridClass struct {
	// contains filtered or unexported fields
}

func GetSKWarpGeometryGridClass

func GetSKWarpGeometryGridClass() SKWarpGeometryGridClass

GetSKWarpGeometryGridClass returns the class object for SKWarpGeometryGrid.

func (SKWarpGeometryGridClass) Alloc

Alloc allocates memory for a new instance of the class.

func (SKWarpGeometryGridClass) Class

func (sc SKWarpGeometryGridClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type SKWarpable

type SKWarpable interface {
	objectivec.IObject

	// The maximum number of subdivision iterations used to generate the final vertices.
	//
	// See: https://developer.apple.com/documentation/SpriteKit/SKWarpable/subdivisionLevels
	SubdivisionLevels() int
	SetSubdivisionLevels(value int)

	// The warp geometry used to define the distortion.
	//
	// See: https://developer.apple.com/documentation/SpriteKit/SKWarpable/warpGeometry
	WarpGeometry() ISKWarpGeometry
	SetWarpGeometry(value ISKWarpGeometry)
}

A protocol for objects that can be warped and animated by an SKWarpGeometry(<https://developer.apple.com/documentation/SpriteKit/SKWarpGeometry>).

See: https://developer.apple.com/documentation/SpriteKit/SKWarpable

type SKWarpableObject

type SKWarpableObject struct {
	objectivec.Object
}

SKWarpableObject wraps an existing Objective-C object that conforms to the SKWarpable protocol.

func SKWarpableObjectFromID

func SKWarpableObjectFromID(id objc.ID) SKWarpableObject

SKWarpableObjectFromID constructs a SKWarpableObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (SKWarpableObject) BaseObject

func (o SKWarpableObject) BaseObject() objectivec.Object

func (SKWarpableObject) SetSubdivisionLevels

func (o SKWarpableObject) SetSubdivisionLevels(value int)

func (SKWarpableObject) SetWarpGeometry

func (o SKWarpableObject) SetWarpGeometry(value ISKWarpGeometry)

func (SKWarpableObject) SubdivisionLevels

func (o SKWarpableObject) SubdivisionLevels() int

The maximum number of subdivision iterations used to generate the final vertices.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpable/subdivisionLevels

func (SKWarpableObject) WarpGeometry

func (o SKWarpableObject) WarpGeometry() ISKWarpGeometry

The warp geometry used to define the distortion.

See: https://developer.apple.com/documentation/SpriteKit/SKWarpable/warpGeometry

type UnsafePointerUintptrHandler

type UnsafePointerUintptrHandler = func(unsafe.Pointer, uintptr)

UnsafePointerUintptrHandler handles A block to be called when the texture can be safely modified.

  • pixelData: A pointer to the start of the current texture data.
  • lengthInBytes: The length of the texture data in bytes.

Used by:

type VectorFloat3

type VectorFloat3 = Vector_float3

VectorFloat3 is a Go-name alias for Vector_float3.

type Vector_float3

type Vector_float3 = [3]float32

Vector_float3 is a floating point vector type used to perform physics calculations.

See: https://developer.apple.com/documentation/SpriteKit/vector_float3

type VoidHandler

type VoidHandler = func()

VoidHandler handles A completion block called when the action completes.

Used by:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL