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

2019/3/26

How do I move

coreypants03 coreypants03

2019/3/26

#
I'm trying to have something move to the left and i have no idea how to do that. I also have a rocket that I'm trying to move to the right that when I use a command to have it move it keeps going .
move(4);
that's my code for the rocket
coreypants03 coreypants03

2019/3/26

#
by the way I'm trying to make a space invaders like game.
danpost danpost

2019/3/26

#
coreypants03 wrote...
I'm trying to have something move to the left and i have no idea how to do that.
There are 3 basic ways to move left:
move(/** negative value */); 
// or
setRotation(180);
move(/** positive value */);
// or
setLocation(getX()-/** positive value */, getY());
I also have a rocket that I'm trying to move to the right that when I use a command to have it move it keeps going. << Code Omitted >>
If you do not want it to keep going, you must restrict it somehow using an if conditional:
if (/** some condition */) move(4);
coreypants03 coreypants03

2019/3/29

#
Thank you. I was able to get it to move.
You need to login to post a reply.