0

I'm using SpriteBuilder and cocos2d-iphone v3 to make an app, and I'm using the timeline to animate some sprites, but I can't figure out if there's a way to do this or not. If I've added a few keyframes for a sprite, and now I want to reposition the sprite but keep it's animation the same relative to it's new location, I have to go through all the keyframes and update the positions for the new position.

Is there a way to apply something across all keyframes in a timeline?

Example:

Sprite1 is at (50,50) at keyframe 0; (60, 60) at keyframe 1; (50, 60) at keyframe 2; and (50,50) at keyframe 3, and then it loops. I want to move the sprite from (50,50) to (100,100), and would expect the position in the rest of the keyframes to be (110, 110), (100, 110), and (100, 100), but they stay at (60, 60), (50,60), (50,50).

I hope this makes sense, it looks a little cluttered reading over it but I can't think of a simpler way of describing my problem.

Thanks in advance!

Wernzy
  • 1,088
  • 8
  • 22

1 Answers1

0

Yes. The easiest way is to add a CCNode and make the sprite a child of that node. Now when you want to offset or move the sprite while it is running its timeline you just need to move the node (the sprite's parent).

CodeSmile
  • 64,284
  • 20
  • 132
  • 217