CCCallFunC, CCCallBlock, Help!!!

CCCallFunC, CCCallBlock, Help!!!
0.0 0


Hello everyone!
Now, I’ve got 2 questions,
1-Is there any way to send 2 or more parameters???
2-I was wondering if there’s any way to save some memory and do both with one action?

@ - (void) spriteMoveFinished:(id)sender @
CCLOG(“Sprite move finished”);@
Sprites *sprite = (Sprites *)sender;

[self animateSprite:sprite];


- (void) animateSprite:(Sprites *)zprite
CCLOG(“We’re animating sprite”):@

Sprites *sprite = nil;

sprite = zprite;

int actualDuration = sprite.speed; //property of sprite

// Create the actions

id actionMove = [CCMoveBy actionWithDuration:actualDuration
@ position:ccpMult(ccpNormalize(ccpSub(_player.position,sprite.position)), 10)];@

id actionMoveDone = [CCCallFuncN actionWithTarget:self selector:selector(spriteMoveFinished:)]; @
[sprite runAction:
[CCSequence actions:actionMove, actionMoveDone, nil]];


- (void) spriteLabelMoveFinished:(CCLabelTTF *)sender

[self animateSpriteLabel:sender];

-(void)animateEnemyHP:(CCLabelTTF *)zpriteLabel

CCLabelTTF *spriteLabel = nil;

spriteLabel = zpriteLabel;

int actualDuration = spriteSpeed; //another property

id actionMove = [CCMoveBy actionWithDuration:actualDuration position:ccpMult(ccpNormalize(ccpSub(_player.position,spriteLabel.position)), 10)];

id actionMoveDone = [CCCallFuncN actionWithTarget:self selector:selector(spriteLabelMoveFinished:)];@
[spriteLabel runAction:
[CCSequence actions:actionMove, actionMoveDone, nil]];


Now, this 4 functions are kind of obvious.

1-Move Sprite if sprite ended moving, we move it again.
2-Move Label towards the same position with the same speed, if the label finishes moving, we move it again.

They both go to the same place. Is there a way to mix this 4 functions into 2? If so, how can I send 2 parameters when the action finishes?
Thanks for your help and your time, have a great day!

I’ve got 2 propositions that I quite don’t understand…

>try to simplify, that will undoubtedly save ‘memory’ … I normally do this with a class that extends CCNode, for example my SoldierMapLayout class does. In the SoldierMapLayout node, i put in the soldier stance animation (idle, walking right-left-up-down), a health bar, an optional label, a ‘HP hit’ animation when appropriate, an ‘XP gained’ animation when appropriate, a ‘poison cloud’ over the head, etc… and i move the node when the whole thing needs to move. A single animation, with a single call back on move completion.>

Which I would like to implement, but Im a little fuzzy on how this could be done.

and another person proposed to me to use CCCallBlock

>To send more than one parameter, instead CCCallFunc you can use CCCallBlock and call a block of code. Inside the block, you can call your method (selector) with any parameters you want.>
but Im not that familiar with it if you could help me out with an example that would be awesome!

Thanks your for your time and I hope you have a great day.