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

2014/1/9

How to stop an object from moving?

y0us y0us

2014/1/9

#
Dear greenfooters, I want to make the two ships, that are starting from above and move in a vertical line downwards, to stop right in the middle of the screen. I tried to make an 'invisible' wall, but two little green feet appear on the screen when I assign no image to them. This is my attempt at it so far. Actor wall; wall = getOneObjectAtOffset(0, 0, wall.class); if (wall == null) { setLocation(getX(), getY() + 1); } Also, can I do such thing as to stop it at an fixed Y- coordinate? Like this, but this isnt working. setLocation(getX(), getY() + 1); if(getY() == 309) { move(0); } I am a beginner so please bear with me :) Thanks in advance
y0us y0us

2014/1/9

#
Nvm I already figured it out :) This one worked: setLocation(getX(), getY() + 1); if(getY() == 309) { setLocation(getX(), getY() - 1); }
You need to login to post a reply.