سؤال

and merry Christmas !

My question is about cocos2D, and how to do a translation in cocos2D. In "classic" objective C, I would have done :

myAnimation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
myAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
myAnimation.toValue = [NSNumber numberWithFloat:200.0f];
myAnimation.duration = t;
myAnimation.repeatCount = 1;
[myUIImageView.layer addAnimation:myAnimation forKey:@"myAnimation"];

But i don't find the equivalent when I tried to make an action :

id action = [CC… ?];

Thanks !

هل كانت مفيدة؟

المحلول

I think you may be looking for members of the CCAction class.

For example, CCMoveTo will move a CCNode from its current position to a new position over a period of time. CCMoveBy will move a CCNode by a certain amount (relative). etc.

See this reference (and search google for "Cocos2d CCAction", there are lots of references).

Was this helpful?

نصائح أخرى

use a CCMoveTo (for displacement to an absolute x,y) or CCMoveBy for a relative movement from current position at the moment when the animation starts.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top