Codetopia

A place to talk about things related to XNA, .NET, and enterprise application development.
Welcome to Codetopia Sign in | Join | Help
in
Home My Book Blogs Forums Photos Files Roller

Chapter 16 Top-Down Scroller XNA 2.0 Source Code Error

Last post 03-14-2008, 12:03 AM by groundh0g. 4 replies.
Sort Posts: Previous Next
  •  03-11-2008, 10:42 PM 432

    Chapter 16 Top-Down Scroller XNA 2.0 Source Code Error

    After compiling and testing the new code the game experiences an exception after pressing start. The exception occurred in the PixelPerfectHelper::GetOpaqueData function at this point:
    texture.GetData<Color>(pixels);
    As I attempted a work around by putting the above line inside a try and catch statement the result was that collision detection was effectively disabled. Reading the comment regarding the above line I tried using this instead:
    texture.GetData<Color>(1, rect, pixels, 0, texture.Width * texture.Height);
    I'm not too savy with texture data reading and the above line didn't solve the problem. Any help would be appreciated. Thanks :)
  •  03-13-2008, 2:09 PM 436 in reply to 432

    Re: Chapter 16 Top-Down Scroller XNA 2.0 Source Code Error

    The phrase "an exception" is too general to know for sure, but I'm guessing that this is realted to the issue that I described for Chapter 5's convertion to XNA 2.0.

    [The exception would read something like this: "The operation was aborted. You may not modify a resource that has been set on a device, or after it has been used within a tiling bracket."]

    Read the section entitled "Dynamically Modifying Resources (Bug?)" under the description for my XNA 2.0 changes for Chapter 05.

    Here's the link: http://codetopia.com/cs/files/7/xna_book_files/entry382.aspx

    Please let me know if that works for you. If so, I'll update the source code for that chapter and post it again.

    Thanks.
    -- joe

    There are 10 kinds of people in this world -- Those that can count in binary, and those that can't.
  •  03-13-2008, 4:44 PM 438 in reply to 436

    Re: Chapter 16 Top-Down Scroller XNA 2.0 Source Code Error

    The exception was indeed an InvalidOperationException which read "The operation was aborted. You may not modify a resource that has been set on a device, or after it has been used within a tiling bracket."

    I attempted to add GraphicsDevice.Textures[0] = null; before GameObjectManager.Init(); in the Initialize() function of the Game1 class. But that didn't solve the problem.
  •  03-13-2008, 11:40 PM 441 in reply to 438

    Re: Chapter 16 Top-Down Scroller XNA 2.0 Source Code Error

    I added the line:

    GraphicsDevice.Textures[0] = null;

    in the beginning of the Game1.Update() function and it worked.

  •  03-14-2008, 12:03 AM 442 in reply to 441

    Re: Chapter 16 Top-Down Scroller XNA 2.0 Source Code Error

    Thanks for the follow up, Edt. I'll add updating the source for chapter 16 to my list of TODO's.

    -- joe


    There are 10 kinds of people in this world -- Those that can count in binary, and those that can't.
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems