I want to remove object which is bullet after it reach edge but it didn't work. can you please help me? Thank you
at Bullet.checkTankHit(Bullet.java:35) at Bullet.act(Bullet.java:21) at greenfoot.core.Simulation.actActor(Simulation.java:567) at greenfoot.core.Simulation.runOneLoop(Simulation.java:530) at greenfoot.core.Simulation.runContent(Simulation.java:193) at greenfoot.core.Simulation.run(Simulation.java:183)
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Bullet here. * * @author (your name) * @version (a version number or a date) */ public class Bullet extends Actor { private static final int damage =15; /** * Act - do whatever the Bullet wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { setLocation(getX(), getY()+1); explosion(); checkTankHit(); } private void explosion() { if(isAtEdge()){ getWorld().removeObject(this); } } /** * Check whether enemy bomb hit our tank or not */ private void checkTankHit(){ Tank tank =(Tank) getOneIntersectingObject(Tank.class); if (tank != null) { getWorld().removeObject(this); tank.hit(damage); } } }