Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When using texturepacker, you can set your trim-mode to crop. This is nice, because when a sprite loads in cocos2d your bounding box will only be the visible area of your sprite - which is useful for things like collision detection etc.

However, if you have a complex animation - say a warrior with a sword, there is a good chance that the visible rect of your sprite is changing with each frame. For example, when the sword swings backwards or forwards your sprite width would adjust.

Cocos2d seems to handle this in a less then ideal way - when the dimensions change the sprite seems to dance around, rather then anchoring to centered point. In an engine I wrote, I handled this by using a set anchor point and direction for an animation. So if an animation got wider you could make sure it extended in a given direction (for example, a punch would extend in one direction, rather then appear to push the sprite backward from the fist)

Does cocos2d have any mechanism for handling this? I looked at anchorpoint, but it doesn't seem to handle this scenario.

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.