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:
this should do the trick, I think this is the unmodified version of CCScale9Sprite (I’ve made some changes to it, so I had to dig around for the original.) Good luck, and let me know if you get it working
that’s odd, I’ve never seen that error before. The invocation object is basically a collection of a target and a function pointer. The invoke method just calls the function belonging to the target object, passing in the object that called the invoke as the argument.
I’m not sure, but you might need some extra brackets on the (*m_action), but the code works fine for me in VS2010.
Thanks for this extension, I would like to use the scale 9 feature. What are the file that I have to use ? I can’t find the scale9sprite files in the zip here : http://cocos2d-x.org/projects/cocos2d-x/assets/1 so I’m not sure of what to use.
I found an issue on CCControlButton. It crashes if you use “buttonWithTitleAndFontNameAndFontSize” method in CCControlButton.
It is due to missing CCScale9Sprite.
EDIT: for some reason, it’s not uploading. Can someone try to upload it from here: http://dl.dropbox.com/u/2522035/HelloWorld.rar
It’s basically a remake of Zatacka (Achtung die Kurve) for iOS and Android. If you think it looks too similar to a few of the versions already out there, it’s because they might’ve kinda “borrowed” the style from my xbox version
Anyway, so it contains the CCControlExtensions, as well as a few of my nice extensions to these extensions:
Snapping to integer values for the slider
checkboxes
“Passive” menus (which allow the controls to handle events)
Spacers
“Setting” controls, which can be tied to a value in CCUserDefaults
The actual game shows how to handle multiple touches, how to scale the UI for different devices (I probably went a bit overboard here, because it automatically selects the best asset size based on the screen size, as well as the available asset sizes (240p, 320p, 480p, etc. It’s dynamic). It’s also quite fun to play on a tablet! Free to use/abuse however you want, just not for a snake-based game
I’m pretty sure my coding style is not ideal, and I’m also sure there are better ways to get some things done, but it works