o100011e10010
09-13-2009, 12:36 AM
Hey guys,
So i've been working on a game and i've been implementing for loops here and there, causing my game to slow down dramatically. The player adds objects onto the screen by mouse clicks and the main character in the game must test for hitTests for all of those objects. So I have a counter ("k") set up and each new object that is added has an instance name of "hitBox"+k and there's a for loop that tests (m=0;m<k;m++) and it tests hitTests that way.
Like this: (this actionscript is on the main character)
for (m=0; m<=_global.k; m++) {
if (_root["hitBox"+m].hitTest(_x, _y, true)) {
test1 = true;
}
}
Is there a better way of doing this so that after like 15 are added it doesn't slow down very much?
thnx,
-o100011e10010
So i've been working on a game and i've been implementing for loops here and there, causing my game to slow down dramatically. The player adds objects onto the screen by mouse clicks and the main character in the game must test for hitTests for all of those objects. So I have a counter ("k") set up and each new object that is added has an instance name of "hitBox"+k and there's a for loop that tests (m=0;m<k;m++) and it tests hitTests that way.
Like this: (this actionscript is on the main character)
for (m=0; m<=_global.k; m++) {
if (_root["hitBox"+m].hitTest(_x, _y, true)) {
test1 = true;
}
}
Is there a better way of doing this so that after like 15 are added it doesn't slow down very much?
thnx,
-o100011e10010