I am having troubles figuring this one out, because the code that I usually use to fix it isn't working for this time. Please help.
Error: java.lang.NullPointerException
at Towers.act(Towers.java:71)
Line of code:
Code's Target (Enemies Class) :
1 | if (Enemies.main.getWorld() == null && Enemies.main == null ) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Enemies here. * * @author (your name) * @version (a version number or a date) */ public class Enemies extends Actor { public static Enemies main; public void act() { main = this ; moving(); } public void moving() { turnTowards(Finish.main.getX(), Finish.main.getY()); move( 2 ); } } |