swing - java Null Pointer Exception passing object -


I have some class that creates a ship (class ship game object expands) and add it to a gameboard Tries.
To do this, it tells the gameframe to add the object as follows:

  Start Public Zero () (Ship Missing = New Ship (GAME_BOARD_WIDTH / 2, GAME_BOARD_HEIGHT -1, SHIP_WIDTH, SHIP_HEIGHT; SwingUtilities.invokeLater (new Runnabal) {Public runs zero () {gameFrame = new InvadersGameFrame ();}}); gameFrame.addGameObject (myShip); // problem line gameFrame.repaint () ;}   

GameFreet then calls:

  gameboard gamebird = new gameboard (); ... ... public zeros addGameObject (GameObject ob) {gameBoard.ad DGameObject (ob);}   

In turn calls:

  public class gameborder applies to JPNL GameData {Private JPG Gameboard; Private List & lt ; GameObject & gt; Objects = New Arrelist & lt; & gt; Public GameGord black); g.setColor (Color.RED); (Game Object Obi: Objects) {g.draw oval (ob.x, oo.E., o.ed.withth, ob.); }} // place the object in the list for drawing on the next paint Public Zero addGameObject (GameObject ob) {objects.add (ob); }}   

Now my problem is that when I gameFrame.addGameObject (myShip);) one of the toughest things is that I do not receive NPE through the debugger when I run (But my object list is still empty). Apart from this, I can follow in each of these and still see my espe, so am I just referring to my game object (ship)?

The problem is that you gameframe inside runable < / Code>, which does not come later. Therefore gameFrame can be redundant at the point you call gameFrame.addGameObject (myShip)

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -