jeudi 16 juin 2016

While moving the enemy left to right, if you change levels he keeps going

public function goalieLoop(e:Event):void { if (goalie!=null) { if (direction=="right") { goalie.x+=5; }

            else
            {
                goalie.x-=5;
            }     
            if (goalie.x==500 && direction=="right")
            {
                direction="left";
            }
            else if (goalie.x==300 && direction=="left")
            {
                direction="right";
            }

        }
    }

this is how i make my enemy move left to right, but once I get to the next level, depending on the way he was going, he keeps going that direction off the screen. If anymore code is needed, please ask. Thank you.

Aucun commentaire:

Enregistrer un commentaire