Skip to content

Conversation

@JFonS
Copy link

@JFonS JFonS commented Feb 3, 2016

This past GGJ I developed a rythm based game, I wanted to use this library for animations but they kept getting out of sync. I had to find a workaround without using flux as I didn't have much time to find the cause.

Now that I have all the time I want I found what was causing the problem and I fixed it. My lua code style is not the best so feel free to modify any of my code.

There were two main problems, the firs one being the delay check. On a frame update it would check if the delay was grater than 0, substract the deltatime and the do nothing. If the delay is smaller than teh deltatime there is some time being "lost" in the process.

The following code would print 0, which is clearly incorrect

test.count = 0
flux.to(test, 0.5, {count = 1}):delay(0.001)
flux.update(10)
print(test.count)

The second problem was relative to tween chaining. The after method used to chain tweens added an oncomplete function to the first tween that added thw new tween to the tween list. But, if the first tween didn't take up the whole deltatime, the second tween wasn't updated according to the remaining time. And again some of the deltatime was "lost".

The following code would print 1, which is clearly incorrect

test.count = 0
flux.to(test, 0.1, {count = 1}):after(0.1,{count = 2}):after(0.1,{count = 3})
flux.update(10)
print(test.count)

These are some minor problems if time precision is not critical or you don't chain many tweens and delays, but the fixes might be useful for someone. Again, feel free to change any part of the code.

@JFonS
Copy link
Author

JFonS commented Feb 3, 2016

Ok, sorry, I did some "real life" tests and its completely broken. I'll try to fix it.

@JFonS JFonS closed this Feb 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant