CCControlPicker Class Reference
Inherits from | CCControl : CCLayer |
Declared in | CCControlPicker.h |
Overview
Picker control for Cocos2D.
The CCControlPicker class implements objects, called control pickers, that use a spinning-wheel or slot-machine metaphor to show one set of values. Users select values by rotating the wheels so that the desired row of values aligns with a selection indicator.
Tasks
Create Pickers
-
– initWithForegroundSprite:
Initializes a picker by only defining the foreground sprite (with no selection indicator).
-
+ pickerWithForegroundSprite:
Creates a picker by only defining the foreground sprite (with no selection indicator).
-
+ pickerWithForegroundFile:
Creates a picker by only defining the foreground filename (with no selection indicator).
-
– initWithForegroundSprite:selectionSprite:
Initializes a picker by defining the foreground and the selection sprites.
-
+ pickerWithForegroundSprite:selectionSprite:
Creates a picker by defining the foreground and the selection sprites.
-
+ pickerWithForegroundFile:selectionFile:
Creates a picker by defining the foreground and the selection filenames.
Changing the Picker’s Appearance
-
background
Contains the node that is drawn on the background of the picker.
property
Getting the Dimensions of the Control Picker
-
– rowSize
Returns the size of a row.
-
– numberOfRows
Returns the number of rows.
Managing the Behavior of the Control Picker
-
swipeOrientation
The swipe orientation of the picker.
property -
looping
The looping vs. nonlooping state of the picker.
property
Specifying the Delegate
-
delegate
The delegate for the control picker.
property
Specifying the Data Source
-
dataSource
The data source for the control picker.
property
Reloading the Control Picker
-
– reloadComponent
Reloads the component of the picker control.
Selecting Rows in the Control Picker
-
– selectRow:animated:
Selects a row in the picker control.
-
– selectedRow
Returns the index of the selected row.
Properties
background
Contains the node that is drawn on the background of the picker.
@property (nonatomic, strong) CCNode *background
Discussion
The node you specify should fit within the bounding rectangle of the foreground sprite. If it does not, the node will be clip.
This default value of this property is nil.
Declared In
CCControlPicker.h
dataSource
The data source for the control picker.
@property (nonatomic, assign) id<CCControlPickerDataSource> dataSource
Discussion
The data source must adopt the CCControlPickerDataSource protocol and implement the required methods to return the number of rows in each component.
Declared In
CCControlPicker.h
delegate
The delegate for the control picker.
@property (nonatomic, assign) id<CCControlPickerDelegate> delegate
Discussion
The delegate must adopt the CCControlPickerDelegate protocol and implement the required methods to respond to new selections or deselections.
Declared In
CCControlPicker.h
looping
The looping vs. nonlooping state of the picker.
@property (nonatomic, getter=isLooping) BOOL looping
Discussion
If YES, the picker will display the data source as a loop. I.e that when the end of the source is reached the picker will display the first element.
The default value for this property is NO.
Declared In
CCControlPicker.h
swipeOrientation
The swipe orientation of the picker.
@property (nonatomic, assign) CCControlPickerOrientation swipeOrientation
Discussion
The orientation constrains the swipe direction. E.g if the orientation is set to CCControlPickerOrientationVertical the element can move in vertical only.
The default value for this property is CCControlPickerOrientationVertical.
Declared In
CCControlPicker.h
Class Methods
pickerWithForegroundFile:
Creates a picker by only defining the foreground filename (with no selection indicator).
+ (id)pickerWithForegroundFile:(NSString *)foregroundFile
See Also
Declared In
CCControlPicker.h
pickerWithForegroundFile:selectionFile:
Creates a picker by defining the foreground and the selection filenames.
+ (id)pickerWithForegroundFile:(NSString *)foregroundFile selectionFile:(NSString *)selectionFile
Declared In
CCControlPicker.h
pickerWithForegroundSprite:
Creates a picker by only defining the foreground sprite (with no selection indicator).
+ (id)pickerWithForegroundSprite:(CCSprite *)foregroundSprite
See Also
Declared In
CCControlPicker.h
Instance Methods
initWithForegroundSprite:
Initializes a picker by only defining the foreground sprite (with no selection indicator).
- (id)initWithForegroundSprite:(CCSprite *)foregroundSprite
Parameters
- foregroundSprite
foreground sprite which defines the area of the picker.
Declared In
CCControlPicker.h
initWithForegroundSprite:selectionSprite:
Initializes a picker by defining the foreground and the selection sprites.
- (id)initWithForegroundSprite:(CCSprite *)foregroundSprite selectionSprite:(CCSprite *)selectionSprite
Parameters
- foregroundSprite
foreground sprite which defines the area of the picker.
- selectionSprite
selection indicator sprite.
Declared In
CCControlPicker.h
numberOfRows
Returns the number of rows.
- (NSUInteger)numberOfRows
Return Value
The number of rows.
Discussion
A picker control fetches the value of this property from the data source and and caches it. The default value is zero.
Declared In
CCControlPicker.h
reloadComponent
Reloads the component of the picker control.
- (void)reloadComponent
Discussion
Reloads the component of the picker control.
Declared In
CCControlPicker.h
rowSize
Returns the size of a row.
- (CGSize)rowSize
Return Value
The size of rows.
Discussion
A picker control fetches the value of this property by calling the rowHeightInControlPicker: delegate methods, and caches it. The default value is CCControlPickerDefaultRowHeight.
Declared In
CCControlPicker.h
selectRow:animated:
Selects a row in the picker control.
- (void)selectRow:(NSUInteger)row animated:(BOOL)animated
Parameters
- row
A zero-indexed number identifying a row of component.
- animated
YES to animate the selection by spinning the wheel (component) to the new value; if you specify NO, the new selection is shown immediately.
Discussion
Selects a row in the picker control.
Declared In
CCControlPicker.h