Hi Im ongokiller50 and I wonna tell you guys how to reduce mega lag.
1st thing in order to reduce serious lag is to "ONLY USE ONE ONENTERFRAME ON THE MAIN TIME LINE, and use it for your hole gameplay!" because OnEnterFrame is very power and can take alot of Fps when there are 5 or more that have alot of scripts in it.
Im gonna teach you how to use One onEnterframe, controlling the ALOT OF players using arrays. array are very power and very useful to detect everything on the stage that you push in the array to move.
3rd avoid "OnClipEvent(enterFrame)" in your game.
lets begin
GamePlay = [];//Created a New Array to control every box in one onenterframe
HowManyBoxes = 100;// HOW Many boxes are we gonna add
onEnterFrame = function(){//checks and do on everyframe;
for (var i = 0; i < HowManyBoxes; i++){// what this does that on every frame;
//on the game "i" is gonna start at 0 and add up to the var HowManyBoxes in one frame.;
//why? because this is to create 200 boxes in one Frame!;
var Boxes = _root.attachMovie("Box","b"+i,i)// this creates what ever name is on the library;
// call "Box" , and name it "b" with what ever number "i" is;
// explain "b1 , b2 , b3";
Boxes._x = random(360)+100;//spawn randomly around 100 - 360;
Boxes._y = random(200)+100;//spawn randomly around 200 - 100;
GamePlay.push(Boxes)// this adds to the array so that we can control it.;
HowManyBoxes--// this is to tell the "for" that this Movieclip(EX:b1,b2) has been;
// created NO NEED TO RE ADD IT again;
};
//CONTROLING THE BOXES;
for (var C = 0; C < _root.GamePlay.length; C++){//this says;
// if "C" is lower than the number "_root.GamePlay.length" (length is how many are they in it by numbers EX: 7);
//then to + add up(C++);
//then on the next frame start with C = 0 again and repeat over and over.;
var ControlBox = _root.GamePlay[C]//_root.GamePlay[C] is a movieClip;
//the "[C]" is a number using the "var C" explain "9";
//this how to control a movieclip;
//inside the array we push in GamePlay, so we useing a var to instead of "_root.GamePlay[C]";
// WHY? Cause its easyer;
//like I said ARRAYS ARE VERY FAST!;
ControlBox._y = ControlBox._y+ControlBox.yspeed//its Y will remain the same;
// but yspeed is in control of its UP AND DOWN YSPEED;
//"ControlBox.yspeed" where using the Box's vars to make him move on its own;
ControlBox.yspeed = ControlBox.yspeed+ControlBox.gravity//ControlBox.yspeed;
//remains the same but gravity is pushing it down;
if (_root.ground.hitTest(ControlBox._x,ControlBox._y+42,true)){;
ControlBox.onground = true;
ControlBox.gravity = 0//stops the gravity form pushing me down when im on the ground;
ControlBox.yspeed =-5//make him jump;
}else{//this mean WHAT IF IM NOT TOUCHING IT?;
ControlBox.onground = false;
ControlBox.gravity = 0.5//gravity contines to push me down;
};
while (_root.ground.hitTest(ControlBox._x,ControlBox._y+40,true)){;// checkes his feet
// THE "WHILE" mean to keep doing it till its no more touching in one frame;
ControlBox._y--//so in one frame its gonna force up to be on top of the ground;
ControlBox.yspeed = 0// " GLICTH FIX "stops my yspeed so that I dont go throw the ground;
};
};
};
// this is how you control alot of movieclips without USING LIKE 5000 ONENTERFRAMES that makes the "pc Crappy to even play" without it breaking a sweat
// as you can see theres 100 MovieClip there WITHOUT NO LAG
Download the EXPLAIN HERE
http://www.2shared.com/file/Vf-MsFy0/my_tutorial.htmlso yes this is why other ppl flash games lags on your crappy pc. (Because theres more than one "onenterframe".
This is why my game COMBAT TOURNAMENT LAGS ON YOUR PC TOO when
theres 8 ppl fighting (Beucase they all have 2 onenterframes)
And imma upload a updated version on Combat Tournament with bugs fix and lag fix.
My next tutorial I will show you how to make a beat em up game with alot of combos with using the arrows and one attack button