Okay, so
- new Zombie variable created.
private Zombie zombieA; -
zombie variable initialized
zombieA = new Zombie(1); -
calls constructor in Zombie class:
public Zombie(int type) { this.type = type; x=200; y=100; dx=1; paintA.setColor(Color.RED);}
Basically, I want the game class to create a new Zombie, with the type as 1 which will go through a switch and case to determine which type of zombie to create (level 1=10). The problem is when I run it my application force closes and i get the an error on:
zombieA = new Zombie(1);
from the initial class and an error on:
public Zombie(int type) {
from the Zombie class. I’ve been going over it again and again and i just can’t see the problem, anyone notice anything wrong?
It’s hard to tell without the stack trace, but I suspect that the problem is in this line:
Are you sure that
paintAhas been properly initialized? it seems to me that it’snulland causing aNullPointerExceptionin your constructor. If that’s the case, be sure to instantiate it first, something like this: