Last active
December 12, 2015 04:18
-
-
Save valexa/4713351 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float lastTick = 0.0; | |
for (int i = 0; i <= 900; i++) { | |
float t = [self tickX:9 timesOfTotal:900 current:i lastTick:lastTick]; | |
if (t > 0) { | |
NSLog(@"%f %i",t,i); | |
lastTick = t; | |
} | |
} | |
-(float)tickX:(int)times | |
timesOfTotal:(float)total | |
current:(float)current | |
lastTick:(float)last | |
{ | |
float tickUnit = 1.0 / times; | |
float ret = last + tickUnit; | |
float oneUnit = total / times; | |
float nextTick = ret * (times) * oneUnit; | |
if (current == 0) return 0.000001; | |
if (current >= total) return 1.0; | |
if (current > nextTick) | |
{ | |
return ret; | |
}else{ | |
return 0.0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment