Hi,
There's a double error here. On this line ****** numRows (15) should be
numCols (10) as we work across the row of 10. However this is only workable
if the number of tiles is numRows X numCols (10x15=150).
public function generate(numTiles:int):void {
var numRows:int =
getNumRows();
for (var i:int = 0; i < numRows; i++) {
for (var j:int = 0; j < getNumCols(); j++) {
setTile(j, i, (i * numRows) + j); ******
}
}
}
The original code ##### shows that the number of tiles is 12 (?) ...
public function randomize (numTiles:int):void {
for (var i:int = 0; i < getNumRows(); i++) {
for (var j:int = 0; j < getNumCols(); j++) {
setTile(j, i, Math.floor(Math.random()*numTiles)); #####
}
}
The Spacemap/map array was getting wiped away by the over run.
John
----- Original Message -----
From: "Terry Riney" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Saturday, April 12, 2008 7:21 PM
Subject: Re: [Flashcoders] Moock TileMap/TileSet/TileMapRenderer
Hello,
Appreciated the response to my post. When I implement new function:
Instead of using Math.random() in the randomize function, you would set
the ID to the row / column position:
public function generate(numTiles:int):void {
var numRows:int =
getNumRows();
for (var i:int = 0; i < numRows; i++) {
for (var j:int = 0; j < getNumCols(); j++) {
setTile(j, i, (i * numRows) + j);
}
}
}
I get: "Cannot access a property or method of a null object reference.".
A
trace shows it halts at "j" being 5 (numCols in TileMap) and does not get
to
12 (numRows in TileMap).
FB2 Debug takes me to" thisTile.position = 0" which works when using
Math.randomize?
Any help would be really be great.
Thanks,
Terry
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders