My code always leads to problems with actor not in World.
What's wrong with it?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Enemy here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Tumor extends Actor
{
/**
* Act - do whatever the Enemy wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
int a;
int b = 1;
int timer = 300;
boolean badtumor = false;
private GreenfootImage GoodTumor;
private GreenfootImage BadTumor;
public void act()
{
GoodTumor = new GreenfootImage("GoodTumor.png");
BadTumor = new GreenfootImage("BadTumor.png");
if (Tutorial.tutorial == false)
{
if (MyWorld.freezeTimer > 0) return;
else
{
if( isAtEdge() ){
turn(17);
}
if( isTouching(Border.class) ){
turn(17);
}
if (Greenfoot.getRandomNumber(50) <1){
a = Greenfoot.getRandomNumber(91)-45;
turn(a);
}
move(b);
}
if (timer > 0)
{
timer--;
if(timer == 0)
{
badtumor = !badtumor;
timer = timer + 300;
}
}
if (badtumor == true)
{
setImage(BadTumor);
}
else
{
setImage(GoodTumor);
}
}
lookForBullet();
lookForPlayer();
}
public void lookForPlayer() {
if (MyWorld.life == 0)
{
removeTouching (Player.class);
}
if (isTouching(Player.class))
{
if(MyWorld.life > 0)
{
MyWorld.life--;
getWorld().removeObject(this);
}
}
}
public void lookForBullet()
{
if (isTouching(Bullet.class))
{
if (badtumor == false)
{
removeTouching (Tumor.class);
getWorld().removeObject(this);
Bullet.enemieskilled++;
if (Bacteria.bacteria > 2)
{
Bacteria.bacteria--;
}
if (Virus.virus > 3)
{
Virus.virus--;
}
}
else if (badtumor == true)
{
removeTouching (Tumor.class);
getWorld().removeObject(this);
Bullet.enemieskilled++;
if (Bacteria.bacteria < 4)
{
Bacteria.bacteria++;
}
if (Virus.virus < 5)
{
Virus.virus++;
}
}
}
}
}

