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

2013/2/16

Stopping an Object

Gingervitis Gingervitis

2013/2/16

#
Is it possible for me to have a class not move any further when it hits a specific spot on the y-axis? (I have my turtle start on the bottom left hand side of the screen, but I don't want it to go past 370 on the y-Axis.)
danpost danpost

2013/2/16

#
If you are starting at the bottom left of the screen, the y value is already maxed out. You probably meant that you do not want it to go past 370 on the x-Axis (not the y-Axis).
if (getX()<370) setLocation(getX()+1, getY());
If I was wrong about what you meant, just change the 'X's to 'Y's and move the '+1' from the 'getX()' to the 'getY()'.
You need to login to post a reply.