Skip to content

Instantly share code, notes, and snippets.

@awreese
Last active December 20, 2021 05:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save awreese/69bdfb99d88c0a680c370e16304aef87 to your computer and use it in GitHub Desktop.
Save awreese/69bdfb99d88c0a680c370e16304aef87 to your computer and use it in GitHub Desktop.
CastleDB integration into HaxeFlixel Project (HaxeDevelop, HTML5)

After following the castledb haxelib package installation instructions...

Steps:

  1. From HaxeDevelop, Project->New Project, select 'HaxeFlixel Project'

  2. Open CastleDB, create/edit sheets, save into 'assets/data/XXX.cdb' where XXX is your db name

  3. Create 'Data.hx' file per the castledb instructions with the following line:

private typedef Init = haxe.macro.MacroType < [cdb.Module.build("assets/data/XXX.cdb")] > ;

  1. Open 'Project.XML' and add these two entries under the Libraries section:
<haxelib name="castle"/>
<haxeflag name="-resource" value="assets/data/XXX.cdb" />
  1. Import Data.hx and instantiate your dbase in Main.hx:
...
import xxx.xxx.xx.Data;

class Main extends Sprite {

  public function new() 	{
    ...
    #if js
    Data.load(haxe.Resource.getString(AssetPaths.XXX__cdb));
    #else
    Data.load(null));
    #end
    trace(Data.XXX);
    ...
  }
}
@TripleSmeven
Copy link

TripleSmeven commented Jan 2, 2021

Thank you so much! Saved me from hours of headache. I tried following the example they have at https://github.com/ncannasse/castle/blob/master/src/test/Test.hx, but I just couldn't get it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment