Big List of Defold Pro Tips!

The road to making juicy buttons - on_input actions : “pressed”, “repeated” or “released” If you want to make juicy buttons then you need to polish them up so they feel good to press. When mouse is hovered make them glow, and scale them up a bit. When mouse is down (but not clicked) make the button shrink, and change its image to a depressed version. Don’t forget to play sounds on hover over / down! Don’t make the button do anything until they have actually fully clicked, their mouse is still hover it, and they let go of their mouse button. This feels the best, though there are some situations where you want instant clicks and not “fully depressed and released while hovering” inputs.

While you’re checking input, you can check for the three actions too

action.pressed – this happens as soon as you click down
action.repeated – while you keep a click held down
action.released – this happens as soon as you released the click

For juicy buttons, you’ll also need to check that their mouse cursor (or finger touch x,y) is still within the rectangle of the button when the action.released goes off. The best buttons stay depressed in a down state as long as the mouse is still pressed down even if it moves out of its rectangle, and while this happens blocks hovers etc. with other inputs until that unique event is finalized. I’m working on an example of a juicy button system for UI that I’ll upload soon.


Hi Pkeod!
In the next release (1.2.79), we’ve fixed the name for the web: “HTML5” (emscripten is the build tool we use, not a platform)

Also, detecting the browser can be done by parsing the “user_agent” field of the sys info. There seems to be a multitude of ways to parse the string, so I’ll just refer to google for more info on how to do it.


Full screen anti-aliasing would be nice.

I’m wondering if Defold team already has some materials / shaders for this? If you use any shaders beyond stock could you share them? Would save me some work.

Shaders for Defold I have working or am preparing. If this area of Defold was expanded (more textures for example - I can’t do texture based bump mapping effects at the moment) more would be possible. I am still newbie too and some are trouble to me so might not make it for now. Also, I’m heavily referencing past made shaders that are publicly available to study.

  • FXAA / SMAA - will try others too
  • Shadows
  • Blurs (a few including directional motion blur, box blur, gaussian blur)
  • Anaglyph 3d (3d glasses effect)
  • Color replacement
  • Inner / Outer Glows
  • Inverted Color
  • Lens Distortions
  • Gradient Map
  • Bloom
  • Emboss
  • Deformations - water, flag, sin wave …
  • Sharpen
  • Hue shift
  • Contrast
  • Mask Color to Transparent - useful in some situations
  • Sepia
  • CRT (a few types)
  • Vignette
  • Dot Matrix
  • Film Grain
  • Noise overlay
  • Scanlines
  • Pixelation
  • Chroma Shift / translation / displacement (can make neat effects)

More is possible but that’s the todo list for now.


I had not even noticed user_agent was already available. Thank you and glad to hear! Is Linux just Linux or? Will update post.

1 Like

Linux is “Linux” yes :slight_smile:


Pre-hashing your hashes.

If you are using hashes often in many places you can optimize some by pre-hashing once, rather than to run hash() on strings over and over as your scripts run. Doing this is easy, and a good practice - at least I assume so!

– Pre-hashing input message hashes
local move_up_hash = hash(“move_up”)
local move_down_hash = hash(“move_down”)
local move_left_hash = hash(“move_left”)
local move_right_hash = hash(“move_right”)

function on_message(self, message_id, message, sender)

if message_id == move_up_hash then



I can definetly see the use of having a much more extended library of shaders/post effects in Defold and those are all good suggestions.

For me personally though I would like to create at least some simple shaders for 3D models (lambert, blinn, phong, ramp, toon) - problem is that I do not have the time.


Yes, hashing action_ids and message_ids is a good idea.


I can try to find some that would be possible to make work.

Many are listed here, and have examples.

This is still mostly new territory for me though, but I can do some tests and see what will work. The reason I want FXAA and SMAA or some AA for post processing that’s fast enough for mobile is because of removing jagged edges from rendering 3d models.

Although FXAA may not work for this specific case.



MSAA might be better. Thoughts? …I don’t know what would look good and be efficient.


Humus (an old colleague) is quite obsessed with AA and his site could be a source of inspiration.


They do seem to be appropriate for what I need. Thank you! I’ll give it a shot getting it to work with Defold.

Been doing some tests and while it does work in some of the model very well the pixel art sections are just textures, so they are not detected in the same way as the geometry edges.

Going to more things next.


Posting code blocks.

I keep forgetting to not use quotes and to use pre-formatted text when posting code blocks. If the code you post doesn’t look right this is probably what’s wrong. Paste the text first, select it, then apply the Preformatted text option from the menu.

But want to know something even better?


function on_message(self, message_id, message, sender)
if message_id == hash(“start_level”) then
– some script tells us to start loading the level"#proxy", “async_load”)
– store sender for later notification
self.loader = sender
elseif message_id == hash(“proxy_loaded”) then
– enable the collection and let the loader know, “enable”), message_id)

Preformatted text / Codeblock

function on_message(self, message_id, message, sender)
    if message_id == hash("start_level") then
        -- some script tells us to start loading the level"#proxy", "async_load")
        -- store sender for later notification
        self.loader = sender
    elseif message_id == hash("proxy_loaded") then
        -- enable the collection and let the loader know, "enable"), message_id)

But want to know something even better? You can turn on a bit of syntax highlighting too and have nice code blocks without needing to indent. Here is how:

function on_message(self, message_id, message, sender)
function on_message(self, message_id, message, sender)
    if message_id == hash("start_level") then
        -- some script tells us to start loading the level"#proxy", "async_load")
        -- store sender for later notification
        self.loader = sender
    elseif message_id == hash("proxy_loaded") then
        -- enable the collection and let the loader know, "enable"), message_id)

Beta builds of Defold

There are publicly available beta builds of Defold.

New stable builds are released every two weeks.

Unless you have a good reason you probably shouldn’t download the betas, especially if you are trying to be productive with a project as it might have serious issues that would stop you! They may be unstable, they may crash more often than stable builds would. Don’t use the unstable alpha / beta builds unless you have a good reason to such as being asked to for testing purposes.

Beta builds for Defold can be download directly here:

(Plus Alpha although I just checked and it says it’s two version behind Stable, but also has the HTML5 system_name fix so maybe bleeding edge but not version number updated? I don’t know)

Current stable builds of Defold, as well as past stable builds, (useful if you build a project in a version that for some reason won’t work in later version…) are here:

Using the auto update feature is the best way to download new versions of Defold, but there may be cases where you need to download again cleanly.

1 Like

Using a custom Android manifest.

In your game.project file there is ability to define a custom manifest file for Android. You may find you need to change some things in the default manifest to fit your project.

If you do need to make changes you must still start with the one shipped with Defold as it is a kind of template.

You can a copy in your Defold folder. Look for it in:


Copy and paste this into your project folder, define it in game.project (found in Android section), and then make any changes you need to.

Keep in mind when you do download updates for Defold you may need to update you Android Manifest file! So pay attention to that and check with a diff compare tool and then pull over any changes into your custom one.

1 Like

iOS has a kind of “manifest” too. It’s called Info.plist

If you want to customize your Info.plist file it’s a good idea to open it with Xcode and edit it there. If you look in your game.project file you’ll see there is a section for iOS. You can define icons, your app’s bundle identifier (, and your custom Info.plist file.


You can copy and paste the template Info.plist file into your Defold project directory. You can manually edit it, or edit with Xcode.

As you prepare your game for launch on iOS you may find you need to customize this file.

Mac builds have an Info.plist file too, and you may need to make a custom version of it as well.


Like with Android manifests, pay attention to new Defold versions if you use customized versions of these files as they may have changes made to them that are required for new Defold features.


Activating native keyboards for iOS and Android, and getting user input since most mobile devices don’t have built in keyboards you will need to activate the native keyboard to allow users to enter text into your game.

To show the native keyboard use


To hide use


More info:

NOTE: You don’t need the virtual keyboard open to detect keys on other platforms. Use the below when you want to enter text into selected text boxes / inputs.

To detect and record text, you need to add a text trigger to your Input Binding game.input_binding file. Its default name is TEXT. Leave at as this

Now when you detect input with on_input() use action.text you can get inputted text.

function on_input(self, action_id, action)
	if action.text then
		input_text = input_text .. action.text

Then you’ll display the text wherever and or store it. Keep in mind user focus and putting text in one place at a time, and checking if you should be looking for text at all.

You will still need to detect actions such as backspace to delete characters (I have yet to test this on mobile so am not 100% sure normal backpsace detection works from virtual keyboard). If you want the user to be able to put their virtual cursor somewhere in the text (like most text editors allow) this is possible but takes a little extra work - a way to do it is to store an offset, and change offset when users touch/click a position in the text (with a visual indicator such as a blinking “|”), and then insert the next character there based on offset.

Read this doc for more info

Super Important! Some Asian language inputs are done in parts to form complete characters. In the case of these, instead of just action.text you will want to use action.marked_text too, and create a text trigger for it too (use drop down on “input”)

There is no manual or documentation on MARKED_TEXT yet so it may need experimentation. Is gui.reset_keyboard related to it?

Based on this, how I assume you use it is that as the user types, you displayed the temporary characters that are in the marked text space, and then when the user finishes typing the final character replaces any of the fragments? So you would need to detect the next action.text and when that happens then clear the action.marked_text temp you added?

Or - you check action.marked_text and if it is true (meaning user entered full character from partials) then you can grab the next character with action.text?

I’ll test this out later to confirm.

This service is good for tests like this

There’s also MAX_TEXT_COUNT but I don’t have a clue what it’s for.

In game.project in the Android category there is an input_method field. The options for it are (default) KeyEvent and HiddenInputField. KeyEvent exists as an older method, and you should probably switch it to HiddenInputField, which has better support for 3rd party keyboard apps that are popular.

Can input.text be used to make custom key bindings? Not really. It can detect textual input, but it can’t detect characters like (afaik) shift, control, alt, or any of the function keys. It also can’t detect state. input.text also can’t detect alt codes.

What we really need is more arbitrary key input detection.

Input.PeekChar too maybe?

For gamepads:
Input.JoyDown( button, gamepad)
Input.JoyHit(button, gamepad)



Don’t create .font files until you’re ready to define a font inside of it.

If you do create a .font and don’t define a font file then if you try to build you’ll likely get a build error.

1 Like

Loving these tips! Keep them coming! Thanks!


This tip goes for a lot of the filetypes you can create in Defold. Materials, tilesources, factories etc Unfortunately the errors are rarely informative. I believe that the upcoming editor will be much better at this.


You can detect if your user (on iOS/Android) is listening to music and disable your game’s audio.

if sound.is_music_playing() then
    for i, group_hash in ipairs(sound.get_groups()) do
        sound.set_group_gain(group_hash, 0)

It’s good to give your users options. If you have an option screen with many options allow them to choose to mute the game’s audio if they are playing audio from another app, but having it mute by default is a good idea.

More info: