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

2022/6/9

How to make the enemy move from one edge to the other?

shindayoni shindayoni

2022/6/9

#
The enemy must move horizontally on one line, and after picking up the object, return to the n-th position and start moving vertically as well from one corner to another at these coordinates? How i can make it?
shindayoni shindayoni

2022/6/9

#
I made it by myself if anyone needed:
public void moveAround(){
        if (isAtEdge()){
            getImage().mirrorHorizontally();
            direction = -direction;
        }
        setLocation(getX() + 1*direction, getY()); // setLocation(getX(), getY() 1*direction); if you want it move vertically
        
    }
You need to login to post a reply.