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

2013/2/25

atWorldEdge Method

ar_jay0525 ar_jay0525

2013/2/25

#
I tried using this method but I cannot compile it and it says "Cannot find symbol - method atWorldEdge"..Need help tnX
danpost danpost

2013/2/25

#
Either the class of this actor does not extend the Animal class, or you did not write a method called 'atWorldEdge' in the class of this actor.
Phytrix Phytrix

2013/2/25

#
It'd seem that the method doesn't exist. You can use the following code for an atWorldEdge method. Replace the 10s as you wish. Generally, people want objects to bounce when the edge of it hits the very borders of the world, so I'd recommend replacing the 10s with half of the size in pixels of your image. public boolean atWorldEdge() { if(getX() < 10 || getX() > getWorld().getWidth() - 10) return true; if(getY() < 10 || getY() > getWorld().getHeight() - 10) return true; else return false; }
You need to login to post a reply.