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

2013/5/14

How do I get my Actors to move?

Yongjoon Yongjoon

2013/5/14

#
I've tried to get them to move with setRotation() and move(). setRotation(270); move(10); doesn't really work. What should i do?
danpost danpost

2013/5/14

#
Where are you placing that code (it should work if you have it in your 'act' method of that actor class).
Yongjoon Yongjoon

2013/5/14

#
it's inside my act method
Yongjoon Yongjoon

2013/5/14

#
public void act() { if(Greenfoot.isKeyDown("up")) { move(1); } if(Greenfoot.isKeyDown("down")) { move(-1); } if(Greenfoot.isKeyDown("left")) { setRotation(getRotation()-5); } if(Greenfoot.isKeyDown("right")) { setRotation(getRotation()+5); } // Add your action code here. }
Yongjoon Yongjoon

2013/5/14

#
Also, how can i get the map to scroll? I'm trying to create a 2D war game, and im totally lost with Greenfoot. I just started using it and it's a bit different from what im used to
You need to login to post a reply.