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?
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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With