New version 2: Like maxY, maxTile lets you change the max tile number. Also fixed bug that started from 3 instead of maxY in reading the X variable.
New version: Instead of need to type for example 0033(or 0033500 including X axis at the end which can be up to unlimited, that’s why there isn’t an maxX variable) as Y, now you can type instead 033(or 033500 including X axis at the end which can be up to unlimited, that’s why there isn’t an maxX variable) as Y with the maxY variable.
That means you can have less or more than 3 digits, not forever 3.
This is an tile map engine made by me I’m using to make Super Tile Ixtipi.
Here’s the code:
buildMap = function (map:Array, maxY:Number, maxTile:Number) {
var i:Number = 0;
while (i<map.length) {
tileHandle = attachMovie("tile_"+map[i].slice(0, maxTile), "tile"+i, getNextHighestDepth());
tileHandle._y = map[i].slice(maxTile, maxY);
tileHandle._x = map[i].slice(maxY, map[i].length);
i++;
}
};
You can make a map doing this:
var map:Array;
For example, we can put:
var map1:Array = ["031", "091150"];
This will create tile 0 on the Y axis 31 and on undefined X axis, and it will create too tile 0 on the X axis 50 and on the Y axis 911
The tile number must have 1 digit(up to 9)(or on the new version 2 up to anything you want) The Y axis must have 3 digits(up to 999)(or on the new version up to anything you want) The X axis can have unlimited digits(Up to infinity)
To create the tiles:
Make a movie clip and make it’s linkage name tile_number. For example, tile_0.
An example of everything:
Stage.showMenu = false;
stop();
buildMap = function (map:Array, maxY:Number, maxTile:Number) {
var i:Number = 0;
while (i<map.length) {
tileHandle = attachMovie("tile_"+map[i].slice(0, maxTile), "tile"+i, getNextHighestDepth());
tileHandle._y = map[i].slice(maxTile, maxY);
tileHandle._x = map[i].slice(maxY, map[i].length);
i++;
}
};
var map1:Array = ["031", "091150"];
buildMap(map1,3,1);
Happy tile map creating!