"Independent Developer ER cocos2d-x combat 005" using COCOS2DX scale9sprite

Source: Internet
Author: User
Tags addchild

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.