Skip to content

Instantly share code, notes, and snippets.

typedef FlxGraphicAsset = AcceptOneOfFive<String, Class<Dynamic>, CachedGraphics, TextureRegion, BitmapData>;
abstract AcceptOneOfFive<T1, T2, T3, T4, T5>(EitherOfFive<T1, T2, T3, T4, T5>)
{
public inline function new(e:EitherOfFive<T1, T2, T3, T4, T5>)
{
this = e;
}
public var value(get, never):Dynamic;
@jcward
jcward / hxScout testing instructions
Last active August 29, 2015 14:15
Setup testing of hxcpp / hxScout
Instructions for testing hxScout with hxcpp.
FYI, I've tested this using Haxe 3.1.3, OpenFL 2.1.7 (the legacy version, aka _v2, aka not next) in Windows 7. Your mileage may vary. All this is under heavy development, so it may cease working at some point.
1) Git checkout (or download) jcward's hxcpp (integration branch), hxtelemetry, and hxScout:
https://github.com/jcward/hxScout/archive/master.zip
https://github.com/jcward/hxtelemetry/archive/master.zip
https://github.com/jcward/hxcpp/archive/integration.zip
@larsiusprime
larsiusprime / dqbugs.php
Last active August 29, 2015 14:18
A script for calculating the number of "points" in a Github Milestone (using numeric labels as "points" in issues). Written by Adam Perry (@hoursgoby) for Level Up Labs, LLC. milestones.json is an example of the php output, progress.js is an example of the front-end display code
<?php
define("CLIENT_ID", "REDACTED");
define("CLIENT_SECRET", "REDACTED");
define("GITHUB_URL", "ssl://api.github.com");
define("GITHUB_PATH", "/repos/YOUR-NAME-HERE/YOUR-REPO-HERE/");
define("ISSUESTATE_OPEN", "open");
define("OUTPUT_FILENAME", "/path/to/milestones.json");
$milestones = processIssues(loadIssues());
$fp = fopen(OUTPUT_FILENAME, "w+");
@loudoweb
loudoweb / FixTile.hx
Created November 3, 2015 15:56
Fix tile trick to avoid border artifacts between tiles. #haxe #openfl
package;
/**
* Avoid holes or border artifacts between tiles.
* Sometimes the scale by 1.01 trick doesn't work, a greater value should be used. This method finds the correct value for you.
* If you use openfl_legacy, pack your atlas using reduceBorderArtifact option in TexturePacker. There is no need to use this option on openfl_next.
* You should update the scale of your tiles if your resize the screen during the game to always have the best scale value.
* @author loudo
*/
class FixTile
{
package ;
abstract JsonMap<T>({ }) from {} {
public function new() this = {};
public function exists(key:String) return Reflect.hasField(this, key);
@:arrayAccess public function get(key:String) return Reflect.field(this, key);
@:arrayAccess public function set(key:String, value:T):T {
Reflect.setField(this, key, value);
return value;
}
@jasononeil
jasononeil / DispatchTest.hx
Last active December 17, 2015 20:19
A sample to test some more complex routing options of haxe.web.Dispatch. Run with `haxe -x DispatchTest.hx` This is the sample code for this tutorial / blog post: http://jasononeil.com.au/2013/05/29/creating-complex-url-routing-schemes-with-haxe-web-dispatch/
import haxe.ds.StringMap;
import haxe.web.Dispatch;
import haxe.web.Dispatch.DispatchError;
#if sys
import Sys.println;
import Sys.print;
#else
import haxe.Log.trace in println;
import haxe.Log.trace in print;
@Beeblerox
Beeblerox / dumpBits example
Created July 8, 2013 12:17
This is an example of how you can reduce memory usage for Tilesheet class in openfl with dumpBits() method. But you also listen for stage resize event and recreate tilesheet after context loss.
import flash.Lib;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import openfl.Assets;
import openfl.display.Tilesheet;
import flash.display.Graphics;
import flash.events.Event;
class Particle
package;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.filters.ShaderFilter;
import openfl.Lib;
import openfl.events.Event;
import openfl.Assets;
import openfl.display.Sprite;
import openfl.utils.Float32Array;
@mrcdk
mrcdk / Macros.hx
Created March 31, 2016 00:33
@:enum abstract Something(Int) autoInt() macro
import haxe.macro.Context;
import haxe.macro.Expr;
class Macros {
macro public static function autoInt():Array<Field> {
var fields = Context.getBuildFields();
var t = switch(Context.getLocalClass().get().kind) {
case KAbstractImpl(c):
@miltoncandelero
miltoncandelero / JsonClass.hx
Last active July 3, 2018 12:48
Creates typedefs based on a json example variable.
import haxe.Json;
/**
* Toss a Dynamic var and get a typedef declaration! (Inspired by http://json2csharp.com)
* (A bit of code stolen from https://gist.github.com/elsassph/16d3b2597f6a51b5817c2fa97dd7f505)
* @author Milton Candelero (Elemental Code)
*/
class JsonClass
{