Skip to content

Instantly share code, notes, and snippets.

Working from home

Kino KinoAR

Working from home
View GitHub Profile
KinoAR / SetScreenPosition.hx
Created May 2, 2021
An example extension for translation of a screen position into a world position for FlxObjects.
View SetScreenPosition.hx
import flixel.FlxCamera;
import flixel.FlxObject;
//Sets the screen position of a FlxObject using setPosition(which is in world coordinates)
function setScreenPosition(obj:FlxObject, point:FlxPoint, ?camera:FlxCamera) {
if (camera == null) {
camera =;
if (obj.pixelPerfectPosition) {
KinoAR / FlixelExample.hx
Created May 2, 2021
Example Function for getting the Screen Position. This is directly from the Flixel Code Base.
View FlixelExample.hx
* Call this function to figure out the on-screen position of the object.
* @param Point Takes a `FlxPoint` object and assigns the post-scrolled X and Y values of this object to it.
* @param Camera Specify which game camera you want.
* If `null`, it will just grab the first global camera.
* @return The Point you passed in, or a new Point if you didn't pass one,
* containing the screen X and Y position of this object.
public function getScreenPosition(?point:FlxPoint, ?Camera:FlxCamera):FlxPoint
KinoAR / FlxSignalExample.hx
Last active May 1, 2021
An example of a FlxSignal in action.
View FlxSignalExample.hx
import flixel.util.FlxSignal;
// for signals that don't need data, use FlxSignal
var signal = new FlxSignal();
// for signals that need data, use FlxTypedSignal with the correct function type
var stringSignal = new FlxTypedSignal<String->Void>();
function noParamCallback() {
trace('Dispatched void event');
KinoAR / EnumDirection.hx
Created Apr 21, 2021
Haxe simple example of using enums.
View EnumDirection.hx
enum Direction {
function main() {
KinoAR / PipeRest.hx
Last active Apr 21, 2021
Haxe Simple Pipe Example
View PipeRest.hx
import haxe.Rest;
function main() {
var result = pipe('A',
(val:String) -> val.toUpperCase(),
(val2:String) -> val2 += " " + "World");
trace(result); //A World
KinoAR / SumRest.hx
Created Apr 21, 2021
Haxe Rest Summation Example
View SumRest.hx
import haxe.Rest;
function main() {
trace(sum(1, 2, 3));
trace(sum('Hello', ' World'));
function sum( {
var result = null;
for(element in rest) {
KinoAR / ExternExample.hx
Created Apr 18, 2021
Example extern class taking from our own LunaTea development code.
View ExternExample.hx
//Expose metatag is used to make sure that when the code is being referenced in the target language it'll be exposed
//for user's to override. I use this in JS to allow for modification, which is core to RPGMakerMV/MZ.
//Native metatag is used to make sure that when the code is compiled it uses the proper name.
//Native works both on classes and fields, which you can see for the x, y fields below.
extern class Point extends pixi.core.math.Point {
KinoAR / PathingExample.hx
Created Apr 11, 2021
How To Setup Pathing For a FlxSprite
View PathingExample.hx
import flixel.util.FlxPath;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.util.FlxColor;
class Player extends FlxSprite {
public var walkPath:Array<FlxPoint>;
public function new(x:Float, y:Float) {
super(x, y);
KinoAR / ObjectPoolingExample.hx
Last active Apr 29, 2021
How to do Object Pooling in Flixel
View ObjectPoolingExample.hx
import flixel.FlxState;
import flixel.FlxSprite;
import flixel.util.FlxColor;
class PlayState extends FlxState {
//bullet group for holding player bullets
public var playerBulletGrp:FlxTypedGroup<FlxSprite>;
public static inline var PLAYER_BULLET_CAP:Int = 20;
override public function create() {
KinoAR / DepotMacros.hx
Last active Mar 29, 2021
Macro for Depot that turns your database elements/spreadsheet rows into a part of your code base.
View DepotMacros.hx
package macros;
#if macro
import haxe.DynamicAccess;
import Types.DepotFile;
import sys.FileSystem;
import haxe.macro.Expr.Field;
import haxe.Json;
import haxe.macro.Context;