I am making a game and you are a car and there's cars that randomly coming down at you
the car that you are is called Car.class
and the other one is Karr.class
and they add randomly but they overlap the same Karr
and in the booklet it gives you a clue on how to do it
and it is code
getOneIntersectingObject
can anyone help thanks
Karr class
also the problem is it stops the game?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class Karr extends Actor { private int vSpeed = 2; public void act() { // addObject(new Karr(), Greenfoot.getRandomNumber(200)+200, 0); moveDown(); setRotation(90); checkPosition(); checkCollision1(); } private void moveDown() { setLocation(getX(), getY()+vSpeed); } private void checkPosition() { if(getY()>= getWorld().getHeight()-1) getWorld().removeObject(this); } private void checkCollision1() { Actor karr = getOneIntersectingObject(Karr.class); if(karr !=null) { getWorld().removeObject(this); } } }