/Classes/Slider.h
C Header | 87 lines | 39 code | 12 blank | 36 comment | 0 complexity | b854b456635fcfd108eef5aff8e5b770 MD5 | raw file
Possible License(s): Apache-2.0
1// 2// Slider.h 3// 4// Created by Karl Stenerud on 10-05-30. 5// 6 7#import "TouchableNode.h" 8 9/** 10 * A slider control. Contains a "knob" object, which slides along a "track" object. 11 * Both the track and the knob are supplied at object creation time, and the slider 12 * adjusts its contentSize according to the knob and track's size as well as their scale factor. <br> 13 * This means that you can prescale the knob and/or track and still have a functioning slider. 14 */ 15@interface Slider : TouchableNode <CCRGBAProtocol> 16{ 17 CCNode* track; 18 CCNode* knob; 19 20 id target; 21 SEL moveSelector; 22 SEL dropSelector; 23 24 CCScaleTo* scaleUpAction; 25 CCScaleTo* scaleDownAction; 26} 27/** The position (value) of the slider in the track, as a proportion from 0.0 to 1.0 */ 28@property(readwrite,assign) float value; 29 30/** Create a slider. 31 * @param track The node to use as a track. 32 * @param knob The node to use as a knob. 33 * @param padding The amount of padding to add to the touchable area. 34 * @param target the target to notify of events. 35 * @param moveSelector the selector to call when the knob is moved (nil = ignore). 36 * @param dropSelector The selector to call when the knob is dropped (nil = ignore). 37 * @return a new slider. 38 */ 39+ (id) sliderWithTrack:(CCNode*) track 40 knob:(CCNode*) knob 41 padding:(CGSize) padding 42 target:(id) target 43 moveSelector:(SEL) moveSelector 44 dropSelector:(SEL) dropSelector; 45 46/** Initialize a slider. 47 * @param track The node to use as a track. 48 * @param knob The node to use as a knob. 49 * @param padding The amount of padding to add to the touchable area. 50 * @param target the target to notify of events. 51 * @param moveSelector the selector to call when the knob is moved (nil = ignore). 52 * @param dropSelector The selector to call when the knob is dropped (nil = ignore). 53 * @return The initialized slider. 54 */ 55- (id) initWithTrack:(CCNode*) track 56 knob:(CCNode*) knob 57 padding:(CGSize) padding 58 target:(id) target 59 moveSelector:(SEL) moveSelector 60 dropSelector:(SEL) dropSelector; 61 62@end 63 64/** 65 * A slider that operates in the vertical direction. 66 */ 67@interface VerticalSlider: Slider 68{ 69 float horizontalLock; 70 float verticalMax; 71 float verticalMin; 72} 73 74@end 75 76 77/** 78 * A slider that operates in the horizontal direction. 79 */ 80@interface HorizontalSlider: Slider 81{ 82 float verticalLock; 83 float horizontalMax; 84 float horizontalMin; 85} 86 87@end