首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CAEmitterLayer negative有可能吗?

CAEmitterLayer negative有可能吗?
EN

Stack Overflow用户
提问于 2012-08-21 09:39:13
回答 1查看 959关注 0票数 7

我正在尝试让CAEmitterLayers和CAEmitterCells从它们的父进程中间的某个位置开始他们的动画。这到底有没有可能?我尝试使用beginTimetimeOffset属性,但似乎无法正常工作。

为后人添加了一些代码:(假设我希望发射器在第5秒开始)

代码语言:javascript
复制
    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来模拟下雨,所以我设置了单元格来做一个从屏幕顶部开始的“下落”动画。在渲染开始的时候,我不想在“还没有下雨”的状态下开始渲染。我想从屏幕已经被雨覆盖的地方开始。

EN

回答 1

Stack Overflow用户

发布于 2012-08-21 11:50:27

beginTime不是相对于现在的。您需要获取相对于当前图层时间空间的当前时间,可以使用CACurrentMediaTime()函数获取。所以在你的例子中,你会这样做:

代码语言:javascript
复制
emitter.beginTime = CACurrentMediaTime() + 5.f;
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12047402

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档