I'm trying to get Greenfoot.mousePressed(object) to work.
I want to make it so whenever I click an object in the world, I want to make it move.
Here's my code
I also want to make it so that once I select an object, I can press a key to make it move forward
Here's my code for that, it would work with the code above
1 2 3 4 | if (Greenfoot.mousePressed(WhitePawn. class ) == true ) { movement(); } |
1 2 3 4 5 6 7 8 | public void movement() { if (Greenfoot.isKeyDown( "w" ) == true ) { setLocation(getX(), getY()- 75 ); endTurn(); } } |