What are the differences between ccScaleBy and ccScaleTo in cocos2d?

I scale my sprite object to cocos2d using the CCScaleTo method. This 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 works great.

I do not know the difference between ccScaleByand CCScaleTo, and also how to use the "reverse" method. Can someone explain this please?

+5
source share
1 answer

CCScaleToscales the node / sprite to an absolute scale factor, and CCScaleByscales it by a factor relative to the current scale.

For example, suppose node has a scale 0.25:

  • [CCScaleTo actionWithDuration:0.5 scale:2.0]change the scale to 2.0(just ignores the current scale)

  • [CCScaleBy actionWithDuration:0.5 scale:2.0] 0.5 (0.25 * 2.0)

reverse CCAction, . : [[CCScaleBy actionWithDuration:0.5 scale:2.0] reverse] [CCScaleBy actionWithDuration:0.5 scale:0.5], [[CCScaleBy actionWithDuration:0.5 scale:4.0] reverse] [CCScaleBy actionWithDuration:0.5 scale:0.25]

+18

All Articles