Официальный сайт студ.городка НГТУ
Программирование и БД » нужна консультация по action script 1 

#1  10.07.09 16:34

нужна консультация по action script 1

Код::

fscommand("allowscale", false);
fscommand("allowscale", false);
//our map is 2-dimensional array
myMap = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]];
//declare game object that holds info
game = {tileW:30, tileH:30};
//walkable tile
game.Tile0 = function () { };
game.Tile0.prototype.walkable = true;
game.Tile0.prototype.frame = 1;
//wall tile
game.Tile1 = function () { };
game.Tile1.prototype.walkable = false;
game.Tile1.prototype.frame = 2;
//building the world
function buildMap(map) {
	//attach empty mc to hold all the tiles and char
	_root.attachMovie("empty", "tiles", ++d);
	//declare clip in the game object
	game.clip = _root.tiles;
	//get map dimensions
	var mapWidth = map[0].length;
	var mapHeight = map.length;
	//loop to place tiles on stage
	for (var i = 0; i<mapHeight; ++i) {
		for (var j = 0; j<mapWidth; ++j) {
			//name of new tile
			var name = "t_"+i+"_"+j;
			//make new tile object in the game
			game[name] = new game["Tile"+map[i][j]]();
			//attach tile mc and place it
			game.clip.attachMovie("tile", name, i*100+j*2);
			game.clip[name]._x = (j*game.tileW);
			game.clip[name]._y = (i*game.tileH);
			//send tile mc to correct frame
			game.clip[name].gotoAndStop(game[name].frame);
		}
	}
}
//make the map
buildMap(myMap);
stop();

код на AS1, как аналогичное будет выглядеть на AS2(с использованием ООП или же нет неважно)

Исправлено T!nk@ff (10.07.09 16:34)

Offline

Программирование и БД » нужна консультация по action script 1 

ФутЕр:)

© Hostel Web Group, 2002-2025.   Сообщить об ошибке

Сгенерировано за 0.319 сек.
Выполнено 14 запросов.