CCActionTween: how to set the key property to Sprites position?


#1

From reading the docs on CCActionTween I can see that the second parameter to the create() function is a string key value for the variable that will be tweened.

Instead of a string key value, why don’t you just pass a pointer to the variable to be tweened? I am guessing the answer is that you are using the string key as a safety check in case the variable goes out of scope.

But then if I have a CCSprite, how would I provide a key to tween the X position?

CCSprite* mySprite = CCSprite::createWithSpriteFrameName("mySprite.png");
mySprite ->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

Now what?

CCActionTween *tweenX = CCActionTween::create(500, "???", 0, visibleSize.width);