Custom adaptative Tiled support for Construct 2

1
  • 12 favourites

Attached Files

The following files have been attached to this tutorial:

.zip

c2tilemapdemo.zip

Download now 156.87 KB

Stats

1,968 visits, 2,760 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Prerequisites

- You need some knowledge with XPath and Xml manipulation.

- You also need some knowledge of Tiled about how it save data.

Introduction

I was looking for a simple way to make maps with Construct 2 so i wrote this adaptative Tiled support sample which actually load a map based on an Xml String (That can be replaced with loading an Xml file instead) generated with Tiled the open source map editor that can be found here : mapeditor.org

What nice about this sample is that its an adaptative way to work with Tiled.

And what the hell is that ?

Its simply showing few events that grab the exact data you want from the map format saved by Tiled then you can adapt it to grab others data in the file itself.

How tiles are pasted in the grid ?

This part is a bit tricky... since Construct 2 doesn't have any runtime support of loading a tileset into a sprite.

You have to actually do it manually into a 'Tile' object. This is a sprite used as a tile. This tile will be copied in each cells of the grid. Each animation frame correspond to each tile of the tileset that have been manually loaded as a strip.

The way Tiled work is that it spread numerical sequential values (called gid) from left to right from the tileset loaded. So if you set the 2th tile from the tileset on the case x=1,y=2 as an example then the value of this case will be 2 which correspond to the 2th tile position from left to right in the tileset. In our case this make things easy for us because we created an object called Tile and we have loaded a frame strip and the behavior of this function act like the same as Tiled when he attribute value to tile of a tileset. So each frame number correspond to a sequential order of the image that represent the tileset. (see in the sample)

This sample include ...

- Loading map width and height.

- Loading custom map property "mapName" as an example.

- Loading tiles properties in a dictionary using this syntax "[tileId]_[key] : [value]".

- Loading map tile position based on the tile data section of the Xml.

Enjoy! If you've got any questions feel free to ask and if this was useful please lets me know :-)

.ZIP

c2tilemapdemo.zip

Download now 156.87 KB
  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!