Ccscale9sprite class, someone called it point nine figure, someone called it nine figure, someone called it nine sister figure. Now we're going to make it easy for him to use.
Ccspriteframecache* Cache =Ccspriteframecache:: Sharedspriteframecache();Cache -Addspriteframeswithfile ("Plist.plist"); Ccsprite*The=Ccsprite:: Createwithspriteframename("6.png"); Ccpoint Opoint=The -Getcontentsize ();/ * 66,27 * /The -SetPosition (CCP ( -, -)); -Setscale (4.0f); AddChild (guest); Scale9sprite*Poscale9sprite1=Scale9sprite:: Createwithspriteframename("6.png");p Oscale9sprite1 -SetPosition (CCP ( -, -));p oscale9sprite1 -Setcontentsize (Ccsizemake (opoint.X* 4, Opoint.Y* 4)); AddChild (poscale9sprite1); Scale9sprite*Poscale9sprite2=Scale9sprite:: Createwithspriteframename("6.png");p Oscale9sprite2 -SetPosition (CCP ( -, -));p Oscale9sprite2 -Setcapinsets (Ccrect (3,3, Opoint.X- 3, Opoint.Y- 3));p Oscale9sprite2 -Setcontentsize (Ccsizemake (opoint.X* 4, Opoint.Y* 4)); AddChild (POSCALE9SPRITE2);
The result of the operation is as follows (the magnification is not large enough, if it is larger then the effect is obvious):
We need to pay special attention to setting capinsets when using Ccscale9sprite:
Since Ccscale9sprite belongs to the extension, under the Extensions folder, so we need to add the corresponding header file and the name space:
#include "../extensions/cocos-ext.h"USING_NS_CC_EXT;
Also add related paths:
Otherwise, the following error occurs:
#
Reference article:
Understanding of COCOS2DX 3.x Scale9sprite
COCOS2DX Basic article (12)--point nine figure ccscale9sprite
#
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"Independent Developer ER cocos2d-x combat 005" using COCOS2DX scale9sprite