I'm trying to figure out how to make it so that when my actor (Odysseus) hits an object (Block) he stops moving. I tried what is said here but every time I reset a terminal came up and broke my game. :( help?


Block b = (Block)getOneIntersectingObject(Block.class); public void walk() { if(b == null) { if(Greenfoot.isKeyDown("down")) { setLocation(getX(), getY() + 3); setDirection(WEST); } if(Greenfoot.isKeyDown("right")) { setLocation(getX() + 3, getY()); setDirection(SOUTH); } if(Greenfoot.isKeyDown("left")) { setLocation(getX() - 3, getY()); setDirection(NORTH); } if(Greenfoot.isKeyDown("up")) { setLocation(getX(), getY() - 3); setDirection(EAST); } } }
public class Bone extends Mover { private int rotation; public Bone() { move(); rotation = getRotation(); } public void act() { setRotation(rotation); move(5); } private int rotation2; public void spin() { rotation2 = rotation2 + 10; setRotation(rotation2); } }