So I’m making a surprise for someone, who sometimes comes into the room while I’m working. This person will not notice text mentioning them but they would sure notice the graphics I have prepared, so I can only work on that set when they’re not around.
I thought it would be fairly easy to make a quick compile flag that switched to a placeholder library that I could use when they’re around, but it’s trickier than I thought for some reason.
Flash target at the moment, BTW, but I plan to target windows, it’s just faster during development to compile flash.
In my Project.xml (it’s a HaxeFlixel game, but I think it applies to OpenFL since that’s where that xml is processed) I have:
<assets path="assets" unless="SECRET" />
<assets path="secretassets" if="SECRET" />
And then AssetPaths.hx I modify like this:
package;
@:build(flixel.system.FlxAssets.buildFileReferences(#if SECRET "secretassets" #else "assets" #end, true))
class AssetPaths {}
What this does correctly is autocompletion in FlashDevelop: I type “AssetPaths.” and the secret ones come up instead of the regular ones, if and only if I have <haxedef name="SECRET"/>
in my Project.xml. If I don’t have it, I get the regular assets directory’s assets. (I know they should be the same normally, but I made them each have a unique file in them just to test this.)
And the paths returned by AssetPaths are correct, e.g. if I trace AssetPaths.seaweed1__png
with the secret enabled I get secretassets/images/seaweed1.png
.
The problem is, they don’t seem to be included in the compiler output, because then I get runtime errors in the haxeflixel debug console saying things like [ERROR] Could not find a BitmapData asset with ID 'secretassets/images/seaweed1.png'.
and the image gets replaced with a generic haxeflixel logo placeholder.
Is there a ‘right way’ to get this to work, or am I once again trying something a little too fancy?