Skip to content

Instantly share code, notes, and snippets.

@IBwWG
IBwWG / PlayState.hx
Last active March 5, 2020 20:30 — forked from MSGhero/PlayState.hx
9-Slice Algo Test
package;
import flash.display.BitmapData;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.geom.Rectangle;
import flixel.FlxSprite;
import flixel.FlxState;
/**
@player-03
player-03 / Tiles in View
Last active June 23, 2021 05:43
A demo of how to scroll tiles without creating a new array every frame.
package;
import openfl.Assets;
import openfl.Lib;
import openfl.display.Shape;
import openfl.display.Sprite;
import openfl.display.Tile;
import openfl.display.Tilemap;
import openfl.display.Tileset;
import openfl.events.Event;
@elsassph
elsassph / ResourceGenerator.hx
Created July 3, 2016 13:21
Haxe build macro converting a JSON file into strongly typed, inline/dce friendly, properties
package;
#if macro
import haxe.Json;
import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.Type;
import sys.io.File;
import sys.FileSystem;
@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):
@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
{
@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+");
@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
@magicznyleszek
magicznyleszek / multiply-blending-mode-to-png.md
Created August 20, 2014 11:27
Multiply blending mode to PNG in Photoshop
  1. copy your image (Ctrl+A and Ctrl+C)
  2. make a new document-sized pure-black layer behind it
  3. group the black layer and yor image together
  4. add mask to the group
  5. enter mask edit mode (alt+click on the mask icon/thumbnail)
  6. paste your image in the mask (b/w) and then invert it.
  7. save it as a 24-bit transparent PNG
@nadako
nadako / Main.hx
Last active November 27, 2020 16:08
Signal builder using new Rest type parameter in Haxe
class Main {
static function main() {
var signal = new Signal<Int,String>();
var conn = signal.connect(function(a, b) {
trace('Well done $a $b');
});
signal.dispatch(10, "lol");
}
}
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;