PDA

View Full Version : dynamicaly creating functions



zylum
July 6th, 2003, 01:42 AM
hi,

how would i go about dynamically making a function... im making a Tile Based World level editor and when the user is done editing a level, then they hit a button and a couple of for loops runs through all the tiles checking the x,y and tile type. then i want this information to be parameters within sub functions within the main function. so the as would look something like this
subFunction = function () {
//do this
}
//the above function is already defined in the script
generateWorld = function () {
subFunction (x,y,tileType)//a function is called for each tile in world
subFunction (x,y,tileType)
//etc...
}
//the above function (generateWorld) is created dynamically

then in the next frame, the generate world function is called.

how would i do this. would i store the information in a multidimensional array? how would i dynamically create a function???

i hope i was clear with what im trying to accomplish,

thanks in advance,

-zylum

ahmed
July 6th, 2003, 02:08 AM
i don't quite get you :(.. why exactly does 'generate world' need to be declared dynamically?

zylum
July 6th, 2003, 02:28 PM
well it's going to be different everytime time so... is there a better way to get around this?