Using The Haxe Language In the Defold Game Engine

The Haxe programming language is capable of generating code in several other languages, including more recently the Lua programming language.  The Defold game engine is a powerful free 2.5D game engine from King, that we have covered extensively in tutorial series.  It was only a matter of time until the two came together, and that is exactly what has happened.  The hxdefold open source project enables you to program Defold using the Haxe programming language. 

Features

  • Fully typed Defold API with proper compile-time errors and IDE services.
  • Type-safe game object messages and properties with zero overhead.
  • Strengths of Haxe without compromises: powerful type system, meta-programming, static optimizations and cross-target code sharing.

The getting started instructions are pretty straight forward, from the Github page:

  • Install this library (from this repo): haxelib git hxdefold https://github.com/hxdefold/hxdefold
  • Run haxelib run hxdefold init inside your Defold project. It will create a sample Hello.hx script component class and a build.hxml for building it.
  • Read the comments in these files to quickly get some idea.
  • Build with haxe build.hxml to get the lua output.
  • Add Hello.script to your game object in the editor and observe the greeting in the debug console.
  • Proceed with writing well-structured, expressive and type safe code for your Defold game.

The editor won’t become Haxe aware however, so you will still have to build your code externally.

GameDev News


Scroll to Top