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 ccScaleBy and CCScaleTo and also how to use the “reverse” method. Can someone explain it please?
CCScaleToscales the node/sprite to an absolute scale factor whileCCScaleByscales 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 to2.0(simply ignores the current scale)[CCScaleBy actionWithDuration:0.5 scale:2.0]will modify the scale to0.5(0.25 * 2.0)On the second question, the
reversemethod returns an instance ofCCActionsubclass 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]