-
Notifications
You must be signed in to change notification settings - Fork 17
Home
- Install Haxe.
- Install this library from Haxelib:
haxelib install hxdefold
- Run the following command at the root of your Defold project:
haxelib run hxdefold init
The above should prepare the following for you:
- A sample script class
src/Hello.hx
. - A
build.hxml
that should be used to build the project using:haxe build.hxml
Compiling Haxe at this point will generate a Hello.script
file, which can be added to a game object in the Defold editor!
Every time the Haxe source files are updated, haxe build.hxml
needs to be called before re-building the game in the Defold editor.
However, it is not necessary to do it manually everytime.
Defold supports defining editor lifetime hooks, and an on_build_started
hook can be used in this case to always call haxe build.hxml
before the game is build through the editor.
-- hooks.editor_script
local M = {}
function M.on_build_started(opts)
return {
{
action = "shell",
command = { "haxe", "build.hxml" }
}
}
end
return M
Don't forget that after editing the hooks.editor_script
file, it is necessary to reload it either by restarting the Defold editor or by using Reload editor scripts
from the toolbar.
The files generated by Haxe (namely main.lua
, .script
files etc) should be treated as artifacts, and not checked into version control.
Below is an example of what your .gitignore
should probably look like.
# Defold stuff
/.internal
/dump
dmengine_headless.exe
dmengine_release.exe
dmengine.exe
SteamEmu/
.externalToolBuilders
.DS_Store
Thumbs.db
.lock-wscript
*.pyc
.project
.cproject
builtins
manifest.private.der
manifest.public.der
# Generated files
/scripts
/bit32.lua
/luv.lua
/socket.lua
/main.lua
# Artifacts
/build