Where are you calling this method from (show the method that calls this one)? Also, what class is this 'newDragon' method in?


1 2 3 4 5 6 7 8 9 10 | // add an instance boolean to the class private boolean onDragon = false ; // code for counter if (!onDragon && !getIntersectingObjects(Dragon. class ).isEmpty()) { // increment counter // any other actions onDragon = true ; } if (onDragon && getIntersectingObjects(Dragon. class ).isEmpty()) onDragon = false ; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // Dragon class field static Dragon liveDragon = null ; // in Dragon constructor liveDragon = this ; // when killed liveDragon = null ; // for the act method if ( this == liveDragon) { // code for live dragon // when dragon dies liveDragon = null ; } else { // code for dead dragon } if (liveDragon == null ) getWorld().addObject( new Dragon(counter), 0 , 400 ); |