Nullpointer error + no other way in my eyes.

edited November 2016 in Programming Questions

solved!

Answers

  • which line is highlighted when you get the error?

  • edited October 2016

    line 208 and line 208 leads to a function at line 300-303

    java.lang.NullPointerException at beroepsproduct.mouseClicked(beroepsproduct.java:243) at processing.core.PApplet.mouseClicked(PApplet.java:2821) at processing.core.PApplet.handleMouseEvent(PApplet.java:2701) at processing.core.PApplet.dequeueEvents(PApplet.java:2612) at processing.core.PApplet.handleDraw(PApplet.java:2423) at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1540) at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)

  • Sketch won't run without images -- when I add filler images, I can't reproduce the problem. What did you click just before the error happens? Please describe the bug.

  • Line 232 lets game go up to 33

    Game settings is twice that, ie possibly 66

    Line 208 accesses cards[gamesettings] but you only have 64 cards, line 16

    Proving this is easy, one line of debug just before line 208.

  • To reproduce it click start, 14 setjes, 14 setjes. (or to anything higher than 12) Breaks at i = 24. myCards only gets populated with 24 cards the first time startup() is run, so there isn't anything in there to find past myCards[23] when it gets to that line. Adding a call to startup() at line 205 fixes the problem.

    @koogs that's true but it doesn't get to 33 because game is always even based on how this is written. The line of debug told me it breaks at 24.

  • println(mycard[i]);

Sign In or Register to comment.