Use Cocos2d-x to imitate QQ happy Bucket landlord mobile version of the interface control

Source: Internet
Author: User

In the previous period of time to do a landlord game, you need to achieve similar QQ happy bucket landlord inside the effect. See below.

Implementation details are not detailed, see source code. In general, an ellipse is created using an elliptical algorithm (see Computer Graphics (Third edition) 3.10), and a sprite is placed on the ellipse every 90 degrees. Then the new position of each sprite is calculated and the color, size , level and other attributes of each sprite are updated based on the distance to the sprite on the center.

Speaking of use, this is also relatively simple to use, as shown below.

BOOL Helloworld::init () {////////////////////////////////1. Super init first if (!    Layer::init ()) {return false;    } Size visiblesize = Director::getinstance ()->getvisiblesize ();    VEC2 origin = Director::getinstance ()->getvisibleorigin ();    Spriteframecache::getinstance ()->addspriteframeswithfile ("Image.plist");    M_pcirclegallery = Circlegallery::create (this, 4, 180, 50);    M_pcirclegallery->setposition (VEC2 (origin.x + VISIBLESIZE.WIDTH/2, ORIGIN.Y + VISIBLESIZE.HEIGHT/2));        AddChild (M_pcirclegallery); return true;} sprite* Helloworld::galleryitematindex (circlegallery *gallery, const Galleryitem &item) {char buffer[64];sprintf ( Buffer, Item.state = = gallerydelegate::state::selected? "Item_%02d+.png": "Item_%02d.png", Item.index + 1); auto Sprite = Gallery->getspritebyindex (Item.index); if (!sprite) {sprite = Sprite::create ();} Sprite->setspriteframe (buffer); return sprite;}

The number of children passed in when Circlegallery was created, the radius of the x-axis, and the radius of the y-axis. And then Galleryitematindex function inside according to the parameter Galleryitem (which contains the current item index and state) to update the wizard, the other will not be ignored, will automatically update the size , hierarchy , color and other information. The usage is a bit similar to Cctableview.


SOURCE Download: Http://pan.baidu.com/s/1o6l2Jk2

Use Cocos2d-x to imitate QQ happy Bucket landlord mobile version of the interface control

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.