私はCAEmitterLayer
s とCAEmitterCell
s に、親の持続時間の途中からアニメーションを開始させようとしています。これはまったく可能ですか?beginTime
とプロパティをいじってみましたが、timeOffset
うまくいかないようです。
後世のためにいくつかのコードを追加しました:(エミッターを5秒で開始したいとしましょう)
CAEmitterLayer *emitter = [CAEmitterLayer new];
// emitter.beginTime = -5.0f; // I tried this
// emitter.timeOffset = 5.0f; // I also tried this, with beginTime = 0.0, and with beginTime = AVCoreAnimationBeginTimeAtZero
/* set some other CAEmitterLayer properties */
CAEmitterCell *cell = [CAEmitterCell new];
// cell.beginTime = -5.0f; // Then I saw that CAEmitterCell implements CAMediaTiming protocol so I tried this
// cell.timeOffset = 5.0f; // and this
/* set some other CAEmitterCell properties */
emitter.emitterCells = @[cell];
[viewLayer addSubLayer:emitter];
それでも、アニメーションはエミッターがパーティクルを生成するところから始まります。
私がやろうとしていることを説明するために再度編集しました:
雨をアニメーション化する があるCAEmitterLayer
としましょう。そのため、画面の上部から始まる「落下」アニメーションを実行するようにセルを設定します。レンダリングの開始時に、「まだ雨が降っていない」状態で開始したくありません。画面がすでに雨で覆われているところから始めたいと思います。