Iphone game - "Power" bar control help

Discussion in 'iOS Apps' started by sregorcinimod, Mar 8, 2011.

  1. sregorcinimod macrumors newbie

    Joined:
    Mar 8, 2011
    #1
    Hi I am creating a game whereby two actions happen that enable a button, upon first touch of the button I need a "power" bar to scroll up and down and then on the second touch of the button the "power" bar stops scrolling and another action happens.

    I have got to the stage where the button is touchable, but have no idea what you call the "power" bar control in order to search for help on how to create this.

    The "power" bar is just like your traditional in game control like a sports game, where you need to set the "power" of a golf shot based on when you hit a button.

    If
    1) You know the name of that type of control so I can more detailed search -or-
    2) You have some sample code that would show how this "power" bar can be achieved
    Then it would be gratefully appreciated

    Cheers
     
  2. sregorcinimod thread starter macrumors newbie

    Joined:
    Mar 8, 2011
    #2
    using a uiprogressview to make the power bar, but

    So with help from a different forum, I have created a UIProgressview and animated it so that when you touch a button the animation starts and then when you touch the button again it registers the touch and stores the progress value at the time. However I now need to stop the animation of the progress bar, any ideas?

    Here is my code:

    (void)Buttontouched {

    if (buttontouchcount == 0) {
    buttontouchcount = 1;
    [myProgbar setProgress: 1.0 animated: YES];
    }
    else if (buttontouchcount == 1) {
    buttontouchcount = 2;
    buttonstop = myProgbar.progress;
    //this next line doesn't work
    [myProgbar setProgress: buttonstop animated: NO];
    //this line works
    placeholder1.text = [NSString stringWithFormat:mad:"%f",buttonstop];

    }
    }
     
  3. sregorcinimod thread starter macrumors newbie

    Joined:
    Mar 8, 2011
    #3
    Solved it

    Just in case anyone else has the same issue. Here is how i solved it:

    Created a UIProgressView with a default value of 0. Then using a timer called a method (progressup) that updates the progress by +0.05 unless it = 1, if it does equal one then the timer is stopped and a new timer is started that calls a method(progressdown) that updates the progress by -0.05 unless it is <0.05, if it is less than 0.05 the timer is stopped and a new timer is started that calls the method(progressup) and so on and so on so the bar goes up and down.

    Then when another button is pressed it reads the current progress and stops the timer.
     

Share This Page