开发者

Timing function for "Wheel of Fortune" style ticker

开发者 https://www.devze.com 2023-03-12 03:26 出处:网络
I\'m trying to create a function that changes a lab开发者_开发技巧el\'s text. I want it in a \"Wheel of Fortune\" style where the text changes really quickly at first but slows down over time, then st

I'm trying to create a function that changes a lab开发者_开发技巧el's text. I want it in a "Wheel of Fortune" style where the text changes really quickly at first but slows down over time, then stops at the final text. I have the text as strings in an array.

I'm guessing I would need an exponential function to do this but maths is not my strong point. Currently I'm trying:

- (void)timer {
   float time = 0.5;
   float increase = 0.05;
   for(int x = 0; x < 100; x++) {
      sleep(time);
      time = time + increase;
      NSLog(@"%f", time); //Log to show time of each iteration
   }
}

I don't need help linking it up with labels etc., I just need help to get the timing right.

0

精彩评论

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