Search | Statistics | User Listing Forums
XNA Resources
XNA Resources ->  General Discussion -> General Discussion -> View Thread

You are logged in as a guest. ( logon | register )

xna 4 VB ed, Question what did i do wrong?
Jump to page : 1
Now viewing page 1 [25 messages per page]
View previous thread :: View next thread
   General Discussion -> General DiscussionMessage format
 
zerikscythe
Posted 2012-02-29 8:54 AM (#414)
Subject: xna 4 VB ed, Question what did i do wrong?


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?
Top of the page Bottom of the page
Kurt Jaegers
Posted 2012-03-01 6:06 PM (#415 - in reply to #414)
Subject: RE: xna 4 VB ed, Question what did i do wrong?


100100252525

(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
Top of the page Bottom of the page
Jump to page : 1
Now viewing page 1 [25 messages per page]
Jump to forum :
Search this forum
Printer friendly version
E-mail a link to this thread

(Delete all cookies set by this site)
Running MegaBBS ASP Forum Software
© 2002-2014 PD9 Software