开发者

What is the difference between ccScaleBy and ccScaleTo in cocos2d?

开发者 https://www.devze.com 2023-03-26 15:53 出处:网络
I am scaling my sprite object in cocos2d using the CCScaleTo method. It is not perfect scaling so I use this code:

I am scaling my sprite object in cocos2d using the CCScaleTo method. It is not perfect scaling so I use this code:

id action1=[CCScaleTo actionWithDuration:0.5 scale:1.25];
id action2=[CCScaleBy actionWithDuration:0.5 scale:.25];
id action3=[CCScaleTo actionWithDuration:0.5 scale:1.25];
id action4=[CCScaleTo actionWithDuration:0.5 scale:.25];

[timeUpImg runAction:[CCSequence actions:action1,action2,action3,action4,nil]];

This is working perfectly.

I don't know the difference between cc开发者_JAVA百科ScaleBy and CCScaleTo and also how to use the "reverse" method. Can someone explain it please?


CCScaleTo scales the node/sprite to an absolute scale factor while CCScaleBy scales it by a factor relative to current scale.

For example, suppose a node currently has scale 0.25:

  • [CCScaleTo actionWithDuration:0.5 scale:2.0] will modify the scale to 2.0 (simply ignores the current scale)

  • [CCScaleBy actionWithDuration:0.5 scale:2.0] will modify the scale to 0.5 (0.25 * 2.0)

On the second question, the reverse method returns an instance of CCAction subclass that gives the reverse effect of the original action. For example: [[CCScaleBy actionWithDuration:0.5 scale:2.0] reverse] will return [CCScaleBy actionWithDuration:0.5 scale:0.5], and [[CCScaleBy actionWithDuration:0.5 scale:4.0] reverse] will return [CCScaleBy actionWithDuration:0.5 scale:0.25]

0

精彩评论

暂无评论...
验证码 换一张
取 消