GUI: Ellipse loop animation sequence

How to make a loop animation sequence of changing rotation value with changing fill_angle value of the ellipse?

In short I want to type the code for this gui animation:

BUT

When I typed delay for gui.animate to get started the next gui.animate - It just don’t work.

Why? What I doing wrong?
code:

gui.animate(node, fill_angle, 55, gui.EASING_LINEAR, 1.5, 0) -- fill_angle to lower
gui.animate(node, fill_angle, 340, gui.EASING_LINEAR, 1.5, 1.5) -- fill_angle to upper

video demo:

You had the right idea. no need for a delay unless I have missed something.

	gui.animate(self.pie , "euler.z", -360, gui.EASING_LINEAR, 2.5, 0, nil, gui.PLAYBACK_LOOP_FORWARD)
	gui.animate(self.pie , "fill_angle", -360, gui.EASING_LINEAR, 2.5, 0, nil, gui.PLAYBACK_LOOP_FORWARD)

will give these results:
dmengine_tZfqbKHvMC

sample project:
GUI_pie_anim.zip (3.2 KB)

4 Likes

hm… Nope

That’s not what I asked for.

I want a special animation in which different speed of rotation by time and changeable fill_angle by time too, so I need the animation sequence…

But sequence with delay of gui.animation just doesn’t work…

gui.animate() has a complete_function param.
Is this something you want?

gui.animate(node, fill_angle, 55, gui.EASING_LINEAR, 1.5, 0, function()
    gui.animate(node, fill_angle, 340, gui.EASING_LINEAR, 1.5)
end)

I see, I think in this case using custom easing may be what you are looking for. You could essentially control the speed of each element (rotation and fill angle) of gui.animate() over the set time.

1 Like

It works only once time) No loop)

Okay, I will try later)

Looks like gui.EASING_INSINE is close to what you need. Also custom easing is the proper way to do but if you just need loop base on your solution then you can put it in timer.delay to check if it’s done one round then start animation again.

2 Likes

It was an example. You can replace the callback with a recursive function, that always calls the animation, with the callback function again, with new parameters. E.g.

function init(self)
    local node = ...
    local function play_anim()
        local angle = ... e.g. calc from self
        local duration = ...
        gui.animate(node, "fill_angle", angle, gui.EASING_LINEAR, duration, 0, play_anim)
    end
    play_anim()
end
3 Likes

It works
Thanks!

So, now I will think about how to do this loading better! )

1 Like

this variant is more difficult but I’ll take a note.
thanks!