1

I want to run actions for a sprite like below:

CCRotateTo* actionTo = CCRotateTo::create(0.2, 0.0f, -90.0f);

CCRotateTo* actionToBack = CCRotateTo::create(0.2, 0.0f, -180.0f);

CCFiniteTimeAction* actionChangeTexture = CCCallFuncN::create(this,
    callfuncN_selector(Paddle::spriteChangeTextture));**//*i want to send value here***

runAction(CCSequence::create(actionTo,actionChangeTexture,actionToBack, NULL));


void Paddle::spriteChangeTextture(CCNode* sender) {
  ***//i want to using parameter here, it's integer value***
}

How can i send value in function call. Please help

Wez Sie Tato
  • 1,186
  • 12
  • 33
Lex Nguyen
  • 401
  • 11
  • 23

1 Answers1

0

You can use tag in the CCNode. In your node setTag with your value. When your action was called, you can simply get yout value from sender's tag.

CCRotateTo* actionTo = CCRotateTo::create(0.2, 0.0f, -90.0f);

CCRotateTo* actionToBack = CCRotateTo::create(0.2, 0.0f, -180.0f);

CCFiniteTimeAction* actionChangeTexture = CCCallFuncN::create(this,
    callfuncN_selector(Paddle::spriteChangeTextture));
int value;
setTag(value); // <-------- 
runAction(CCSequence::create(actionTo,actionChangeTexture,actionToBack, NULL));


void Paddle::spriteChangeTextture(CCNode* sender) {

int value = sender->getTag; // <------------
}

Another option is use CCCallFuncND when you can pass the Node and Data as parameters, but I think option with tag is simplier :)

Wez Sie Tato
  • 1,186
  • 12
  • 33