Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 1.01 KB

README.md

File metadata and controls

39 lines (29 loc) · 1.01 KB

Tiled Map - Crafty.js plugin for Tiled Map Editor

Tiled Map is a plugin for Crafty.js for loading tiled maps (from Tiled Map Editor) and use them on a Crafty scene.

Usage

Crafty.scene('Main', function () {
  var mapLoader = new Crafty.TiledMap('url/to/tiled/map.json');

  mapLoader.downloaded(function (err, json) {
    // Errors on downloading json comes here.
    if (err) throw err;

    var map = Crafty.e('TiledMap');

    // Create entities based on json;
    map.setTiledMap(JSON.parse(json));

    // Optionally, you can change Crafty camera to follow the given entity,
    //   caching not visible tiles.
    map.cameraFollow(Crafty('Player'));
  });
});

Demo

WIP

Thanks

This plugin is based on Jonas Olmstead's post about tiled maps; and an old crafty.js component for tiled map editor (I couldn't find the link ): )