ldtk
ldtk copied to clipboard
[SUGGESTION] Hot Reloading in Haxe
I don't know if this is a limitation of Haxe macros, but there's been some investigation into hot reloading levels (especially with flixel) in LDTK. This would significantly cut down on dev time as it'd remove the need for constant recompiling to regen the macro. This is for situations where assets aren't embedded of course.
Could it be possible?
Hot reloading should work in Haxe through the official LDtk Haxe importer. Here is an example from GameBase:
https://github.com/deepnight/gameBase/blob/79c70ea035d096c6282846b181997749ace67032/src/game/assets/Assets.hx#L60
what it does in short:
- check if the ldtk is in the res subfolder (where assets belong)
- watch the file for changes
- if any change happen (in the watch callback), wait for 0.2s before actually reloading the file. This prevents some deadlocks when trying to load a file while it's being saved (happens for large projects)
- get the new raw JSON string (through getText)
- call parseJson() with this new string
- notify the game that the LDtk data was reloaded
the idea should be the same in HF, but using their specific asset system