My favourite animation trick: exponential smoothing
I write stuff about math, simulation, graphics, gamedev, and programming.
lisyarus.github.io
Private Sub AnimateTo(MoveFrom As Int, MoveTo As Int, Duration As Int)
Private CurrentPosition As Int
Private BeginTime As Long = DateTime.Now
CurrentPosition = MoveTo
Dim tempValueA As Float
Do While DateTime.Now < BeginTime + Duration
tempValueA = CallAnimation(DateTime.Now - BeginTime, MoveFrom, MoveTo - MoveFrom, Duration)
' tempValueA = CubicTimeEaseInOut(DateTime.Now - BeginTime, MoveFrom, MoveTo - MoveFrom, Duration)
DrawCircle(tempValueA)
Sleep(5)
If MoveTo <> CurrentPosition Then Return 'will happen if another update has started
Loop
DrawCircle(CurrentPosition)
End Sub
I have converted all functions from this site for B4X hereYou may also have a look at this site: Easing Equations
Sorry, I did not remember this thread.I have converted all functions from this site for B4X here
Even though these equations were already converted to B4X by @epiCode, I opened a new thread in the Code snippets forum.Please @klaus, post this wonderful example in some section of the forum. The chit chat forum is not indexed for searching.