iostream71
Programmer
I need help undestanding the bolded syntax.
1)I think the first part is creating an object "game" and assigned two variables default values.
2)I think in the second part a "Tile0" object is added to the "game" object.
3)I don't understand what the "game[]" syntax is doing. Is it making "game" into an array?
Hope this makes sense. This is used in flash mx:
game = (tileW:30,tileH:30);
game.Tile0 = function () {};
game.Tile0.prototype.walkable = true;
game.Tile0.prototype.frame = 1;
game.Tile1 = function () {};
game.Tile1.prototype.walkable = false;
game.Tile1.prototype.frame = 2;
function buildMap (map)
{
_root.attachMovie("empty", "tiles", ++d);
game.clip = _root.tiles;
var mapWidth = map[0].length;
var mapHeight = map.length;
for (var i = 0; i < mapHeight; ++i)
{
for (var j = 0; j < mapWidth; ++j)
{
var name = "t_" + i + "_" + j;
game[name] = new game["Tile" + map[j]];
game.clip.attachMovie("tile", name, i * 100 + j * 2);
game.clip[name]._x = (j * game.tileW);
game.clip[name]._y = (i * game.tileH);
game.clip[name].gotoAndStop(game[name].frame);
}
}
}
1)I think the first part is creating an object "game" and assigned two variables default values.
2)I think in the second part a "Tile0" object is added to the "game" object.
3)I don't understand what the "game[]" syntax is doing. Is it making "game" into an array?
Hope this makes sense. This is used in flash mx:
game = (tileW:30,tileH:30);
game.Tile0 = function () {};
game.Tile0.prototype.walkable = true;
game.Tile0.prototype.frame = 1;
game.Tile1 = function () {};
game.Tile1.prototype.walkable = false;
game.Tile1.prototype.frame = 2;
function buildMap (map)
{
_root.attachMovie("empty", "tiles", ++d);
game.clip = _root.tiles;
var mapWidth = map[0].length;
var mapHeight = map.length;
for (var i = 0; i < mapHeight; ++i)
{
for (var j = 0; j < mapWidth; ++j)
{
var name = "t_" + i + "_" + j;
game[name] = new game["Tile" + map[j]];
game.clip.attachMovie("tile", name, i * 100 + j * 2);
game.clip[name]._x = (j * game.tileW);
game.clip[name]._y = (i * game.tileH);
game.clip[name].gotoAndStop(game[name].frame);
}
}
}