简体   繁体   中英

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.

How does scale factor changes on the node which was "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.

The update: method takes an NSTimeInterval parameter that can be used to know how far along the animation to progress and when to finish.

EDIT

In cocos2d-x, the CCScaleBy action is a subclass of 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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM