[Open Source!] SimpleSlider : An easy to integrate slider control!

[Open Source!] SimpleSlider : An easy to integrate slider control!
0

Good afternoon everyone!

Another class I’ve been working on recently has been my SimpleSlider class, which I am now open-sourcing for all to use! :smiley:

While Cocos2d-x already contains a slider class, it had quite a lot of functionality I didn’t need, and lacked a few bits of functionality I wanted. So, I decided I’d develop my own custom implementation with the aims of meeting my own requirements while also being incredibly easy to integrate anywhere it is needed! It is fully game-agnostic, meaning that the one version can be used across many games at the same time!

To have a look and try it out for yourselves, check out https://github.com/ryanbourneuk/SimpleSlider and follow the integration instructions!

As an example of how simple the integration is, here’s a complete example of how to create the slider object:

auto slider = SimpleSlider::create(50, "slider_unselected.png", "slider_selected.png", "slider_circle.png", "font.ttf", LabelFormatPercentage, "Off", "Default", "Max", [&]() {
  // slider activated
}, [&](int sliderValue) {
  // slider is moving
}, [&](int sliderValue) {
  // slider has stopped moving
});

Yep, that’s it. Add that as a child to the node/layer you’re wanting it on, set the position of the slider, set the slider to enabled and you’re good to go! The full integration instructions are available in the repository!

Here’s an example, of the SimpleSlider integrated twice into the settings for Asterun:

The sliders both interface with the AudioHelper class I open-sourced yesterday, so the in-game volume is fully customisable from the settings!

Note how when the top slider is at 100% it uses a custom defined string instead of “100%”, while the slider below is showing the standard percent value.

Some updates for the future (being changing the parameters) include changing the slider to use sprite masks instead of scaling the slider bar; this will take some time to implement though!

Feel free to take a look at it, if you have any suggestions or improvements you think I should make please do let me know! :smiley:

Thanks! :smiley:

4 Likes

Just updated the repository, the SimpleSlider class is now fully game agnostic and you can pass in the activated and changing callbacks as nullptr if you decide you do not need them.

Take a look at the repository for more details! :smiley:

1 Like