Socket
Book a DemoInstallSign in
Socket

ldtk

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldtk

Importer for the LDtk project file format

latest
Source
npmnpm
Version
0.8.7
Version published
Maintainers
1
Created
Source

ldtk-ts

LDtk file format type definitions and import wrapper.

This library provides an API without all the noise of LDtk "editor-only" values, definitions, etc., combined with many utilities to make usage easier.

If you just want the type definitions, they're fully compliant with the schema.

Documentation is available here.

$ npm install ldtk

Usage

Basic usage

import { World } from "ldtk";

World.loadRaw("assets/world.ldtk").then(async world => {
    // You have access to the raw `LDtk` JSON file here
    let currentLevel = world.levels[0];
    for (const layer of currentLevel.layerInstances) {
        console.log(layer);
        // the world is your oyster
    }
})

Using the importer

import { World, LDtk } from "ldtk";

World.fromURL("assets/world.ldtk").then(async world => {
    let currentLevel = world.levelMap["Level1"];
    function loop(time) {
        render(currentLevel);

        window.requestAnimationFrame(loop);
    }
    window.requestAnimationFrame(loop)
});

Versioning table

LDtkldtk-ts
0.7.20.8.6
0.7.10.8.5
<0.7.0not supported

Keywords

ldtk

FAQs

Package last updated on 28 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts