somebody621
Member
|
Would this be a fast way to scroll a tile-based map? First build the whole map with an array and make a second array with the entire width and height like this: mapWhole = [[0, 1, 2, 3, 4],
[1, 1, 1, 1, 1],
[2, 2, 2, 2, 2],
[3, 3, 3, 3, 3]];
// this is for a 5 by 4 map.
Also make an array like that for your scrollpane. Second, make a variable scrollX and scrollY based on your character's xTile and yTile. Next, build the whole map using for(var i in mapWhole){ and for(var j in mapWhole[0]){ loops. Don't make the tiles gotoAndStop yet. Then, use another for... in loop for your scrollpane using variables k and l. After each loop, use this: var m = k + scrollX or something like that, and make those tiles go to the right frame. For movement, it should be about the same, except you use gotoAndStop to go to an empty frame instead of deleting the tile.
|