This site requires JavaScript, please enable it in your browser!
Greenfoot back
Trebushey
Trebushey wrote ...

2019/4/22

Movement Pattern

Trebushey Trebushey

2019/4/22

#
Hey, I'm trying to create a movement pattern for a boss where it goes up and down. I've been able to move it down but it doesn't want to change its direction once it's reached its point.
 public void movement2()
    {
       int move = 5;
        if (getX() == 465)
        {
            setLocation(getX() , getY() - move);
            if (move > 0 && getY() >= 500)
            {
                 setLocation(getX(), 500); 
                 move =-move;
            }
            if (move < 0 && getY() <= 200)
            {
                 setLocation(getX(), 200); 
                 
            }
    }
here's the code that I've been testing out, I saw this on a previous post here and I tried copying it but it doesn't work for me, I'm hoping someone can tell me what the problem is becasue I have no clue.
Super_Hippo Super_Hippo

2019/4/22

#
Move line 3 outside of the method. You probably want line 10 in line 15, too.
Trebushey Trebushey

2019/4/22

#
Super_Hippo wrote...
Move line 3 outside of the method. You probably want line 10 in line 15, too.
ohhh I see now, thanks it works now.
You need to login to post a reply.