【问题标题】:What do they mean by "the timespace of the animation's layer" and "in the local active time"?“动画层的时间空间”和“在本地活动时间”是什么意思?
【发布时间】:2009-07-23 00:27:18
【问题描述】:

他们说:

计时协议提供了手段 开始某个动画的 持续时间的秒数 使用两个属性:beginTime 和 时间偏移。 beginTime 指定 进入的秒数 动画应该开始的持续时间 并缩放到 动画的图层。时间偏移 指定一个额外的偏移量,但 以当地活动时间为准。两个都 值被组合以确定 最终起始偏移量。

我知道时空。但是我在这里很难理解他们的话。

“缩放到动画层的时间空间。”

假设我有这个:

  • 动画速度 = 1.0
  • 层动画视图的速度 = 2.0
  • superlayer 的速度 = 2.0
  • 开始时间 = 1.0

那么它会在 0.25 秒后实时开始吗? (双倍超层速度,它使子层速度翻倍,所以我们有四倍速。动画师的本地速度是 1。所以仍然是四倍速。)。

并且 timeOffset 表示“在本地活动时间”。他们的意思是时间被速度扭曲了?即如果 animator 对象的 speed 属性为 1.0,这就是这里的本地活动时间?

本地活动时间对我来说真的意味着很多不同的事情。例如时钟时间,或整个时间空间层次结构中的时间它如何影响底部的时间。如果有人可以在这里指出细节,那就太好了。

【问题讨论】:

  • 这是一个 iPhone 问题。所以苹果;)

标签: iphone cocoa-touch uikit core-animation timespace


【解决方案1】:

查看核心动画的标题;特别是 CAMediaTiming.h:

/* The CAMediaTiming protocol is implemented by layers and animations, it
 * models a hierarchical timing system, with each object describing the
 * mapping from time values in the object's parent to local time.
 *
 * Absolute time is defined as mach time converted to seconds. The
 * CACurrentMediaTime function is provided as a convenience for querying the
 * current absolute time. 
 * 
 * The conversion from parent time to local time has two stages:
 *
 * 1. conversion to "active local time". This includes the point at
 * which the object appears in the parent's timeline, and how fast it
 * plays relative to the parent.
 *
 * 2. conversion from active to "basic local time". The timing model
 * allows for objects to repeat their basic duration multiple times,
 * and optionally to play backwards before repeating. */

另外(来自属性上的 cmets)

/* The rate of the layer. Used to scale parent time to local time, e.g.
 * if rate is 2, local time progresses twice as fast as parent time.
 * Defaults to 1. */

@property float speed;

/* Additional offset in active local time. i.e. to convert from parent
 * time tp to active local time t: t = (tp - begin) * speed + offset.
 * One use of this is to "pause" a layer by setting `speed' to zero and
 * `offset' to a suitable value. Defaults to 0. */

@property CFTimeInterval timeOffset;

看来你的解释是正确的。

【讨论】:

  • 这对我来说是关键:t = (tp - begin) * speed + offset。使用这个我已经能够将时间从 CACurrentMediaTime() 转换为动画的本地时间。
猜你喜欢
  • 2016-03-11
  • 1970-01-01
  • 2012-03-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-18
  • 2019-02-27
相关资源
最近更新 更多