Maybe I’m misunderstanding coroutines but I’m trying to have it so several different objects can be animated simultaneously and saw the post about coroutines, but the question is how exactly do you activate one in a funciton?
local BOOKSHELF_POSITIONS_X = {480, 960,1440}
local function bookshelf_animate(url, property, playback, to, easing, duration, delay, playback)
local co = coroutine.running()
assert(co, "You must call this function from within a coroutine")
go.animate(url, property, playback, to, easing, duration, delay, function()
coroutine.resume(co)
end,playback)
coroutine.yield()
end
coroutine.wrap(function()
bookshelf_animate("/bookshelf_1", "position.x", go.PLAYBACK_ONCE_FORWARD, BOOKSHELF_POSITIONS_X[1], go.EASING_INQUART, 1)
bookshelf_animate("/bookshelf_2", "position.x", go.PLAYBACK_ONCE_FORWARD, BOOKSHELF_POSITIONS_X[2], go.EASING_INQUART, 1)
bookshelf_animate("/bookshelf_3", "position.x", go.PLAYBACK_ONCE_FORWARD, BOOKSHELF_POSITIONS_X[3], go.EASING_INQUART, 1)
end)()
local function set_book_behind_bookshelf()
BOOKSHELF_POSITIONS_X = minigames.shuffle(BOOKSHELF_POSITIONS_X)
-- how to call the coroutine?
end
Thanks to anyone in advance who replies.