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