Writing a book on Defold


Off-topic but I’d like to comment anyway. Rotation using quaternions is almost a de-facto standard in game engines. Defold also provides support for euler angles, but you should try to get to terms with quaternions.

There’s a go.set_rotation():

-- rotate 45 degrees around the z-axis

There’s also go.set(".", "euler.z") and go.animate(".", "rotation.z", ...)

Not quite. It relies on hashed strings. There’s a difference (performance mainly). If you’re worried about typos and refactoring you can store all hashed message ids in a Lua module. Change in a single place instead of all over. And until we’re adding static code analysis to our internal editor you can use Atom with a Lua linter to get a warning if you’re mistyping a message id reference when you have them stored in a module.


Okay first of all - that was a fast reply. I’m officialy impressed.

With rotate() I mean: rotate x degree / rad from your current rotation. So rotate() is not the same as set_rotation() (which I’m aware of). For the very simple act of rotating a thing from its current rotation the following code is needed:

go.set_rotation(go.get_rotation() * vmath.quat_rotation_z(x_rad))

Which seems ridiculous to me. What I’d like to see is:


Done. That’s the way it’s handled in the Godot game engine.

I couldn’t get rotation using the euler propertie to work for rotations > 90 degree. The game object seemed to get stuck at this value.

Regarding the messaging system - it’s fine for most things, but why isn’t there a method acquire_input_focus()? From a user perspective it just seems so much easier.

But I’ll keep using the engine for the next week or so and see if I can get used to it because I really want this relationship to work out :grinning:


Yes, that’s more cumbersome for sure. I’m not going to deny that. Even though it might be a candidate for an engine provided function there really is nothing stopping you from adding these kind of utility functions in a Lua module.

I agree. I don’t know why really. I usually use this Lua module when I need to deal with user input in Defold:



I’ve been on contract work most of this year but have less obligations now. Editor 2 seems close to release so it’s a good time to put the time in. Glad @britzl could help you!


what happened to this?


Gitbook changed their site to a new version with entirely different features, I’m moving the old text over and also updating it as I go, adding screenshots of new editor, redoing some examples. It is tedious and time consuming and I don’t have a ton of free time right now for how much time it needs so progress is slow.

There’s a lot which has not been seen before like https://www.bookofdefold.com/dive-into-defold/avoider/ but it will all get published eventually…


I see,

I’m slacking off with my self learning of Defold , I think your book could be really good for someone who does not want to be distracted by the Internet(such as me unfortunately).

I’m looking forward for this , thanks for the reply


Yes! Books are great. I spend so much time helping students who would prefer a book, but have been obliged to do online courses.

(Although I think it’s actually an online book)