I am doing a system which player can throw out the bomb.
The below is my bomb function,it will set the position of bomb and call another enterFrame function.
if ( man1.bomb == true && isThrow == false)
{
isThrow = true;
attachMovie(“bomb”,“bomb1”,998)
bomb1._width = 20;
bomb1._height = 30;
if (man1.facing == “left”)
{
bomb1._x = man1._x;
bomb1._y = man1._y- bomb1._height;
bspeed = -5;
}
else if (man1.facing == “right”)
{
bomb1._x = man1._x+man1.width;
bomb1._y = man1._y- bomb1._height;
bspeed = 5;
}
bomb1.onEnterFrame = bombEnterFrame;
}
isThrow = false;
function bombEnterFrame()
{
bomb1._x += bspeed;
if (bomb1.hitTest(patrolrobot1))
{
patrolrobot1.HP -= 10;
bomb1.removeMovieClip();
isThrow = false;
}
if (bomb1._x <= 0 || bomb._x > 800)
{
bomb1.removeMovieClip();
isThrow = false;
}
}
But the problem is the bomb will not continuously fly to end of the screen and disappear. It seem like constant at the same place.
Anyone can help me to solve this problem?
Thank you.