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

2014/12/17

atWorldEdge() larger distance?

xFabi xFabi

2014/12/17

#
Hi there, i found this:
public boolean atWorldEdge()
{
if (getX() <= 5 || getX() >= getWorld() . getWidth() -5)
        return true;
    if (getY() <= 5 || getY() >= getWorld() . getHeight() -5) 
        return true;
    else
        return false;
}
for an atWorldEdge() method, now i want to make it count earlier, like 15-20 pixels before the edge, which of the given numbers do i have to change, in order to get a greater distance? its kinda confusing..
danpost danpost

2014/12/17

#
All four '5's are used to make the bounds of the actor slightly tighter. Just alter the '5's (keeping their signs) to a larger number to tighten the bounds even more.
xFabi xFabi

2014/12/17

#
Worked, thanks ;)
You need to login to post a reply.