Search code examples
c#windowswindows-phone-7xnamessagebox

How can I implement Dialog Boxes in XNA


How can I implement something like a dialog box in a XNA game? What I want to do is when the dialog box's image is still active, anything below it will stop receiving user input until the box disappears. Using rectangle's Contains() method doesn't seem to work since it's coordinate based.

For example: clicking on an item will pop up a small "Use" box. Even if that box's image is at the same location (or more accurately, on top of) as another item's, clicking there will only trigger the usage of the first item and not display another "Use" box for the second item, effectively disable the second item's input region in the collision rectangle.


Solution

  • Just use some flags to get input

    For example,

    bool accessFlag = true;
    

    Then in Update() method

    if (accessFlag)
    {
      // Take input from user
    }
    

    Then make accessFlag to false when your dialogue box or any other stuff you want, appears. And make it true when pop up disappears.