Start multiple animations at the same time

Is it possible to start multiple animations at the same time?

    gui.animate(play_button_node, gui.PROP_SCALE, vmath.vector3(0.7,0.7,1), gui.EASING_OUTBOUNCE, 0.5, 0.5, nil, gui.PLAYBACK_ONCE_FORWARD)
    gui.animate(play_button_node, gui.PROP_SCALE, vmath.vector3(0.5,0.5,1), gui.EASING_LINEAR, 1, 1.5, nil, gui.PLAYBACK_ONCE_FORWARD)

I want to start scale up / scale down animation without complete function. Means start scale up animation and start scale down animation with delaying 1.5s (when first animation is completed).

No, that won’t work. You need to chain them with complete functions or use a coroutine to chain them:

local function gui_animate(node, property, to, easing, duration, delay, playback)
	local co = coroutine.running()
	assert(co, "You must call this function from within a coroutine")
	gui.animate(node, property, to, easing, duration, delay, function()
		coroutine.resume(co)
	end,playback)
	coroutine.yield()
end

coroutine.wrap(function()
	gui_animate(play_button_node, gui.PROP_SCALE, vmath.vector3(0.7,0.7,1), gui.EASING_OUTBOUNCE, 0.5, 0.5, gui.PLAYBACK_ONCE_FORWARD)
	gui_animate(play_button_node, gui.PROP_SCALE, vmath.vector3(0.5,0.5,1), gui.EASING_LINEAR, 1, 0.5, gui.PLAYBACK_ONCE_FORWARD)
end)()
2 Likes