Hello,
I am building a platform game.
There is a problem. I have two MovieClip, one of the player, and one of the enemy. On both of them works gravity. I use attachMovie to attach them to the stage.
my code is:
var grav:Number = 0;
var gravity:Number = 2;
enemySpawn = function(numEnemies){
for(i=1;i<=numEnemies;i++){
attachMovie("enemy", "enemy"+i, i);
enemy2._x = 200;
_root["enemy"+i].onEnterFrame = function(){
this._y += grav;
grav += gravity;
while(ground.hitTest(this._x,this._y,true)){
this._y -= gravity;
grav = 0;
}
}
}
}
enemySpawn(2);
Fla file is attached.
Thank you to the all those who helpful!!!