سؤال

In the impact.js framework, what is the structure of level objects produce by the Weltmeister level editor ? The most information I was able to find on this is the documentation for ig.game.loadlevel, but it is very limited. In particular what is the meaning of the conent of a layer's data property ?

هل كانت مفيدة؟

المحلول

The example from the docs:

{
    entities: [
        {type: "EntityClassName", x: 64, y: 32, settings: {}},
        {type: "EntityClassName", x: 16, y: 0, settings: {}},
    ],
    layer: [
        {
            name: "background1",
            tilesetName: "media/tiles/biolab.png",
            repeat: false,
            distance: 1,
            tilesize: 8,
            foreground: false,
            data: [
                [1,2,6],
                [0,3,5],
                [2,8,1],
            ]
        },
    ]
}

The level object has 2 sections, the entities and layers, both of which are arrays. The entities array contains entities that will spawned during level load. In the example above this is equivalent to calling ig.game.spawnEntity(EntityClassName, 64, 32, {})

The objects in the layers array create either an ig.BackgroundMap or an ig.CollsionMap, depending on the name of the map. If the name is "collision", then the game will create a ig.CollisionMap at ig.game.collisionMap. If it's anything else, then it will create an ig.BackgroundMap and add it to the ig.game.backgroundMaps array.

The data property of the layer structure is the tile map itself. The array determines which tile from the tileset to draw.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top