I’m working with a 2D artist on my current project, and he would like to animate a cutscene without having to dive into the code. I noticed Defold has a curve editor but it seems to only work for particles?
Right now it’s a whole bunch of GUI elements that need to translate, rotate, color lerp etc…
In theory I could just use normal sprites if that works better.
There’s nothing that would benefit from skeletal animations or even traditional flipbook animation. Things just need to slide around and fade.
Ok, that has to be driven through Lua code. There are several ways to make this easier.
If you have a lot of complex scenes it might make sense to define a custom way to define these animations as separate data and have code process that.
If it’s not massive, you can define them directly in code. Coroutines can be used to facilitate timing and sequencing. Here’s one example:
go.property("wait", 0)
local function sequence_1(self)
msg.post("some_go", "do_something")
coroutine.yield(1) -- waits 1 sec
msg.post("some_go", "do_something_else")
coroutine.yield(1.5) -- waits 1.5 secs
msg.post("some_go", "do_something_else_entirely")
coroutine.yield(0.5) -- waits 0.5 secs
-- Run sequence again
msg.post(".", "run_sequence_1")
return 0
end
function init(self)
msg.post(".", "run_sequence_1")
end
local function run_sequence(seq)
local status, wait_seconds = coroutine.resume(seq, self)
if status then
go.animate("#", "wait", go.PLAYBACK_ONCE_FORWARD, 1, go.EASING_LINEAR, wait_seconds, 0, function ()
run_sequence(seq)
end)
end
end
function on_message(self, message_id, message, sender)
if message_id == hash("run_sequence_1") then
local co = coroutine.create(sequence_1)
run_sequence(co)
end
end