1

我想为如下精灵运行动作:

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***
}

我如何在函数调用中发送值。请帮忙

4

1 回答 1

0

您可以在 CCNode 中使用标签。在您的节点 setTag 中使用您的值。当您的操作被调用时,您可以简单地从发件人的标签中获取您的价值。

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; // <------------
}

当您可以将节点和数据作为参数传递时,另一个选项是使用 CCCallFuncND,但我认为带有标签的选项更简单:)

于 2014-08-23T06:49:14.877 回答