Okay I've to make the car collide with three different objects using different code.
The first two are fine and work, heres an example -
I'm stuck on the bear though can anyone help?
*/ public void act() { // Add your action code here. checkCollision(); } private void checkCollision() {//check if the character collides with other game objects //check if the character collides with the car Actor Car = getOneIntersectingObject(Car.class); if(Car!=null) { setLocation((Greenfoot.getRandomNumber(600)+50),(Greenfoot.getRandomNumber(600)+50) ); //endif } } }
/** * Act - do whatever the Bear wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { // Add your action code here. checkCollision(); } private void checkCollision() {//check if the character collides with other game objects //check if the character collides with the car Actor Car = getObjectsInRange(Bear.class); if(Car!=null) { setLocation((Greenfoot.getRandomNumber(600)+50),(Greenfoot.getRandomNumber(600)+50) ); //endif } } }