CCControlSlider Class Reference
Inherits from | CCControl : CCLayer |
Declared in | CCControlSlider.h |
Overview
Slider control for Cocos2D.
A CCControlSlider object is a visual control used to select a single value from a continuous range of values. An indicator, or thumb, notes the current value of the slider and can be moved by the user to change the setting.
Tasks
Creating Sliders
-
+ sliderWithBackgroundFile:progressFile:thumbFile:
Creates slider with a background filename, a progress filename and a thumb image filename.
-
+ sliderWithBackgroundSprite:progressSprite:thumbSprite:
Creates a slider with a given background sprite and a progress bar and a thumb item.
-
– initWithBackgroundSprite:progressSprite:thumbSprite:
Initializes a slider with a background sprite, a progress bar and a thumb item.
Accessing the Slider’s Value
-
value
Contains the receiver’s current value.
property -
– setValue:animated:
Sets the receiver’s current value, allowing you to animate the change visually.
Accessing the Slider’s Value Limits
-
minimumValue
Contains the minimum value of the receiver.
property -
maximumValue
Contains the maximum value of the receiver.
property
Customizing the Appearance of the Slider
-
onThumbTintColor
The color used to tint the appearance of the thumb when the slider is pushed.
property
Properties
maximumValue
Contains the maximum value of the receiver.
@property (nonatomic, assign) float maximumValue
Discussion
If you change the value of this property, and the current value of the receiver is above the new maximum, the current value is adjusted to match the new maximum value automatically.
The default value of this property is 1.0.
Declared In
CCControlSlider.h
minimumValue
Contains the minimum value of the receiver.
@property (nonatomic, assign) float minimumValue
Discussion
If you change the value of this property, and the current value of the receiver is below the new minimum, the current value is adjusted to match the new minimum value automatically.
The default value of this property is 0.0.
Declared In
CCControlSlider.h
onThumbTintColor
The color used to tint the appearance of the thumb when the slider is pushed.
@property (nonatomic, assign) ccColor3B onThumbTintColor
Discussion
The default color is ccGRAY.
Declared In
CCControlSlider.h
value
Contains the receiver’s current value.
@property (nonatomic, assign) float value
Discussion
Setting this property causes the receiver to redraw itself using the new value. To render an animated transition from the current value to the new value, you should use the setValue:animated: method instead.
If you try to set a value that is below the minimum or above the maximum value, the minimum or maximum value is set instead. The default value of this property is 0.0.
Declared In
CCControlSlider.h
Class Methods
sliderWithBackgroundFile:progressFile:thumbFile:
Creates slider with a background filename, a progress filename and a thumb image filename.
+ (id)sliderWithBackgroundFile:(NSString *)bgFile progressFile:(NSString *)progressFile thumbFile:(NSString *)thumbFile
Discussion
Creates slider with a background filename, a progress filename and a thumb image filename.
Declared In
CCControlSlider.h
sliderWithBackgroundSprite:progressSprite:thumbSprite:
Creates a slider with a given background sprite and a progress bar and a thumb item.
+ (id)sliderWithBackgroundSprite:(CCSprite *)backgroundSprite progressSprite:(CCSprite *)pogressSprite thumbSprite:(CCSprite *)thumbSprite
Discussion
Creates a slider with a given background sprite and a progress bar and a thumb item.
Declared In
CCControlSlider.h
Instance Methods
initWithBackgroundSprite:progressSprite:thumbSprite:
Initializes a slider with a background sprite, a progress bar and a thumb item.
- (id)initWithBackgroundSprite:(CCSprite *)backgroundSprite progressSprite:(CCSprite *)progressSprite thumbSprite:(CCSprite *)thumbSprite
Parameters
- backgroundSprite
CCSprite, that is used as a background.
- progressSprite
CCSprite, that is used as a progress bar.
- thumbSprite
CCSprite, that is used as a thumb.
Discussion
Initializes a slider with a background sprite, a progress bar and a thumb item.
Declared In
CCControlSlider.h
setValue:animated:
Sets the receiver’s current value, allowing you to animate the change visually.
- (void)setValue:(float)value animated:(BOOL)animated
Parameters
Discussion
If you try to set a value that is below the minimum or above the maximum value, the minimum or maximum value is set instead. The default value of this property is 0.0.
See Also
Declared In
CCControlSlider.h