Cocos2d-x drag slider control CCControlSlider

Source: Internet
Author: User

# Include "GameMusicSetting. h" bool GameMusicSetting: init () {if (! CCLayer: init () {return false;} CCSize size = CCDirector: sharedDirector ()-> getWinSize (); // The parameters are: slide slider image, slide slider slide to overwrite images. slide Image CCControlSlider * slider = CCControlSlider: create ("bg_ScrollBtn.png", "value_ScrollBtn.png", "bar_ScrollBtn.png"); slider-> lower (0 ); // set the slider-> setMaximumAllowedValue (5); slider-> setAnchorPoint (ccp (0.5, 1); slider-> setPosition (ccp (size. width/2, size. height/2); // set the slider sliding callback function slider-> addTargetWithActionForControlEvents (this, cccontrol_selector (GameMusicSetting: callback), CCControlEventValueChanged); addChild (slider, 1 ); return true;} CCScene * GameMusicSetting: scene () {CCScene * scene = CCScene: create (); CCLayer * layer = GameMusicSetting: create (); scene-> addChild (layer); return scene;} void GameMusicSetting: onEnter () {CCLayer: onEnter ();} void GameMusicSetting: onExit () {CCLayer :: onExit ();} void GameMusicSetting: callback (CCObject * sender, CCControlEvent controlEvent) {CCControlSlider * pslider = (CCControlSlider *) sender; CCLOG ("% f ", pslider-> getValue () * 5); // output the value represented by the position of the slider}

 

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.