also if i keep contact with the enemy my actor is removed even though it has done a little bit damage to my actor could you check if there's something with my actor and enemy actor here's the code


import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class K here. * * @author (your name) * @version (a version number or a date) */ public class K extends ShooterActors { /** * Act - do whatever the K wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ private int vspeed = 0; private int acceleration = 2; private int speed =5; private int fspeed = 0; private boolean onHeartless = false; boolean CanJump; KiBlast kiblast = new KiBlast(); private int points = 0; private Bar healthBar; public void act() { movement(); if(isOnGround()){ CanJump = true; } else{ CanJump = false; fall(); } if (isTouching(Heartless.class)) { if (!onHeartless) { healthBar.subtract(10); onHeartless = true; } } else onHeartless = false; fire(); shoot(); healthBar.setLocation(getX(), getY()-30); hit(); } public K() { healthBar = new Bar("", "", 100, 100); healthBar.setShowTextualUnits(false); healthBar.setBarWidth(30); healthBar.setBarHeight(3); healthBar.setMaximumValue(70); healthBar.setValue(70); healthBar.setBreakValue(10); } public boolean isOnGround() { Clone Window = (Clone) getWorld(); if(getY() + (getImage().getHeight() / 2) >= (Window.getHeight() -1)) { return true; } return false; } public void jump() { fspeed = -10; fall(); } public void fall() { setLocation ( getX(), getY() + fspeed); fspeed = fspeed + acceleration; } public void movement() { if(Greenfoot.isKeyDown("left")) { MoveLeft(); } if(Greenfoot.isKeyDown("right")) { MoveRight(); } if(Greenfoot.isKeyDown("up")) { jump(); } } public void MoveLeft() { setLocation (getX() - speed, getY()); } public void MoveRight() { setLocation (getX() + speed, getY()); } public void fire() { if(Greenfoot.isKeyDown("x")) { World world = getWorld(); world.addObject(kiblast, 0, 0); kiblast.setLocation(getX(),getY()); } } public void shoot() { { if ("c".equals(Greenfoot.getKey())) getWorld().addObject(new KiBlast(), getX(), getY()); points = points+5; } } protected void addedToWorld(World world) { world.addObject(healthBar, getX()-18, getY()-373); } public void hit() { Actor heartlessblast = getOneIntersectingObject(HeartlessBlast.class); if(heartlessblast != null) { healthBar.subtract(10); getWorld().removeObject(heartlessblast); } Actor heartless = getOneIntersectingObject(Heartless.class); { if(heartless != null) healthBar.subtract(10); } if(healthBar.getValue() == 0) { World world = getWorld(); NewGameOver newgameover = new NewGameOver(); world.addObject(newgameover, world.getWidth()/2,world.getHeight()/2); getWorld().removeObject(healthBar); getWorld().removeObject(this); } } }
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Heartless here. * * @author (your name) * @version (a version number or a date) */ /** * Act - do whatever the Heartless wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public class Heartless extends Actor { HeartlessBlast heartlessblast = new HeartlessBlast(); private int shotDelay = 0; private int JumpChance = 0; private int vspeed = 0; private int magicnumber = 3; private int acceleration = 0; boolean isOnGround; public void act() { fap(); shoot(); } public void annihilate() { Actor K = getOneObjectAtOffset(0,0,K.class); getWorld().addObject(heartlessblast, getX(), getY()); if(K != null){ World world = getWorld(); NewGameOver newgameover = new NewGameOver(); world.addObject(newgameover, world.getWidth()/2,world.getHeight()/2); world.removeObject(K); } } public void fap() { getWorld().addObject(heartlessblast, getX(), getY()); annihilate(); } public void shoot() { if(shotDelay >= 100) { getWorld().addObject(new HeartlessBlast(), getX(), getY()); shotDelay = 0; } shotDelay++; } public void jump() { vspeed = -10; fall(); } public void fall() { setLocation ( getX(), getY() + vspeed); vspeed = vspeed + acceleration; } }
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Heartless here. * * @author (your name) * @version (a version number or a date) */ /** * Act - do whatever the Heartless wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public class Heartless extends Actor { HeartlessBlast heartlessblast = new HeartlessBlast(); private int shotDelay = 0; private int JumpChance = 0; private int vspeed = 0; private int acceleration = 0; boolean CanJump; boolean OnGround; public void act() { if(isOnGround()){ CanJump = true; } else{ CanJump = false; fall(); } fap(); shoot(); randomjump(); } public void annihilate() { Actor K = getOneObjectAtOffset(0,0,K.class); getWorld().addObject(heartlessblast, getX(), getY()); if(K != null){ World world = getWorld(); NewGameOver newgameover = new NewGameOver(); world.addObject(newgameover, world.getWidth()/2,world.getHeight()/2); world.removeObject(K); } } public void fap() { getWorld().addObject(heartlessblast, getX(), getY()); } public void shoot() { if(shotDelay >= 100) { getWorld().addObject(new HeartlessBlast(), getX(), getY()); shotDelay = 0; } shotDelay++; } public boolean isOnGround() { Clone Window = (Clone) getWorld(); if(getY() + (getImage().getHeight() / 2) >= (Window.getHeight() -1)) { return true; } return false; } public void randomjump() { if(OnGround && Greenfoot.getRandomNumber(100) ==3) { jump(); } } public void jump() { vspeed = -10; fall(); } public void fall() { setLocation ( getX(), getY() + vspeed); vspeed = vspeed + acceleration; } }
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Heartless here. * * @author (your name) * @version (a version number or a date) */ /** * Act - do whatever the Heartless wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public class Heartless extends Actor { HeartlessBlast heartlessblast = new HeartlessBlast(); private int shotDelay = 0; private int JumpChance = 0; private int vspeed = 0; private int acceleration = 0; public void act() { fap(); shoot(); randomjump(); } public void annihilate() { Actor K = getOneObjectAtOffset(0,0,K.class); getWorld().addObject(heartlessblast, getX(), getY()); if(K != null){ World world = getWorld(); NewGameOver newgameover = new NewGameOver(); world.addObject(newgameover, world.getWidth()/2,world.getHeight()/2); world.removeObject(K); } } public void fap() { getWorld().addObject(heartlessblast, getX(), getY()); } public void shoot() { if(shotDelay >= 100) { getWorld().addObject(new HeartlessBlast(), getX(), getY()); shotDelay = 0; } shotDelay++; } public boolean isOnGround() { Clone Window = (Clone) getWorld(); if(getY() + (getImage().getHeight() / 2) >= (Window.getHeight() -1)) { return true; } return false; } public void randomjump() { if( Greenfoot.getRandomNumber(100) ==3) { jump(); } } public void jump() { vspeed = -10; fall(); } public void fall() { setLocation ( getX(), getY() + vspeed); vspeed = vspeed + acceleration; } }