Compiler Conditionals
EditThe Haxe compiler provides a robust solution for cross-platform development where you can use operators to define what targets receive your code. This functionality is invaluable for HaxeFlixel since we are targeting native mobile / desktop and web targets, all with different capabilities.
Conditional Compilation in the Haxe Manual
A basic example may include logic like this:
#if desktop // desktop only code #elseif mobile // mobile only code #end
Conditionals relevant to your HaxeFlixel games may include:
mobile
,desktop
,web
ios
,android
,windows
,mac
,linux
,html5
flash
,cpp
,neko
,js
Multiple targets can be used together:
#if (mac || linux || android) // code specific for these platforms #end
To define your own it is as easy as adding to your Project.xml
:
<haxedef name="magic" />
Now this will work:
#if magic // Create a dragon #end
Since Haxe lets you use some logic with the conditionals you can enable something just for mobile, as in:
<haxedef name="magic" if="mobile"/>