Monkey original, reprinted. Reprinted Please note:Reposted from cocos2d Development Network --cocos2dev.com. Thank you!
Original article address:
Http://www.cocos2dev.com /? P = 295
When I saw cceditbox some time ago, I found that there was an image scaled with a 9-cell grid, that is, an image scaled with rounded corners.
This is useful. Many games have many rounded corner images of different sizes as the background. With ccscale9sprite, you only need to provide a very small rounded corner image to freely scale the rounded corner image of other sizes. It's a good thing.
Usage:
1. Import the header file and namespace
# Include "cocos-ext.h" using_ns_cc_ext;
2. Initialization code:
Ccscale9sprite * labbg1 = ccscale9sprite: Create ("wd_bg_text.png"); labbg1-> setanchorpoint (. 5 ,. 5); labbg1-> setpreferredsize (ccsizemake (255, 20); labbg1-> setposition (CCP (size. width/2, size. height/2); addchild (labbg1 );
Note:
Setpreferredsize is used to set the size to be generated.
View results:
Wd_bg_text.png
Effect after running: