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

2013/11/4

End of World

Aceman Aceman

2013/11/4

#
Can somebody explain me this? I just need the limit for the left site of the world.
public boolean atWorldEdgeLeft()
    {
        if(getX() < 20 || getX() > getWorld().getWidth() - 20)
            return true;
        else
            return false;
    }
Gevater_Tod4711 Gevater_Tod4711

2013/11/4

#
If the x coordinate of your actor (getX()) is less than 20 your actor is at the left side of the world. If it is greater than the width of the world - 20 it is at the right side. If you only need to check for the left side of the world you can youse this:
public boolean isAtLeftSide() {
    return getX() < 20;
}
Aceman Aceman

2013/11/5

#
Thank you <3 It helped me alot!
You need to login to post a reply.