# DefAnimator, visual animator for Defold

**URL:** <https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772>\
**Category:** Dev diaries\
**Created:** [December 24, 2016, 12:19pm UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772 "2016-12-24T12:19:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sven/32/1086_2.png) [@sven](https://forum.defold.com/u/sven)\
**Post date:** [December 24, 2016, 12:19pm UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/1 "2016-12-24T12:19:51Z")

</div>

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** 🙂

### Screenshot

 ![](https://forum-defold-uploads.b-cdn.net/original/2X/f/fb8644bb797202d2b5b59ed33632bc7ed991b1f6.png)

### Video

[http://forum.defold.com](http://forum.defold.com):/uploads/default/original/2X/2/21e09c9b794c40191a4dc8c2f6e13639d436c16e.mov

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

```Lua
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](https://github.com/andsve/dirtylarry), with some modifications and custom “theme”.
- Some OS native interaction using LuaJit FFI, including:
  - Native “Save/Open File” dialogs using [defold-dialogs](https://github.com/andsve/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](https://forum-defold-uploads.b-cdn.net/original/2X/e/efddcf6e00009236ce6346d2842f8f9f63e86723.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.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [December 24, 2016, 1:03pm UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/2 "2016-12-24T13:03:23Z")

</div>

This is a really brilliant showcase of what can be done with Defold and Lua. Well done Sven!

---

<div class="post-metadata">

**Author:** ![88.josh](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/88.josh/32/20137_2.png) [@88.josh](https://forum.defold.com/u/88.josh)\
**Post date:** [December 24, 2016, 3:48pm UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/3 "2016-12-24T15:48:22Z")

</div>

I am really looking forward to checking this out.

---

<div class="post-metadata">

**Author:** ![AGulev](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/agulev/32/4541_2.png) [@AGulev](https://forum.defold.com/u/AGulev)\
**Post date:** [December 26, 2016, 1:10pm UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/4 "2016-12-26T13:10:52Z")

</div>

I try to use your program.  
When I clicked to “Save As” nothing happens.

---

<div class="post-metadata">

**Author:** ![sven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sven/32/1086_2.png) [@sven](https://forum.defold.com/u/sven)\
**Post date:** [December 26, 2016, 1:34pm UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/5 "2016-12-26T13:34:25Z")

</div>

Whoops, my bad! Fixed and updated the Zip in the original post, but here is a direct link: [DefAnimator.zip](https://defold-forum-bucket.nbg1.your-objectstorage.com/original/2X/e/efddcf6e00009236ce6346d2842f8f9f63e86723.zip)

---

<div class="post-metadata">

**Author:** ![gianmichele](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/gianmichele/32/24028_2.png) [@gianmichele](https://forum.defold.com/u/gianmichele)\
**Post date:** [October 3, 2019, 10:29am UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/6 "2019-10-03T10:29:37Z")

</div>

Eheh was searching for something else and this came back.

Wish we had something similar in the editor 😉 😉

---

<div class="post-metadata">

**Author:** ![TheKing0x9](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/theking0x9/32/13588_2.png) [@TheKing0x9](https://forum.defold.com/u/TheKing0x9)\
**Post date:** [October 3, 2019, 11:05am UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/7 "2019-10-03T11:05:05Z")

</div>

I can die for it 🗡 (and then respawn to use it 👻 ) 😉

---

<div class="post-metadata">

**Author:** ![COCO](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/coco/32/38692_2.png) [@COCO](https://forum.defold.com/u/COCO)\
**Post date:** [October 4, 2019, 11:48pm UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/8 "2019-10-04T23:48:13Z")

</div>

what’s going on about it now?  
after 3 years？

---

<div class="post-metadata">

**Author:** ![88.josh](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/88.josh/32/20137_2.png) [@88.josh](https://forum.defold.com/u/88.josh)\
**Post date:** [October 6, 2019, 6:53pm UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/9 "2019-10-06T18:53:40Z")

</div>

hi! Is there any chance I could get a working version of this? The archive is damaged and can’t be opened (not the zip, the app itself)

---

<div class="post-metadata">

**Author:** ![sven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sven/32/1086_2.png) [@sven](https://forum.defold.com/u/sven)\
**Post date:** [October 7, 2019, 7:55am UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/10 "2019-10-07T07:55:32Z")

</div>

Can you try this version @88.josh?  
[animator\_0.2.zip](https://defold-forum-bucket.nbg1.your-objectstorage.com/original/3X/9/4/949d5ffc3db58502fb2bb446173b41323ad440c4.zip) (2.4 MB)

@COCO haven’t made any progress on this, I really should release it open source. 🤔

---

<div class="post-metadata">

**Author:** ![88.josh](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/88.josh/32/20137_2.png) [@88.josh](https://forum.defold.com/u/88.josh)\
**Post date:** [October 7, 2019, 8:16am UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/11 "2019-10-07T08:16:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sven/32/1086_2.png) [@sven](https://forum.defold.com/u/sven)\
**Post date:** [October 7, 2019, 8:18am UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/12 "2019-10-07T08:18:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![88.josh](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/88.josh/32/20137_2.png) [@88.josh](https://forum.defold.com/u/88.josh)\
**Post date:** [October 7, 2019, 8:20am UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/13 "2019-10-07T08:20:59Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![sven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sven/32/1086_2.png) [@sven](https://forum.defold.com/u/sven)\
**Post date:** [October 7, 2019, 8:32am UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/14 "2019-10-07T08:32:45Z")

</div>

Ahhhh, right! Now I remember, I had to do some hack to get dynamic images to load. Let me see if I remember what I actually did. 🙂

---

<div class="post-metadata">

**Author:** ![sven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sven/32/1086_2.png) [@sven](https://forum.defold.com/u/sven)\
**Post date:** [October 7, 2019, 8:46am UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/15 "2019-10-07T08:46:39Z")

</div>

Managed to remember what I did last time, actually wrote a thing about it apparently. ([Loading dynamic libraries from inside macOS .app-folders](http://svenandersson.se/2016/loading-dynamic-libraries-from-inside-macos-app-folder.html)) 🙂

Fixed version: [animator\_0.2.1.zip](https://defold-forum-bucket.nbg1.your-objectstorage.com/original/3X/e/5/e53e464782761c81b5d6a8778a18cdb8a4e4c9f2.zip) (2.4 MB)

---

<div class="post-metadata">

**Author:** ![88.josh](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/88.josh/32/20137_2.png) [@88.josh](https://forum.defold.com/u/88.josh)\
**Post date:** [May 16, 2020, 10:04pm UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/16 "2020-05-16T22:04:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ross.grams](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@ross.grams](https://forum.defold.com/u/ross.grams)\
**Post date:** [May 17, 2020, 12:45am UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/17 "2020-05-17T00:45:13Z")

</div>

Release the source, Sven. We will fix it. The Collective has spoken.

---

<div class="post-metadata">

**Author:** ![88.josh](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/88.josh/32/20137_2.png) [@88.josh](https://forum.defold.com/u/88.josh)\
**Post date:** [May 17, 2020, 9:14am UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/18 "2020-05-17T09:14:10Z")

</div>

![15](https://forum-defold-uploads.b-cdn.net/original/3X/9/f/9f4e072ad402ab4876c5e3cdc271bd5bc4be86bb.png)

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

1. the object,
2. the attribute,
3. a nested table with the keyframes and target values

> {  
> "gui.get\_node(“object1”), “position.x”, {0 = 0, 0.5 = 0, 1 = 20}  
> }

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.

Any help?

---

<div class="post-metadata">

**Author:** ![88.josh](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/88.josh/32/20137_2.png) [@88.josh](https://forum.defold.com/u/88.josh)\
**Post date:** [May 17, 2020, 9:20am UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/19 "2020-05-17T09:20:05Z")

</div>

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()

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [May 18, 2020, 11:44am UTC](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772/20 "2020-05-18T11:44:13Z")

</div>

Maybe you could push your project on Github so we can help developing it? 😉

P.S. I wish there could be more hackathon days in Defold team! 😍 Maybe even we can prepare something like that, in community? What do you think? 😉

[Next page](https://forum.defold.com/t/defanimator-visual-animator-for-defold/3772.md?page=2)
