Cocos2d-x 2.x ccscale9sprite use

Source: Internet
Author: User

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:

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.