views:

140

answers:

1

I have a small doubt in CCAnimation. Is there any difference between the code1 and code 2 in performance ?

code1:

id Action1 = [CCAnimate actionWithAnimation: numberAnimation restoreOriginalFrame:NO];
        id Action2 = [CCFadeOut actionWithDuration:0.1f];
        id Action3 = [CCCallFunc actionWithTarget:self     selector:@selector(Method1:)];
        [player runAction: [CCSequence actions:Action1, Action2, Action3, nil]];

code2:

[player runAction: [CCSequence actions:  [CCAnimate actionWithAnimation: numberAnimation restoreOriginalFrame:NO],  [CCFadeOut actionWithDuration:0.1f], [CCCallFunc actionWithTarget:self selector:@selector(enemyGunDrawMethod:)], nil ] ];`

Which is the better way to write and please explain why ?
Thank You.

A: 

The performance difference is not worth worrying about, in most cases. I'd go with code1 because it is more readable.

The main difference is in terms of memory. Three pointers are allocated in code1 that aren't in code2. These pointers are short lived and relatively small. After compiler optimizations, code1 and code2 may be equivalent.

Colin Gislason
thank You Colin.So, leaving about the readability we can use either one of them.
srikanth rongali