Я не знаю, почему это происходит, но все элементы моего массива имеют одинаковое значение: (
public function populateNodes():void
{
// Calculate tile size:
// width = sceneWidth/mapSize (map size is Size of the map in tiled editor)
_tileSize = new Point (PBE.scene.sceneView.width/mapSize.x, PBE.scene.sceneView.height/mapSize.y)
// Get Scene bounds
var left:Point = PBE.scene.sceneViewBounds.topLeft;
var right:Point = PBE.scene.sceneViewBounds.bottomRight;
// Defines the center of first tile
var minX:int = left.x + _tileSize.x/2;
var minY:int = left.y + _tileSize.y/2;
// Defines the center of last tile
var maxX:int = right.x - _tileSize.x/2;
var maxY:int = right.y - _tileSize.y/2
//var nodes:Array = new Array(100);
var place:Point = new Point(minX, minY);
//_tileSize = new Point(PBE.scene.sceneView.width/mapSize.x, PBE.scene.sceneView.height/mapSize.y);
var debugLoop:int = 0;
for each (var tile:* in layers.data.tile)
{
var node:Node = new Node();
node.gid = tile.@gid;
node.location = place;
node.size = _tileSize;
nodesList.push(node);
if (place.y >= maxY)
{
if(place.x >= maxX)
trace("End loop");
}
place.x += _tileSize.x;
// Review case when x reached boarder
// If yes, add y and point x to begining
if (place.x >= maxX)
{
place.x = minX;
place.y += _tileSize.y
}
// Review when y reached max y size
// If yes put y to to begining
if (place.y >= maxY)
{
place.y = minY;
}
debugLoop += 1;
}
trace ("Done");
}
Класс узла:
public class Node
{
public var collidable:Boolean = false;
public var gid:int;
public var size:Point;
public var location:Point;
public function Node()
{
}
}
Не знаю, почему, но все узлы в списке узлов имеют одинаковое местоположение (местоположение последней точки, помещенной в массив ...)
Может кто-нибудь подсказать почему?