Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2004
    Location
    USA
    Posts
    1,529

    Question DrumGame null reference exception. TimeScale. Help?

    Well I am at a loss. I am going through the drum game, and I am at lesson 54 - Renderer – Trackes, Time Scaling.

    In my config.xml I have:

    Code:
    <hitRange value="8"/>
        <timeScale vaule="1.5"/>

    in my Config.cs I have:

    Code:
     public static int HitRange;
            public static float TimeScale;
    
    public static void LoadOptions()
            {
    	  HitRange = ParseInt(GetNodeValue(xmlConfig, "/config/options/hitRange"));
                TimeScale = ParseFloat(GetNodeValue(xmlConfig, 	"/config/options/timeScale"));
            }

    Now HitRange works fine, but TimeScale is giving me a “null reference exception was unhandled” error When I try to return on this method.

    Code:
    public static string GetNodeValue(XmlDocument xmlDocument, string nodePath)
            {
                XmlNode node = xmlDocument.SelectSingleNode(nodePath);
                if (node != null)
                    return node.Attributes["value"].Value;

    On the video it works fine for them. So what have I done wrong?

  2. #2
    Join Date
    Mar 2004
    Posts
    0
    Code:
    <timeScale vaule="1.5"/>
    should be
    Code:
    <timeScale value="1.5"/>

  3. #3
    Join Date
    Dec 2003
    Location
    3dbuzzmania
    Posts
    4,064
    Ouch wolfknightly. Nice catch Nelson.

  4. #4
    Join Date
    Sep 2004
    Location
    USA
    Posts
    1,529
    Oh my god man, I must be blind! How could I not see that. I mean I went over and over it. I looked at the two lines word for word, and I thought letter for letter, and I swore that they were the same! I just don't get why my mind does that some times. It just stops working right for a bit. It is like your words changed the shape of reality Nelson. You must be a witch! Usually I would burn you, but sense you helped me, and it is working again, I will let you go with just a warning.

    Thanks a lot Nelson.


    Yeah TF242, ouch indeed. I feel foolish now. It is funny because I was thinking about just deleting all those lines and re-typing them out. Now I wish I had. It just seemed so silly at the time, because I was so sure everything was right. In the future I will try and be less sure.
    Last edited by Wolfknightly; 11-23-2010 at 12:52 AM.

  5. #5
    Join Date
    Dec 2003
    Location
    3dbuzzmania
    Posts
    4,064
    No worries dude, it happens to the best of us.

  6. #6
    Join Date
    Sep 2004
    Location
    USA
    Posts
    1,529
    Yeah thanks. It still bothers me though. Fifty three lessons without needing to ask for help, and that is what stops me. But isn't it always the stupidest of mistakes that are the hardest to find?


    --- The other big mistake that I had was when I let intelliSense fill in the wrong word and it didn't brake anything. Later when the code wasn't working right, or at all, I forget, I found that I had the same line in a different method. Commenting out that line of code didn't help either, I had to to make it say the right word. The problem in that was that it seemed to be working right for like two videos before the one I was on. I was going back and forth between the video I was on and the one before it, and couldn't find anything I was doing wrong. That is because the mistake was three videos back. But I found that one and solved it on my own. I gave up on this one because it just wasn't making any sense to me. Sneaky misspelled word!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •