Frequently Asked Questions


General Code/Logic Questions

"ArgumentNullException was unhandled : This method does not accept null for this parameter. Parameter name: texture"

A: What you need are two texture files: XNALibCircle.png and XNALibSquare.png, both of these texture files must be located in the Textures folder under Resources.

 

Do this:

 

Look at the “UsefuleFiles” folder from any of the week-1 examples (e.g., 1.Speed). You will see the “Resources” folder. Make sure:

 

·       Copy the entire Folder into your project’s Content folder, so in your project’s “Content” folder you will see:

o   Content.contentproj

o   Resources (which has three sub-folders:

§  Textures (the two png files must be located in this folder)

§  Audio – can be empty

§  Fonts – Arial.spritefont.

Now, you should be able to compile/run.

 

    if (mBall.CenterX < 0f){

       PlayACue("BelowZero");

    }
How come my audio cue plays continuously?
A: Because you did not update the mBall.CenterX position after you play the audio cue. Your logic here says, if mBall.CenterX is less than 0, then play the audio cue. Whenever this condition is true, the audio cue plays. Here you need to figure out when you want to play the cue:

Figure out what you want to do and code accordingly. To support the "event", one way may be:

    if (mBall.CenterX < 0f) {

       PlayACue("BelowZero");

       mBall.RemoveFromAutoDrawSet(); // Make the ball disappear

       mBall.CenterX = 1f;

       // ... later on your logic should/may decide to

       //    add the ball back to the auto draw set

    }

 

    if (mBall.CenterX == 4f){

       PlayACue("TouchesFour");

    }
I can see my ball fly across the X=4f line, but the audio cue won't play, why?
A: Do not test for floating point equality! The chance of a general floating number equal to another one is close to zero!  In general, you can only test for floating point equality when you have specifically set a variable to a well known constant (e.g., X==0f). Otherwise, you should test for inequality. In this case, you can test for if your CenterX is greater than 4f. 

 


Bugs/Features with XGCS1Lib:

    public class ClassExample : XNACS1Base

    {

        float a = World.WorldDimension.X;

    }

The above will crash because the World-class (XNACS1Base.World) is not initialized.

A:   PlayBackgroundAudio(null, 0f);

A: From any source file, you must include the XNACS1Lib by:

using XNACS1Lib;

And then, you can access to user input by typing the full name to GamePad, e.g., to check for A button click, you can:

            XNACS1Base.GamePad.ButtonAClicked();

To call other library functions, e.g., to clamp to WorldBound:

            XNACS1Base.World.ClampAtWorldBound(yourObject);

A: To test for button present events, you do:

if (GamePad.ButtonAClicked()) {

           // Button-A Clicked event has occured ...

 

To poll for current state of button A, you can do:

            if (GamePad.Buttons.A == ButtonState.Pressed)  

           // currently Button-A is depressed


Problems relating to XBOX 360: