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

2015/4/14

Need help with object moving up and down!

leew145 leew145

2015/4/14

#
I am trying to get a jelly fish in my game to move up and down. I want it to move up and then when it is at worldsEdge to move down without rotating. I am having trouble with it moving back down. any help if appreciated. Thanks!
Douggresham Douggresham

2015/4/14

#
Try something like this private boolean isMovingDown=false; public void act() { if(!isMovingDown) setLocation(getX(),getY()-3); else setLocation(getX(),getY()+3); if(isAtEdge()) isMovingDown=!isMovingDown; }
leew145 leew145

2015/4/15

#
That worked, thank you so much!
You need to login to post a reply.