Reputation: 8462
Currently I am using the update method from my CCLayer to move the X,Y sprite axys which is working fine, but I want to make sure I can do the same thing inside CCAnimation.
I searched and it seems CCAnimation only handles frame animation, is that correct? any direction?
thanks
Upvotes: 1
Views: 165
Reputation: 7390
I think you're looking for CCMoveBy
, or CCMoveTo
:
CCAction *actionMove = [CCMoveBy actionWithDuration:duration
position:ccp(dx, dy)];
[target runAction:actionMove];
You can run this action concurrently with a CCAnimate
action.
There are a lot more CCAction
subclasses besides these two, by the way. You can rotate and scale sprites, combine actions, call custom selectors, etc. Take a look at the class hierarchy for more ideas.
Upvotes: 2
Reputation: 9079
In a strategy game, to move a soldier i spawn 3 concurrent actions : a CCMoveTo, a CCAnimate that corresponds to the direction of travel, and a sequence of callbacks to signal the controller when the soldier egresses a tile or stands in the middle of the tile during its walk.
But note the caveat : simple straight line motion in any one of 8 directions, with no possibility of collision 'en route'. If your sprites need to move freely, or motion could become obstructed after starting the move, chose your current method to refresh position in the update cycle.
Upvotes: 1