Including these controls: Scale9Sprite, ControlButton, Slider, Color Picker
I’ve ported the very nice set of extensions to cocos2d made by YannickL (https://github.com/YannickL/CCControlExtension) to cocos2d-x.
The controls are:
- Scale9Sprite (resizable 9patch sprite)
- ControlButton (button with excellent event handling, with a label and background 9patch sprite
- Color picker
I have made a few adjustments to YannickL’s code: The slider now has a the ability to “snap” to certain intervals. For example, if the slider goes from 1-10, you could make it snap to integers only. In addition, the touch detection has been cleaned up a bit to allow for more intuitive slides.
If anyone wants to have a look, they’re attached here. You can use the images from YannickL’s github for testing. You can create slider with the following code:
@ CCControlSlider* slider=CCControlSlider::sliderFromFiles(“Slider.png”, “SliderProgress.png”, “SliderKnob.png”);
slider->addTargetWithActionForControlEvents(this, menu_selector(MenuScene::sliderCallback), CCControlEventValueChanged);
<embed src="http://www.youtube.com/v/NHA6uB2_D_s?version=3&hl=en_US&rel=0" type="application/x-shockwave-flash" width="420" height="315" allowscriptaccess="always" allowfullscreen="true">