As some of you might have read on our public slack, we have had two hack days this week where we had the opportunity to do some fun projects using Defold. I decided to do something I have been thinking about for a while, a tool created in Defold! So without a long introduction, let me introduce my hack result; DefAnimator 0.1
DefAnimator is a (super non-official ;)) visual animation tool built as a regular Defold project. The idea is that you can use it to author simple GO animations visually with keyframes, then save the animations as Lua-modules and use in your own game/project.
The output from the save functionality creates a Lua module that returns a function consisting of chained go.animation calls.
Example usage
local my_animation = require "my_animation" -- my_animation.lua was saved using the tool and is located in the project directory
function init(self)
my_animation("gameobject_id") -- starts the generated animation on GO /gameobject_id
end
Implementation details
GUI was done using dirtylarry, with some modifications and custom āthemeā.
Some OS native interaction using LuaJit FFI, including:
Native āSave/Open Fileā dialogs using defold-dialogs
Native context menus using a lib Iām planning to release soon-ish.
Future plans
Being able to use DefAnimator as a library in your own project. Meaning that you could in theory just depend on DefAnimator to animate your own GOs (create a .collection with your own GO, add the supplied defanimator.gui and it āShould just work ā¢ā.
Download
I want to release it as open source eventually, but for now here is a (a bit buggy ) OSX version. DefAnimator.zip (2.3 MB)
Known bugs and limitations
The timeline is a bit wonky, you can only select keyframes on the current property you have selected (visualised as lighter gray in the left most column).
Playback preview does not loop.
Playback preview does not handle different easing options, but the saved file will.
Opening/Loading previously saved animations does not work currently.
Okay, I can open the app, but it appears to immediately close. thatās a shame. Iād really love to have a play around with this! donāt worry if itās too much work
Could you try running the binary inside the app folder through a terminal? Animator.app/Contents/MacOS/Animator
You should be able to see the logs there since I build it for debug.
INFO:DLIB: Log server started on port 53029
INFO:ENGINE: Engine service started on port 8001
INFO:ENGINE: Defold Engine 1.2.162 (e07f3bb)
INFO:ENGINE: Loading data from: dmanif:/Users/joshrackstraw/Downloads/animator_0.2/Animator.app/Contents/Resources/game.dmanifest
INFO:ENGINE: Initialised sound device ādefaultā
ERROR:SCRIPT: main/dialogs.lua:5: dlopen(native_libs/nfd, 5): image not found
stack traceback:
[C]: in function āloadā
main/dialogs.lua:5: in main chunk
[C]: in function ārequireā
main/main.gui_script:3: in main chunk
WARNING:RESOURCE: Unable to create resource: /main/main.gui_scriptc
WARNING:RESOURCE: Unable to create resource: /main/main.guic
WARNING:RESOURCE: Unable to create resource: /main/main_generated_1.goc
ERROR:GAMEOBJECT: Could not instantiate game object from prototype /main/main_generated_1.goc.
WARNING:RESOURCE: Unable to create resource: /main/main.collectionc
logout
Saving sessionā¦
ā¦copying shared historyā¦
ā¦saving historyā¦truncating history filesā¦
ā¦completed.
Deleting expired sessionsā¦109 completed.
[Process completed]
Okay, I canāt get this one to work either. And you know what? Iām going to have to make this myself (unless sven can make it open source )
Key features:
Ability to animate tint, scale, euler, position using keyframes along a timeline.
I think thatās it. Even if I have to import images myself in the editor and get the animations out via debug everytime i want to do this, itās still going to be useful for me.
My efforts are not going badly! I have timelines and I can select different objects and different points on the time line. I also have a play button.
the only downside is that I have no idea how to actually do the animations once the play button is pressed. My idea is that for each attribute to animate (i.e. āposition.xā to create a table with
the object,
the attribute,
a nested table with the keyframes and target values
the target animation here would be the position.x waiting for the first half of the animation, then sliding to 20 during the second half. And aside from actually doing the animation, Iād also like to print something like gui.animate(āobject1āā¦) in the debug. And even then i wonāt be able to do automatic easing.
okay got it! like in Svenās example, itās chained animations using callbacks! and that means you CAN do easing! okay WE DONāT NEED THE SOURCE CODE ANYMORE, IāM GONNA MAKE THE SOURCE CODE MYSELF
edit: I DONāT KNOW HOW TO DYNAMICALLY CREATE FUNCTIONS CAN ANYONE HELP
edit: OKAY I THINK I CAN USE A GENERIC FUNCTION AND A COUNTER AND MSG.POST()