everytime i load this code i get this error java.lang.NullPointerException
at enemy.enemyimage(enemy.java:32)
at enemy.act(enemy.java:21)
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 enemy extends Actor
{
GreenfootImage enemyimg;
public enemy enemy1;
/**
* Act - do whatever the enemy wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
enemyimage();
getImage().scale(200, 200);
if (isTouching(player.class))
{
}
}
void enemyimage()
{
enemyimg = getImage();
enemy1.setImage(enemyimg);
enemy1.setLocation(0,0);
getWorld().addObject(enemy1, 30, 30);
}
}