Hub

CCControlExtensions

Thumb_icon-controlextensions

Brief

Including these controls: Scale9Sprite, ControlButton, Slider, Color Picker

Description

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
  • Slider
  • 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~~>setMinimumValue;
slider~~>setMaximumValue(max);
slider~~>setSnappingInterval;
slider~~>setValue(value);
slider->addTargetWithActionForControlEvents(this, menu_selector(MenuScene::sliderCallback), CCControlEventValueChanged);
return slider;
@

Screenshot

Video

<embed src="http://www.youtube.com/v/NHA6uB2_D_s?version=3&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" width="420" height="315" allowscriptaccess="always" allowfullscreen="true">
</embed>

Comments

  • kodok88

    Can I see the source of examples on video?

    2012-07-03 05:15

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.