openfl-tiled-flixel

Experimental glue to use openfl-tiled with HaxeFlixel
https://github.com/Kasoki/openfl-tiled-flixel

To install, run:

haxelib install openfl-tiled-flixel 0.0.5 

See using Haxelib in Haxelib documentation for more information.

README.md

openfl-tiled-flixel

Experimental glue to use openfl-tiled with HaxeFlixel

Reporting Issues

If you want to report issues please use the openfl-tiled issue report

Install openfl-tiled-flixel

haxelib install openfl-tiled-flixel

Please note that this package depends on openfl-tiled.

Usage

You just need to use FlxTiledMap instead of TiledMap:

var map = FlxTiledMap.fromAssets("assets/map.tmx");

this.add(map); // FlxTiledMap is a FlxGroup

Each layer is a FlxGroup of FlxSprites (each tile is a FlxSprite) which are not active (which means that the update method is not called). If you want to make a layer active to use it e.g. for collision detection read the snippet below:

// TODO: add flixel import statements here
import openfl.tiled.FlxTiledMap;
import openfl.tiled.FlxLayer;

class TiledTestState extends FlxState {
	
	private var map:FlxTiledMap;
	private var sprite:FlxSprite;
	
	// FlxLayer is a FlxGroup of tiles
	private var colliderLayer:FlxLayer;
	
	public override function create():Void {
		super.create();
		
		map = FlxTiledMap.fromAssets("assets/map/test.tmx");
		
		sprite = new FlxSprite(30, 30);
		sprite.makeGraphic(32, 32, FlxColor.RED);
		
		sprite.acceleration.y = 200;
		
		// get the layer named "collider"
		colliderLayer = map.getLayerByName("collider");
		
		// set the layer to active (update method will be called -> collision detection will be enabled)
		colliderLayer.setActive(true);
		
		this.add(map);
		this.add(sprite);
	}
	
	public override function destroy():Void {
		super.destroy();
	}
	
	public override function update():Void {
		super.update();
		
		FlxG.collide(sprite, colliderLayer);
	}
}

Licence

openfl-tiled-flixel is licenced under the terms of the MIT licence.

Contributors
kasoki
Version
0.0.5
Published
4 years ago
License
MIT

All libraries are free

Every month, more than thousand developers use haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on Github!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on Github