Ok so I’m working in 2D for this project. I put 3D vector as my position in the roulette wheel ball
example but it is actually meant as a 2D game. Here is a more complete set of equations:
local r ← radius(t) # t is time here
local noise ← [ noise_x(t), noise_y(t) ]
[ r * cos(2PI * t), r * sin(2PI * t) ] + noise
This is basically how I move the ball around the roulette wheel. So the radius is constant for the major part of the animation, then starts to decrease after a certain point, up to a certain minimum value. This captures the fact that the ball is being slowly pulled towards the middle of the roulette wheel. “t”, or the time, controls this behavior. It also controls the circular motion of the ball. “t” gradually decelerates down to zero when the ball starts being pulled inwards. Finally, when this is the case, we add some noise to simulate the ball bouncing around.
I wanted to simply use a function (the function above) in go.animate. For this to work, I would need to animate the position of the ball [t, t] from say [0, 0] to [10, 10] (that is, 10 loops). I wanted the engine to interpolate an “ease” [t, t] then pass it to my function that would compute the true (final) position as a function of “t” and then have the engine pass the final value to the position property of the ball go.
My issue with go.animate is that it is only interpolating values on a line, from whatever starting value the property has to the “to” parameter. We have no control in between.
That said, my suggestion probably wouldn’t work and I would need to code easing myself and compose it with my functions above in the update function.
@blisteredMind yes I think what you describe is kind of what I look for. The ball is subject to various forces. I just don’t see how to make it do a many full circles with go.animate. The simplest would simply to use the update function. Just for my information, instead of using timers can we use the “complete function” parameter and call go.animate from there? Also you don’t need to be random at all with the graphics/animation part. I coded a solution in react native where I simply randomly sample which slot will be “chosen” by the ball, and I sample also where that slot will be at the end of the animation (say north, or west or any other angle) and then I match all of this to a sound effect and it looks pretty good. I play an animation which is decided in advance! The trick is to match where the slot will be at the end with where the ball will be, with the sound effect! Unfortunately I don’t remember how to make react native sing anymore and I don’t want to do it too. I will redo in Defold! Also I could use go.animate by having the ball occupy just a fraction of a larger square sprite with the square width equal to the radius of the roulette wheel. The ball would appear at its place. Then animate rotation of the square go. That could work and I am not sure if this is what you alluded to. Most of the square sprite would be transparent, except for the ball. This is a solution I think.