I need to figure out to add a slider to my scene that has a min value of 0 and a max value of 1.. thanks
Adding Slider In Cocos2D
(24 posts) (5 voices)-
Posted 2 years ago #
-
What kind of slider, a UIKit slider or one made with cocos2d elements?
Posted 2 years ago # -
Well which ever one is easiest... preferable a cocos2d one so i can customize the images easier
Posted 2 years ago # -
Hmmmm.... well I was thinking about doing a post on our blog on a slider I wrote in Cocos2d... I suppose now I'll have to do it, let me get back to on that.
Posted 2 years ago # -
Ok thanks when do you think you'll finish
Posted 2 years ago # -
I did a quick post with all the source, heres the link:
Posted 2 years ago # -
Is it compatible with cocos 0.7.2
Posted 2 years ago # -
Actually.. it's not because of the new Touch code in 0.8. You'd pretty much have to change the 3 touch functions in SliderTouchLogic to look like this, notice the comment where you'd want to preserve the "newer" code:
- (BOOL)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; //rest of began code is the same } - (BOOL)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; //rest of moved code is the same } - (BOOL)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; //rest of ended code is the same }I saw your other question about 0.8.2, all you needed was a libz.dylib it'd be worth your while to get it to compile.
Posted 2 years ago # -
ahh ok lol.. ill go and see if it works in 1 sec.. im redeveloping my game Kollide! with cocos2d so im kinda new but im enjoying cocos2d
Posted 2 years ago # -
added it and still getting:
"_OBJC_IVAR_$_TransitionScene.inSceneOnTop", referenced from:
_OBJC_IVAR_$_TransitionScene.inSceneOnTop$non_lazy_ptr in PageTurnTransition.o
"_OBJC_IVAR_$_CocosNode.anchorPoint_", referenced from:
_OBJC_IVAR_$_CocosNode.anchorPoint_$non_lazy_ptr in BitmapFontAtlas.o
"_OBJC_IVAR_$_CocosNode.position_", referenced from:
_OBJC_IVAR_$_CocosNode.position_$non_lazy_ptr in ParallaxNode.o
"_OBJC_IVAR_$_CocosNode.contentSize_", referenced from:
_OBJC_IVAR_$_CocosNode.contentSize_$non_lazy_ptr in BitmapFontAtlas.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Edit: but it works in simulator
Now im getting
error: FontManager.h: No such file or directory
error: FontLabelStringDrawing.h: No such file or directory
error: 'ZFont' undeclared (first use in this function)
error: 'zFont' undeclared (first use in this function)
error: 'FontManager' undeclared (first use in this function)
warning: 'NSString' may not respond to '-sizeWithZFont:'
warning: (Messages without a matching method signature
error: incompatible types in assignment
error: 'FontManager' undeclared (first use in this function)
warning: 'NSString' may not respond to '-drawInRect:withZFont:lineBreakMode:alignment:'
Posted 2 years ago # -
Hmmm those are strange errors, doing a quick google search on that type of error seems to indicate that your project settings are not set to the correct "simulator" or "device" settings... maybe take a look in the settings, could even compare them to the working examples from the cocos2d source folder.
Posted 2 years ago # -
Not sure what happened I cant seem to get it to work
Posted 2 years ago # -
WOOT! I was just missing the frontlabel lib
Posted 2 years ago # -
Your slider works great! Thanks!
Posted 2 years ago # -
Epic thread revival, but I just wanted to say thanks to @mobilebros for this Slider! I used it to replace my UIKit sliders that were not rotating with cocos2d autorotate functionality. I just modified your files to be compatible with the latest version of cocos2d :)
Posted 1 year ago # -
Can you post the updated source somewhere ?
Posted 1 year ago # -
So, I tried out this slider, and well, I got it working, but the code is less than straightforward for one, and two, some of it doesn't work!
I want to set the value to a default, i.e.
[slider setValue:1.0]; and it does nothing! The slider's thumb object just remains in the middle.
So, the Slider works in that you can grab it, drag it, and it will set the value you want it to, but you can't initialize it to be at a certain position.
OR, if you can, please let me know! I like that this item is a CCMenuItem, that's why I didn't roll my own solution, but now I'm at Alpha and need to fix these bugs...
Posted 1 year ago # -
@horseshoe7, I used the slider in a previous version of cocos2d (I think about 0.99.0) and they worked great then, the setValue worked perfectly, however, I tried to implement them just yesterday in 0.99.5 and I too am unable to set a default with setValue. I have been scouring the code, but haven't found anything yet. Hopefully @mobilebros has some time to check it out.
Posted 1 year ago # -
Ok I'll take a look in a bit, and post it in a more accessible location.
Posted 1 year ago # -
Awesome! Great to hear, especially with your new release of SpaceManager!
Posted 1 year ago # -
Hi guys, I adapted this to run in 0.99.5 too, have been on holiday, but just before I left I also noted that the slider would not initialise to the correct value (only in the middle) - thanks for helping out mobilebros :) I'll have another look when I am back home!
Posted 1 year ago # -
Ok I had a chance to look, it was something silly of course; I was using a member variable directly (position) and it wasn't getting "dirtied". I posted the src here, the zip is all that's needed:
http://mobile-bros.com/source/Slider/
Just to recap, 'cause it took me a second to remember too, here's the link to the old post:
http://www.mobile-bros.com/index.php?option=com_content&view=article&id=12:slider-in-cocos2d-iphone&catid=383:category-technical-articles&Itemid=3Posted 1 year ago # -
So that variable 'position' was being used from a parent class of a dif ccnode?
EDIT: Sorry, I just looked at the new source, I understand now!! Thanks @mobilebros!
Posted 1 year ago # -
Thanks very much @mobilebros - all working in my 0.99.5 ported app now :)
Posted 1 year ago #
Reply
You must log in to post.