New user
Posts: 1
(66.99.180.162) | Chapter 2. Pg 55,
i have the code entered EXACTLY as shown in the book, however, when i run the code the game "freezes" after pressing space to enter play from the Title Screen and i receive a "ArgumentNullException was Unhandled" error w/ this section lit up.
spriteBatch.Draw(
playingPieces,
New Rectangle(
pixelX,
pixelY,
GamePiece.PieceWidth,
GamePiece.PieceHeight),
EmptyPiece,
Color.White)
i can remove this and the next segment of code to enter play but obviously i get no Tiles.
Possibly something wrong in the GamePiece.vb? |
    
(96.245.178.53) | Generally, an "ArgumentNullException" error occurs because you are trying to use a variable that has not yet been initialized (in other words, is still Null).
In the statement you have listed, there are a couple of possibilities:
The playingPieces texture may not yet be loaded. Is the line to load the texture included in the LoadContent method? The code for this is a the bottom of page 28.
The EmptyPiece rectangle may not be defined. This is lss likely, as the rectangle is created when it is declared on page 51.
Finally, the GamePiece class, defined on page 33, contains PieceWidth and PieceHeight values. These need to be declared as Public Const, as they don't refer to instance members, but shared members across all instances of the GamePiece class.
Hope that helps. If not, if you want to zip up and e-mail me your current project, I can look for other causes.
- Kurt |