Description

Load JSON file and draw layers in the element of the scene. View Tiled class description for more informations (http://canvasengine.net/doc/?p=editor.tiled)

Usage

Parameters

  • scene {CanvasEngine.Scene}

  • el {CanvasEngine.Element}

    The element containing layers of Tiled

  • url {String}

    Path to JSON file of Tiled Map Editor

Example

Example with Node.js :

Server :

var CE = require("canvasengine").listen(8333),
    Tiled = CE.Core.requireExtend("Tiled").Class,
    Class = CE.Class;

CE.Model.init("Main", {

    initialize: function(socket) {

        var tiled = Class.New("Tiled");
        tiled.ready(function(map) {
            socket.emit("Scene_Map.load", map);
        });
        tiled.load("Map/map.json");

    }
});

Client :

canvas.Scene.New({
    name: "Scene_Map",
    events: ["load"],
    materials: {
        images: {
            tileset: "my_tileset.png"
        }
    },
    load: function(data) {

        var tiled = canvas.Tiled.New();

        tiled.ready(function() {
         var tile_w = this.getTileWidth(),
             tile_h = this.getTileHeight(),
             layer_object = this.getLayerObject();
        });

        tiled.load(this, this.getStage(), data);

    }

});

Discussion