Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon
18. July 2018

The Defold Game Engine just released version 1.2.133.  The 1.2.133 release contains new features including the ability to live update aspects of your game, making it possible to push game updates out for published games without having to resubmit to the App Store.  This release also added hot reload support of collections, enabling you to make changes on the fly while running on devices.  If you are interested in learning more about the Defold Engine, be sure to check out our complete tutorial series available here.

Details from the release announcement:


  • DEF-3323 - Added: Collection hot reload support.
  • DEF-2411 - Added: Liveupdate store and verify manifest.
  • DEF-3375 - Fixed: Fixed crash when calculating particle instance emitter count
  • DEF-3330 - Fixed: sys.get_save_path now uses the platform path characters.
  • DEF-3359 - Fixed: Optimized engine size a bit by adding “-fno-rtti”.
  • DEF-3283 - Fixed: Try to resume WebAudio on mouse/touch interaction (and also handle a null DefoldSoundDevice)
  • DEF-3352 - Fixed: Native Extensions: Added support for Objective-C flags -f[no-]objc-arc and -f[no-]objc-arc-exceptions.

Work in progress

We’ve started with the new feature of caching the uploaded files/libraries to the extension build server.
This should improve turnaround times a lot as well as saving bandwidth for certain users.

We are also currently upgrading our Facebook SDK to the latest version.

GameDev News

23. April 2018

A new version of the Defold game engine was released, version 1.2.126.  The nicest new feature of this release is the ability to do side by side editing in the Defold Editor.  The Defold Engine is a 2D lua powered free engine from King.  If you are interested in learning to use the Defold Engine, be sure to check our tutorial series available here.Defold

Details from the release notes:


  • DEF-3137 - Added: Added dmExtension::RegisteriOSUIApplicationDelegate() to Native Extension SDK
  • DEF-3024 - Fixed: Renamed (internal) AxTls symbols with a namespace to avoid libcrypto/libssl clashes
  • DEF-3146 - Fixed: Fix win32 accumulating error in dt when “variable_dt” checked in game.project
  • DEF-3161 - Fixed: Set content length explicitly to zero for 204 (no content) responses
  • DEF-3237 - Fixed: Improved error handling for extension errors on Win32
  • DEF-3216 - Fixed: factory.create() now allows nil for the properties argument
  • DEF-3218 - Fixed: Fixed rare assert when adding and deleting many objects during the same frame
  • DEF-3238 - Fixed: Reenabled logging when using lldb


  • DEFEDIT-1312 - Added: Side-by-side editing
  • DEFEDIT-1345 - Fixed: Defold 1.2.124 not launching on macOS High Sierra 10.13.4
  • DEFEDIT-1348 - Fixed: Add exception printing & logging during application startup
  • DEFEDIT-1349 - Fixed: Add util directory to reflection check build step
  • DEFEDIT-1350 - Fixed: The debugger is no longer working
  • DEFEDIT-1351 - Fixed: Shift+Enter from the Find field should Find Previous in code editor and console
  • DEFEDIT-1352 - Fixed: Undo after auto-complete no longer removes the whole line
  • DEFEDIT-1353 - Fixed: Text selection almost invisible when searching
  • DEFEDIT-1355 - Fixed: Error when syncing new project from editor
  • DEFEDIT-1356 - Fixed: Error when changed a value (scale) on a template node and then tried to reset it
  • DEFEDIT-1357 - Fixed: AssertionError when trying to attach to a running engine while building
  • DEFEDIT-1358 - Fixed: Breakpoints no longer get copied when you make new lines on a line with a breakpoint
  • DEFEDIT-1359 - Fixed: You can now mouse click to select autocomplete result
  • DEFEDIT-1360 - Fixed: Correctly syntax-highlight numbers inside all-caps Lua constants
  • DEFEDIT-1361 - Fixed: Lua keywords inside strings will no longer trigger indentation changes

GameDev News

9. April 2018


Version 1.2.125 of the Defold Game Engine was just released.  This release is primarily a bug fix release.  If you’ve never heard of it, Defold is an excellent 2D game engine from King that is free for developers to use.  You can learn more about working with Defold in our tutorial series available here.  In addition to the release, there was also a new incredibly handy plugin released by the community named Moku, described below.

Details of the release:


  • DEF-3185 - Added: Added projection helper functions to the default render script
  • DEF-3061 - Fixed: HTML5 rendering issue for Safari.
  • DEF-3209 - Fixed: Multitouch crash on iOS when using more than supported number of touches.
  • DEF-3206 - Fixed: Stopping all playing particlefx on a single particlefx GUI node.
  • DEF-3233 - Fixed: iOS11: App now requests priority over system gestures (i.e. touches at edges)
  • DEF-3217 - Fixed: The SIGABRT signal will now generate a _crash log.
  • DEF-3215 - Fixed: dmLog* functions on iOS now use NSLog.
  • DEF-3162 - Fixed: Changed what part of the script filepath is reported on Lua errors.
  • DEF-3184 - Fixed: Improved link errors for native extensions on Win32.
  • DEF-3197 - Fixed: Resource hashes does not include the factory base path.

Additionally there was a powerful new extension released for the Defold engine.  Moku is a new Defold extension that brings auto-tiling and pathfinding to the Defold engine.

  • Bitmask auto-tiling partially based on the method outlined here: How to Use Tile Bitmasking to Auto-Tile Your Level Layouts. Supports both simple (4-bit) and complex (8-bit) auto-tiling. Can be used in conjuction with defold tilemaps, or your own custom, game-object based maps.
  • AStar pathfinding with support for options such as heavy diagonals, different heuristics, etc
  • Assorted convenience functions including cell picking


A great deal more information, as well as a download link, is available here.

GameDev News

15. January 2018

Defold technical artist Martin Dahlin just released the Photoshop extension they use in house at King for exporting GUI designs from Adobe Photoshop to the Defold game engine.  The extension enables you to export such information as layer name, size and position, with additional data such as pivot position and slice9 properties stored on a per layer basis.  The results are ultimately exported in Defold’s .gui format.


You can learn more about the extension here.

GameDev News

21. February 2017


Somewhat delayed from the rest of the Defold Engine tutorial series, I realized there was a major gap in subjects we covered... GUI programming.  Defold actually has some really solid UI functionality built in, and in this tutorial we are going to look at the basics of handling a UI in Defold. Well very conventional in it’s approach, if you’ve gotten accustomed to the Defold way of doing things, you will find Defold’s approach to handling UI remarkably consistent to the way you do just about everything else using the Defold game engine.


As always, there is an HD video version of this tutorial available here.


In this tutorial we are going to implement the simplest of UI, but all of the concepts of a much more complicated interface can easily be extrapolated from what we cover here. We are going to create a UI that pops up when the user hits the ESC key, dimming the existing screen, showing the UI, handling input, then un-dimming the UI.  There is a ton more UI functionality available in Defold, but it should be fairly easy to pick it up once you’ve got the basics down.  So without further ado, lets jump right in.


A UI in Defold consists of two different file types, a .gui and a .gui_script file.  A gui_script file is just a traditional lua script file, but has access to the gui namespace.    Let’s take a step by step look at creating a UI that appears when you hit the ESC key and handles a simple button being clicked.


First we need a font, drag any applicable TTF file to your project.  I personally created a folder called MyFont and dragged it there.  Next I created a Font file in the same folder.



Next open the newly created Font file and select the ttf file you just imported.  Please note that the filter is broken and you should manually type *.ttf to locate your font.


After selecting the font I also increased the size to 30pts.  This is aesthetic and purely optional.


Now that we have a font selected, we need to define an Input map.  I fully describe the process here for more information on how Input Maps work in Defold.  This are the bindings I created:



Next we create our gui file.  Simply select Gui File:



We can use the Gui File to arrange the controls that make up our UI.  Here are the options:



In this simple UI we are simply going to create a button by creating a box then adding a text label to it.  We will also create a label telling the user to click the button.  First we need to set up our font that we created earlier.  In the GUI editor, right click Fonts and select Add Font:



When prompted, select the font you just created:



Now right click Nodes and add a Box.  Once created it can be positioned by hitting W then moving manually.



Next right click the newly created box node and create a child Text field:



Child nodes automatically inherit the position of their parents.  With the Text node selected, lets set it’s font and text, like so:



I also created another Text field telling the user to click the button.  This one in the root of the GUI hierarchy and not parented to the box.  You’re outline should look something like:



While your Gui layout should look something like:



Now that we have a gui file, let’s right a script that will display it.  In our main.collection I simply create a new script and attach it to the default logo objecct.



Now of course we need to add the UI to our game object.  Create a new root level GameObject named UI, then add component from file and select our gui file:



So now you main.collection should look something like:


Now we enter the following code for main.script:

function init(self)
	-- we want focus and to hide our UI until needed".", "acquire_input_focus")"UI","disable");

function on_message(self, message_id, message, sender)
	-- Wait for a message from the UI layer that the UI has been dismissed
	-- un-dim our sprite
    if(message_id == hash("DONE_UI")) then

function on_input(self, action_id, action)
	-- If the user hits the ESC show the UI and dim our sprite
    if(action_id == hash("ESC") and action.released) then
    	-- UI needed now, reenable"UI","enable")


This code does a couple things, first on input it tells Defold we want to get input messages.  We also start out by disabling the UI, by sending it the built-in message disable.  When the user actually hits the escape key, we send a message to re-enable the UI layer.  We also dim the logo sprite so it’s not visually in focus when the UI is active.  Also note we wait for the DONE_UI message to undim our sprite.  This is sent by the UI script, which we will create now.


If you select your .gui file, in the properties you will notice there is a setting for Script.



There is a special kind of script, .gui_script, that is used to control gui objects, the Gui Script File.  Let’s create one in the same folder as our .gui file:



This is a standard lua script, but it has access to the gui namespace.  Once you’ve created your gui_script, set it as the script for your gui file.  Now enter the following script:

function init(self)
	-- We want input control.  AKA, pump input to the UI".", "acquire_input_focus")

function on_message(self, message_id, message, sender)
	-- Expect to be enabled by main when needed.  Acquire focus and set text back to click me
	if(message_id == hash("enable")) then".", "acquire_input_focus")
		gui.set_text(gui.get_node("text"),"Click Me")

function on_input(self, action_id, action)
	-- handle left clicks.  On left click, see if click was within box
	-- if so change our text (this wont actually be seen), disable ourself and pass a message back
	-- to logo that we are done so it can undim itself
	if(action_id == hash("LEFT_CLICK") and action.released == true) then
		local box = gui.get_node("box")
		if(gui.pick_node(box,action.x,action.y)) then
			local text = gui.get_node("text")


This code waits for the enable message then sets input focus so the gui can receive input messages from Defold.  It also illustrates how you could change the text of a component within the gui.  The most important logic is in the on_input event handler.  We wait for the LEFT_CLICK input.  We then check to see if the click was within our box, if so we set the text of our control ( which is somewhat pointless as it’s about to be hidden! ) to “Clicked”, disable our self, release input focus then send the message DONE_UI back to main.script.  Now if you run the code:



Of course we only scratched the surface of what you can do in a Defold gui, but that should certainly get you started!


The Video


See More Tutorials on!

Month List

Popular Comments