Coding4Fun
10 .NET Programming Projects for Wiimote, World of Warcraft, YouTube and More

NullReferenceException on enemy attempting to shoot

Latest post Tue, Aug 4 2009 8:46 PM by Brian Peek. 3 replies.
  • Mon, Aug 3 2009 7:49 AM

    • clubo
    • Top 10 Contributor
    • Joined on Mon, Aug 3 2009
    • Posts 2

    NullReferenceException on enemy attempting to shoot

    Hi,

    I'm working my way through Chapter 1 and have run into the issue above. When the enemy attempts to shoot that exception is thrown on the contentManager argument send to the EnemyShot constructor because the contentManager is null. I've rechecked my code over and over but cannot see the issue and its probably so obvious. Any help would be appreciated.

  • Tue, Aug 4 2009 1:07 AM In reply to

    • Brian Peek
    • Top 10 Contributor
      Male
    • Joined on Wed, Jul 16 2008
    • Niskayuna, NY
    • Posts 53

    Re: NullReferenceException on enemy attempting to shoot

    Hello,

    Can you veriify that the ContentManager object is being passed through to the EnemyGroup object?  EnemyShot is getting its ContentManager from that.

    Otherwise, if you can, please .zip up your code and either attach it to a forum post here or send it to me.  You can use the Contact Us link above to email me and I can reply with an address to send it to.

    Thanks!

    Brian

  • Tue, Aug 4 2009 4:20 PM In reply to

    • clubo
    • Top 10 Contributor
    • Joined on Mon, Aug 3 2009
    • Posts 2

    Re: NullReferenceException on enemy attempting to shoot

    Thank you for the hint, I found my problem, I left out

    : base(contentManager)

    from the EnemyGroup constructor. I knew it was something silly.  Thanks again for the hint got me looking in the right direction :).

  • Tue, Aug 4 2009 8:46 PM In reply to

    • Brian Peek
    • Top 10 Contributor
      Male
    • Joined on Wed, Jul 16 2008
    • Niskayuna, NY
    • Posts 53

    Re: NullReferenceException on enemy attempting to shoot

    That'll do it.  Glad you got it running.  Enjoy!

Page 1 of 1 (4 items) | RSS
Powered by Community Server (Non-Commercial Edition), by Telligent Systems