开发者

iphone game control help

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


You could use a simple progress bar (UIProgressView) but you will have to "animate" it yourself. Perhaps use a repeating timer with 20ms delay to generate small up/down changes.

More help on UIProgressView:

  • http://developer.apple.com/library/ios/#documentation/uikit/reference/UIProgressView_Class/Reference/Reference.html
  • How to initiate UIProgressView to a certain value?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜