PDA

View Full Version : Naming maps



Tsukimaru
December 18th, 2007, 07:44 PM
In Tonypa's tile map tutorials, he names his map arrays myMap1, myMap2, and so on. He sets currentmap to 1, and then calls his map building function with buildMap(_root["myMap"+game.currentMap]); so he can just change the currentmap number when he goes to a different room.

I think it'll be hard to remember which map "myMap1" corresponds to. What I want to do is make it so I can name my map arrays things like Castle and Town, and call it with something like buildMap(//name of map array);
I've tried a few different ways, but none of them work. What's the best, simplest way to do this?

GrndMasterFlash
December 21st, 2007, 09:37 AM
var level:Number = 1
//when a level is over do level++ some where
//next fill your levelsArr
levelsArr:Array = [castle, town, swamp]
//when you call your build man not the - 1 to level since arrays start at 0 this will
//be the castle
buildMap(levelsArr[level-1]
//if you wanted to get really tech about it you could change the map acording
//to areas like so
//have mc in library called castle_outside
var area:String = "outside"
buildMap(levelsArr[level-1]+"_"+area]

hope dis elps :D

oh and don't forget to set your library linkage