I have an animation the makes a black square fade in and out that I want to play while loading and unloading collections its a gui animation is this possible
This is what I’m thinking
msg.post(unload current collection)
play animation
-- wait for animation stop
msg.post(load new collection)
sorry this took so long but here is the code. i changed something not sure what but now it plays half the animation once then glichly does it any time after that.
function on_message(self, message_id, message, sender)
if message_id == hash("play") then
gui.set_enabled(gui.get_node("box_1"), true)
gui.animate(gui.get_node("box_1"), 'color.w', 1, gui.EASING_LINEAR, 0.5, 0, function ()
msg.post("/proxys#loader", "load")
gui.set_enabled(gui.get_node("box_2"), true)
gui.set_enabled(gui.get_node("box_1"), false)
gui.animate(gui.get_node("box_2"), "color.w", 0.5, gui.EASING_LINEAR, 0.5, 0, function ()
gui.set_enabled(gui.get_node("box_2"), false)
end)
end)
end
end
this is what i want it to be doing
animate box_1 to alpha 1
show box_2
hide box_1
init/enable new collection
animate box_2 to alpha .5
hide box_2
I’m looking at this on my phone at the moment but it looks like the code should work fine.
the issue seems to be that (at least the piece of code you shared) you don’t “reset” the animated values after the animation is done:
when you animate the alpha of the node, that final value of the animation (in this case 1) becomes the new value of the node
when you enable the node again the node has alpha of 1 and the animation it’s actually playing but it’s animating “color.w” from 1 to… 1 so nothing really changes
when you disable the node you should also reset back to 0 (or whatever you need it to be) the property
animate box_1 to alpha 1
show box_2
hide box_1
SET ALPHA OF box_1 BACK TO 0
init/enable new collection
animate box_2 to alpha .5
hide box_2
SET ALPHA OF box_2 BACK TO 0