- Prototope Documentation
- Animator
- Border
- CameraLayer
- CameraPosition
- Color
- Gesture
- Heartbeat
- Image
- Layer
- LayerAnimatorStore
- Math
- PanGesture
- Particle
- ParticleEmitter
- ParticlePreset
- Point
- Rect
- Shadow
- Size
- Sound
- TapGesture
- Timestamp
- TouchSample
- TouchSequence
- Tunable
- View as:
- Swift
- JavaScript
ParticleEmitter
A particle emitter shows one or more kinds of Particles, and can show them in different formations.
The general strategy here is as follows:
// make a sunny expanse
var playa = Layer()
playa.size = Size(width: 300, height: 200)
Layer.root.addLayer(playa)
// create a Particle from a stack of 'benjamin's and
// with a preset of .Sparkle
let rain = Particle(image: "benjamin", preset: .Sparkle)
// make an emitter that always makes it rain
let sparklePony = ParticleEmitter(particle: rain)
// put our sparklepony on our sunny expanse
playa.addParticleEmitter(sparklePony)
Once you add the ParticleEmitter
to a layer, it will emit particles continually until you remove it.
Although you need an emitter to ‘make it rain,’ you should look at Particle
instead to get details on how to style out your fat wads of Benjamins.
Method reference
-
⚓
public init(particles: [Particle])
Creates a particle emitter with an array of particles.
-
⚓
public convenience init(particle: Particle)
Creates a particle emitter with one kind of particle.
-
Variables
-
⚓
public var birthRate: Double
How often new baby particles are born.
-
⚓
public var renderMode: String
The render mode of the emitter.
In particular, CAEmitterLayer defines the following:
let kCAEmitterLayerPoints: NSString!
- Particles are emitted from points on the particle emitter.
let kCAEmitterLayerOutline: NSString!
- Particles are emitted from the outline of the particle emitter.
let kCAEmitterLayerSurface: NSString!
- Particles are emitted from the surface of the particle emitter.
let kCAEmitterLayerVolume: NSString!
- Particles are emitted from the a position within the particle emitter.
The default is
kCAEmitterLayerUnordered
. -
⚓
public var shape: String
The shape of the emitter. c.f., CAEmitterLayer for valid strings.
In particular, CAEmitterLayer defines:
let kCAEmitterLayerPoint: NSString!
let kCAEmitterLayerLine: NSString!
let kCAEmitterLayerRectangle: NSString!
let kCAEmitterLayerCuboid: NSString!
let kCAEmitterLayerCircle: NSString!
let kCAEmitterLayerSphere: NSString!
Again, see the class reference for more information.
-
⚓
public var size: Size
Determines the size of the particle emitter shape.
-
⚓
public var position: Point
The position of the emitter. The Point where particles are birthed from.
-
⚓
public var x: Double
The x position of the emitter. This is a shortcut for
position
. -
⚓
public var y: Double
The y position of the emitter. This is a shortcut for
position
.