[QUOTE=bluemagica;2353845]abs55, you really do not have any clear concept about movieclips or library yet! What you are thinking went in the right direction, but is a bit offtrack. First of all, just the number of instances of a mc wont put much pressure on the processor unless you have some code the computes on all of them! Calculating code is the actual processor intensive part.
For example, you can create many bullets and have them be destroyed after sometime, without lag, but try creating a single bullet and let it go off to infinity with some distance checking code in it…and it will soon start to lag.
I dont know your entire gameplan so i cant say anything specific but you should design the level with a tile based approach, such that, you can generate the level as you go on. Also, you can layout the ground mc or such which have no codes in them before hand, and you can also attach the enemies, just dont execute all their codes if they are outside view.
var my_distance=Math.sqrt(((player._x-this._x)*(player._x-this._x))+((player._y-this._y)*(player._y-this._y)))
if(my_distance<(Stage.width/2)+30)
{
//execute the enemy code
}
else dont
this type of checking will lessen the burden on processor, but still it will be processor intensive if there are too many instances to check through. Thus you should not perform this check every step!
And lastly read tonypa’s tutorials on tilebased level creation to build larger yet lag free levels.[/QUOTE]
Oh ok, so the code is the main fault for the lag. Before, I thought it was the actual graphics but now I realize it’s the code! All the different sections of the level have code in them, which is why it probably goes slow. The thing with the tile based levels is that the enemy need to travel regardless of player so if the next sections of the level is created when the player passes, and the enemy is far ahead, he will be lost somewhere. And I don’t want the enemy to stop at a stage to wait for the player to catch up.
Btw, I realized that when I put in more code for the main character to make new sections to appear when he nears the end of one, the game lagged a lot. I put this code in his mc on right key press. So when I pressed left, he didn’t go slow at all. So I also want to know if there is a way I can put all his code somewhere else so it might not make the game lag. I don’t know about oop but if it is needed and if you could explain, I would really be grateful.
Thanks for clearing up my issue with why the game goes slow!