I'm not really familiar with objC and looking for a solution to create a slider that slides from "steps" I am here. Value increases to the slider as value + 10 or maybe value + = 100
I modified the code above for a custom cocos 2D slider
Has properties in it : recalculation : and ccTouchesEnded: I added (self.steps! = 0), the case is set to step , the slider can work General mode This calls valueForLocation and locationFromValue : Then use an example with a 3-step slider on each step Needs and values of 0, 1 and 2 are needed: Hope this can be useful
@property (nonatomic, readwrite) float value; @protecti (nanatomic, redrawite) minimum value; @property (non-standard, redrawite) maximum value; @protecti (nonatomic, readwrite) int step;
- (empty) recalculate value {float step value [self.psups]; StepValues [0] = Self. Mildly; StepViews Step - 1] = self. Optimum; (Int i = 1; I & lt; self.stops; I ++) {Stevell Value [I] = I * (Self Maximimate Value - Self Minimum Value) / (Self Step - 1); If (self.value
- (zero) ccTouchEnded: Event with touch (UEIVE *) event {if ([self select is done]) {self .value = [Self-value Location Location: _thumbSprite.position]; If (step by step! = 0) {[self-reckon value]; [_thumbSprite setPosition: [self-placementframe value: self.value]]; }} Self.thumbSprite.color = ccWHITE; Self. Selected = no; }
- (float) Manfola Location: (CGPoint) Location {Float Percentage = location.x / _backgroundSprite.contentSize.width; Return _minimumValue + percent * (_maximumValue - _minimumValue); } - (CG point) LocationForm Value: (float) value {float percentage = self. Value / self maxime value;
self.Slider = [backgroundground with CCControlSlider sliderFile: @ "sliderTrack." "Progress file: @" slider progress.png "thumbFile : @ "SliderThumb-hd.png"]; progress file: @ "slider progression .png" thumbfile: @ "slider Self- Slider.steps = 3; Self.Slider.value = [[GameSettings Shared Settings] Default RailwayWeek: Self.Slider.maximumValue = 2.0f; Self.Slider.steps = 3; [Self] Slider addTarget: Self-action: @Selector (OnSliderWhenChange) Control events: CCC Contract EventValues];
Comments
Post a Comment