0

For a project at school we need to program a game in JavaFx, we're almost ready with the game but I get a strange error when I use the intersects command (see attachment 1) error section. In the second and third attachment are the constructors which I use in those line where the error is constructor_1 constructor_2. and the last attachment is the ouput window with the error lines output_window_with_error_lines.

I already have read the section on this site over NullPointerException but I cant find the fault.

Main code:

if (kogelView.getBoundsInParent().intersects(enemyView1.getBoundsInParent()))
            {

                  enemyDoodModel1.setXDodeEnemy(enemyModel1.getX());
                  enemyDoodView1.UpdateEnemyDood(enemyDoodModel1);

                  enemyDoodModel2.setXDodeEnemy(enemyModel2.getX());
                  enemyDoodView2.UpdateEnemyDood(enemyDoodModel2);

            }
}

constructor_1:

public void setXDodeEnemy(int xPos)
    {
        this.xDood = xPos;

    }

constructor_2:

public int getX()
    {
        return this.xEnemy;

    }
  • 5
    Please share you error and code in the question. – yassadi Apr 11 '18 at 11:13
  • 1
    Please read [ask] and provide a [mcve] inside the question itself (not as pictures). – rustyx Apr 11 '18 at 11:19
  • You use the term *"constructor"* wrong. The methods you posted below the "heading" `constructor_1` and `constructor_2` are a setter and a getter method. None of them is actually a constructor... – fabian Apr 11 '18 at 12:25

0 Answers0