Skip to content

Commit

Permalink
Fix issue where the emitter would not start
Browse files Browse the repository at this point in the history
Setting the `beginTime` on the `CAEmitterLayer` would sometimes result in it not starting. If you set the `beginTime` on the `CAEmitterCell`, it starts properly.
  • Loading branch information
jbuckner committed Apr 17, 2019
1 parent c874004 commit 819e38e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/Common/Cheers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ open class CheerView: UIView {
and: pickImages()
)

let beginTime = CACurrentMediaTime()

let cells: [CAEmitterCell] = combinations.reduce([]) { (accum, combination) in
let cell = CAEmitterCell()
cell.birthRate = 20
cell.beginTime = beginTime
cell.lifetime = 20.0
cell.lifetimeRange = 10
cell.velocity = 250 * yMultiplier
Expand All @@ -74,7 +77,6 @@ open class CheerView: UIView {
}

emitter.emitterCells = cells
emitter.beginTime = CACurrentMediaTime()

config.customize?(cells)

Expand Down

0 comments on commit 819e38e

Please sign in to comment.