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

2014/11/10

Moving up!

hipsterpants hipsterpants

2014/11/10

#
Is there any way that I can make my actor class move vertically instead of horizontally to begin with? I am creating a top-down game, and my models always begin by going right, as is the default for the move() command. Is there any way I can achieve vertical motion through this command?
JetLennit JetLennit

2014/11/10

#
setLocation(getX(), getY+5); This sets the location to the current x (horizontal position) and the current y (vertical position) +5. You can change the plus to a minus to go down, and the 5 to any number to change how far per act it goes.
danpost danpost

2014/11/10

#
To use the 'move' method to go up, you will have to set the rotation of your actor to face up ( 'setRotation(270);' ). You could instead use the 'setLocation' method suggested by JetLennit; however, minus would be for up and plus for down.
JetLennit JetLennit

2014/11/10

#
What danpost said XD
hipsterpants hipsterpants

2014/11/11

#
Thanks JetLennit and danpost! You guys helped a lot!
You need to login to post a reply.