我真的似乎没有等待 SKAction 的范围
I really don't seem to get the wait SKAction for a range
抱歉,如果这听起来太原始了。我似乎真的不明白 wait SKAction 如何在一个范围内工作。我看过一些帖子,但我没有清楚地解释(据我所知)如何计算我的范围。例如,我看到以下范围:
SKAction.wait(forDuration: 2.5, withRange: 3.0), //Wait between 1.0 and 4.0 seconds
SKAction.wait(forDuration: 0.65, withRange: 0.7),//Wait between 0.3 and 1.0 seconds
我不确定如何协调上述内容以计算 1.0 到 2.0 秒和 0.2 到 0.8 秒之间的等待时间。
forDuration
时间是动作的平均时间。 withRange
时间给出了 forDuration
时间两侧的公差。
将 withRange
时间除以 2,然后 add/subtract 它与 forDuration
时间。
SKAction.wait(forDuration: 2.5, withRange: 3.0), //Wait between 1.0 and 4.0 seconds
//3.0 / 2 = 1.5; 2.5 - 1.5 = 1.0; 2.5 + 1.5 = 4.0
SKAction.wait(forDuration: 0.65, withRange: 0.7),//Wait between 0.3 and 1.0 seconds
//0.7 / 2 = 0.35; 0.65 - 0.35 = 0.3; 0.65 + .035 = 1.0
因此,如果您希望等待时间介于 1.0 到 2.0 秒之间,请使用
SKAction.wait(forDuration: 1.5, withRange: 1.0)
对于 0.2 到 0.8 秒之间的时间,使用
SKAction.wait(forDuration: 0.5, withRange: 0.6)
计算 forDuration 和 withRange 值的通用公式是这样的:
forDuration = t_min + (t_max - t_min) / 2
withRange = (t_max - t_min)
抱歉,如果这听起来太原始了。我似乎真的不明白 wait SKAction 如何在一个范围内工作。我看过一些帖子,但我没有清楚地解释(据我所知)如何计算我的范围。例如,我看到以下范围:
SKAction.wait(forDuration: 2.5, withRange: 3.0), //Wait between 1.0 and 4.0 seconds
SKAction.wait(forDuration: 0.65, withRange: 0.7),//Wait between 0.3 and 1.0 seconds
我不确定如何协调上述内容以计算 1.0 到 2.0 秒和 0.2 到 0.8 秒之间的等待时间。
forDuration
时间是动作的平均时间。 withRange
时间给出了 forDuration
时间两侧的公差。
将 withRange
时间除以 2,然后 add/subtract 它与 forDuration
时间。
SKAction.wait(forDuration: 2.5, withRange: 3.0), //Wait between 1.0 and 4.0 seconds
//3.0 / 2 = 1.5; 2.5 - 1.5 = 1.0; 2.5 + 1.5 = 4.0
SKAction.wait(forDuration: 0.65, withRange: 0.7),//Wait between 0.3 and 1.0 seconds
//0.7 / 2 = 0.35; 0.65 - 0.35 = 0.3; 0.65 + .035 = 1.0
因此,如果您希望等待时间介于 1.0 到 2.0 秒之间,请使用
SKAction.wait(forDuration: 1.5, withRange: 1.0)
对于 0.2 到 0.8 秒之间的时间,使用
SKAction.wait(forDuration: 0.5, withRange: 0.6)
计算 forDuration 和 withRange 值的通用公式是这样的:
forDuration = t_min + (t_max - t_min) / 2
withRange = (t_max - t_min)