[英]How does SKAction scaleBy:duration: method works under the hood?
Need to have a way to "scale by" without using an SKAction, but it should mimic changes to SKNode as scaleBy:duration:
method does. 需要有一种无需使用SKAction即可“按比例缩放”的方法,但它应该像scaleBy:duration:
方法那样模仿SKNode的更改。
How does scale factor changes on the node which was "scaledBy"? 比例因子在“ scaledBy”节点上如何变化?
My guess is that there's some kind of action manager running its own update:
method (like what SKScene
has) and updates the appropriate properties (in this case xScale
and yScale
) of the node attached to the action on each callback. 我的猜测是,某种动作管理器正在运行自己的update:
方法(如SKScene
具有的),并更新每个回调上附加到该动作的节点的适当属性(在本例中为xScale
和yScale
)。
The update:
method takes an NSTimeInterval
parameter that can be used to know how far along the animation to progress and when to finish. update:
方法采用NSTimeInterval
参数,该参数可用于了解动画进行的距离以及何时完成。
EDIT 编辑
In cocos2d-x, the CCScaleBy
action is a subclass of CCScaleTo
. 在cocos2d-x,则CCScaleBy
行动的一个子类CCScaleTo
。 The update method goes something like this: 更新方法如下所示:
void CCScaleTo::update(float time)
{
setScaleX(m_fStartScaleX + m_fDeltaX * time);
setScaleY(m_fStartScaleY + m_fDeltaY * time);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.