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

2017/11/3

How to restrict character on top of screen while jumping?

shantanu28 shantanu28

2017/11/3

#
I have made a character who has the power to fly. But I am not able to restrict him to the screen. While flying it goes beyond the screen
danpost danpost

2017/11/3

#
shantanu28 wrote...
I have made a character who has the power to fly. But I am not able to restrict him to the screen. While flying it goes beyond the screen
Normally the following alone after the movement code would be enough:
if (getY() < getImage().getHeight()/2) setLocation(getX(), getImage().getHeight()/2);
You need to login to post a reply.