|
-
[F8] enterFrame alternatives
I was creating a simple flash game as part of a project at college and it came to my attention how slow the game would run. There were a lot of symbols on the screen and part (I'm sure) the lag was caused by the massive amount of enterFrame if statements. Such as:
code: if (anyClip_mc._y > Stage.height) {
I used a statement like this to delete symbols that fell off the lower edge of the stage. In this case it was rain that was being generated + removed. However is there a more CPU friendly way to check these sorts of conditions? Something that wouldn't require ever droplet (of which there were a lot) on every frame tick to check it's height etc.
Any ideas/help?
Thank you in advance,
JAK x
-
Just before you deleted the symbols, did you remove the onEnterFrame functions? If not, you may want to give it a try...
-
Well I used this code in full to generate the rain:
code: rainNum = 0;
raining = function () {
rainNum++;
var rain = _root.attachMovie("rain_mc", "rain_mc" + rainNum, rainNum);
rain._x = Math.round(Math.random() * Stage.width);
rain.onEnterFrame = function() {
rain._y += 2;
if (rain._y > Stage.height) {
delete this.onEnterFrame;
this.removeMovieClip();
}
};
};
Surely when the rain is deleted the onEnterFrame code is removed along with it for that individual symbol?
By the way, that's your code. You answered one of previous questions on how to actually make it in the first place. Thank you for that, made my game look pretty!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|