SKEmitterNode
A source of various particle effects.
Declaration
class SKEmitterNodeMentioned in
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.
Topics
First Steps
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
particleSpeedparticleSpeedRangeemissionAngleemissionAngleRangexAccelerationyAccelerationparticleZPositionSpeed
Adjusting a Particle’s Rotation
Scaling Particles by a Factor
Changing a Particle’s Source Image and Size
Configuring Particle Color
particleColorSequenceparticleColorparticleColorAlphaRangeparticleColorBlueRangeparticleColorGreenRangeparticleColorRedRangeparticleColorAlphaSpeedparticleColorBlueSpeedparticleColorGreenSpeedparticleColorRedSpeed
Controlling How the Texture is Blended with Particle Color
particleColorBlendFactorSequenceparticleColorBlendFactorparticleColorBlendFactorRangeparticleColorBlendFactorSpeed
Blending Particles with the Framebuffer
Animating Particles
Applying Physics Fields to the Particles
Taking Full Control of Particle Drawing with a Shader
Getting Started with Particle ShadersshaderattributeValuessetValue(_:forAttribute:)value(forAttributeNamed:)