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

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

Managing the Behavior of the Control Picker

Specifying the Delegate

  •   delegate

    The delegate for the control picker.

    property

Specifying the Data Source

Reloading the Control Picker

Selecting Rows in the Control Picker

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

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

Declared In

CCControlPicker.h

pickerWithForegroundSprite:selectionSprite:

Creates a picker by defining the foreground and the selection sprites.

+ (id)pickerWithForegroundSprite:(CCSprite *)foregroundSprite selectionSprite:(CCSprite *)selectionSprite

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

selectedRow

Returns the index of the selected row.

- (NSInteger)selectedRow

Return Value

A zero-indexed number identifying the selected row , or -1 if no row is selected.

Discussion

Returns the index of the selected row.

Declared In

CCControlPicker.h