Hi guys, I'm needing some help again. I am trying to figure out how exactly to setup my counter properly. I want it to add to my "misses" when the cannonball I fire hits anything but the target.
I have all of this in my world class
In my cannonball class I have
Currently I've come to an understanding that when the cannonball is fired it will check to see if it is in the world. Then if it is not because its hit the wall or hit the world's edge it should add 1 to the misses. If it didn't hit the wall or the world edge then it hit a target. Hitting the target will prompt the player to restart the game.
So when I trying to fire the cannon ball and it does hit the world edge it gives me a null point exception error. Any help would be greatly appreciated.
public int angle = 0; public int power = 50; public int misses = 0; public void Spawn() { StatusBoard status = new StatusBoard(); status.setValues(angle, power, misses); addObject(status, 50,90); } public int getMisses() { return misses; } public void increaseMisses() { misses = misses + 1; statusBoard.setValues(angle, power, misses); }
public void cannonBallRemove() { World fodderWorld = getWorld(); FodderWorld FodderWorld = (FodderWorld) getWorld(); if ( getY() > fodderWorld.getHeight() ) { FodderWorld.increaseMisses(); fodderWorld.removeObject(this); return; } }