1. Home
  2. Game dev
  3. Haxe in-game API
  4. Rendering

Rendering

LDtk Haxe API supports the following game engines:

To render a level, you have to render its individual layers. In supported game engines, you typically have to do something like below.

Heaps.io

// Read project JSON
var project = new LdtkProject();

// Get level data
var level = project.all_levels.West;

// Get level background image
if( level.hasBgImage() ) {
	var background = level.getBgBitmap();
	myScene.addChild( background );
}

// Render an auto-layer 
var layerRender = level.l_Cavern_background.render();
myScene.addChild( layerRender );

HaxeFlixel

// Read project JSON
var project = new LdtkProject();

// Get level data
var level = project.all_levels.West;

// Get level background image
if( level.hasBgImage() )
	myFlxSpriteGroup.add( level.getBgSprite() );

// Render a layer
level.l_Cavern_background.render( myFlxSpriteGroup );