Share a reusable Slide Control

Thanks for all of you who has contributed or will contribute to the community,
especially to Walzer and his great team.
i want to share a slide control using cocos2dx. it is oringinally from pmanna in cocos2d version,
and i change it to c++ and made some useful improvement.
any advice is welcome.


CCMenuItemSlider.h.zip (1.1 KB)


CCMenuItemSlider.cpp.zip (2.0 KB)


track.png (0.9 KB)


track2.png (1.1 KB)


knob.png (1.8 KB)

Thanks a lot! It’s definitely useful. We’ll discuss if this feature should be merged into master repo.

Issue #912. But I’m not sure if the most of the team will agree.

We decide to merge your code.

Could you paste some test code?
Or could you pull request by github: https://github.com/cocos2d/cocos2d-x?

Thank you.

Hi :slight_smile:

Thanks for sharing this, it was the inspiration I needed to start porting some of YannickL’s “CCControlExtension” classes to cocos2d-x! One of the problems I found with the CCMenuItemSlider class above is that you use a separate menu class to hold the sliders (to detect and process touches), while YannickL’s approach is to allow each control to do the processing of the touches. For that purpose, I created a “passive” menu, which is simply a container, without any processing of touches (but this is not essential)

The result is a set of controls that extend from CCLayer and CCRGBAProtocol that can be put in a menu. You can have a look here: http://www.cocos2d-x.org/boards/6/topics/8335

I hope eventually they can get integrated into the extensions repo!