ios - Right way to return the UISlider method's INT? -


i working on game. have bunch of bad guy planes attacking guy planes. want user able manually select how many missiles shoot @ bad guy planes.

i have method adds subview containing uislider select how many missiles shoot.

example (flow of code):

1) bad guys, guys planes see each other.

2) jump uislider method.

3) (>need int continue program here<)

4) user selects number in uislider method , selector called.

5) uislider selector - (how location 3?)

my problem not programming rather logic. specific, right way return uislider method's int code location called uislider method?

also great able reuse same method (the game has lot of bad guys).

i don't think there's way return uislider value.

first abdullah shafique stated, need create method uislider programmatically like:

[yourslider addtarget:self action:@selector(valuechanged:) forcontrolevents:uicontroleventvaluechanged]; 

then might have call method want after selecting number like:

- (void)valuechanged:(id)sender {     uislider *slider = (uislider *)sender;     int value = slider.value;      [self shootmissles:value]; //this line send value of slider method below. } 

i'm not familiar input , apple basic line [self shootmissles:value] pass slider value method can whatever wish it. example:

 - (void)shootmissles:(float)numofmissles {      //code shoot x number of missles based on uislider value - mindful       //that uislider spits out float values, have round whole numbers.  } 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -