-
The official Haxe sources:
- https://haxe.org/manual/macro.html
- http://api.haxe.org/haxe/macro/
- http://code.haxe.org/category/macros/
Getting better all the time, this is the definitive guide though quite meaty and requires a good couple of passes before things make sense. Learn from simple examples and practicing, use the manual as a reference.
-
Macronauts: Macro workshop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Custom flambe embed for JavaScript-target only. | |
* Author: Mark Knol - http://blog.stroep.nl | |
*/ | |
var flambe = {}; | |
/** | |
* Embed a Flambe game into the page. | |
* | |
* @return True if the game was successfully embedded. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
import haxe.web.Dispatch; | |
import haxe.web.Request; | |
import php.Lib; | |
/** | |
Dispatch Example | |
* Make sure `mod_rewrite` is enabled | |
* You can add any `doBla` in Routes and it becomes an url /bla | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package temple.components; | |
import flambe.Component; | |
/** | |
Dispose its owner entity after a given delay. | |
Example: | |
`myEntity.add(new AutoDisposer(5);` | |
Example with callback: |
instruction: look for condition in code like
if (xx == yy)
replace with
if (xx = yy)
color to hex http://try.haxe.org/#F5127
zip test http://try.haxe.org/#6ad3E
loops without loops http://try.haxe.org/#02FF0
StringTools.eregReplace http://try.haxe.org/#C6d8F
Random haxelib generator https://try.haxe.org/#C985a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Main { | |
static function main() { | |
addConsoleLogViewer(); | |
} | |
public static inline function addConsoleLogViewer(align = "bottom", minimized = true, totalItems = 45) { | |
#if consolelogviewer | |
var script = js.Browser.document.createScriptElement(); | |
script.type = "text/javascript"; | |
script.src = 'https://markknol.github.io/console-log-viewer/console-log-viewer.js?align=$align&minimized=$minimized'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package temple.utils; | |
import flambe.System; | |
/** | |
* @author Mark Knol [http://blog.stroep.nl] | |
*/ | |
class ExternalUtil | |
{ | |
#if air | |
public static var airBrowser:AirBrowser = new AirBrowser(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _connection:SignalConnection; | |
override public function onStart() | |
{ | |
// grap HeartBeat component somewhere in parent entities | |
var heartBeat = owner.getFromParents(HeartBeat); | |
// listen to it | |
_connection = heartBeat.beat.changed.connect(onBeatChanged); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nl.stroep.games.components; | |
import flambe.animation.AnimatedFloat; | |
import flambe.Component; | |
import flambe.util.Value; | |
/** | |
* @author Mark Knol [http://blog.stroep.nl] | |
*/ | |
class HeartBeat extends Component |