Search code examples
cocos2d-iphonescale

cocos2d scaleX - scale only middle part


I want to use a menu image for short and long menus, when I scale the image the edges look bad. Is it possible to scale only middle part of a sprite or is there a way to do what I want?

Thanks for you help.


Solution

  • You need to use a technique called 9 Slice Scaling. It involves slicing the image into 9 slices so that only the middle part scales in both directions, where as the edges only scale up/down or left/right to preserve them.

    There is an open source implementation on GitHub which I use and it works well.