Windows Phone 8:多屏幕分辨率

时间:2013-06-16 22:06:35

标签: c# xna windows-phone-8

我想做一款支持多种屏幕分辨率的Windows手机游戏。 我尝试了这个Microsoft教程,但我总是在ResolutionHelper类中收到错误消息。

教程:http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206974(v=vs.105).aspx

错误消息:当前上下文中不存在名称“App”

有什么问题?

namespace WindowsPhoneGame1
{
  public enum Resolutions { WVGA, WXGA, HD720p };

  public static class ResolutionHelper
  {
    private static bool IsWvga
    {
      get
      {
       return App.Current.Host.Content.ScaleFactor == 100;
      }
    }

    private static bool IsWxga
    {
      get 
      { 
       return App.Current.Host.Content.ScaleFactor == 160; 
      }
    }

    private static bool Is720p
    {
      get 
      { 
       return App.Current.Host.Content.ScaleFactor == 150; 
      }
    }

    public static Resolutions CurrentResolution
    {
      get
      {
       if (IsWvga) return Resolutions.WVGA;
       else if (IsWxga) return Resolutions.WXGA;
       else if (Is720p) return Resolutions.HD720p;
       else throw new InvalidOperationException("Unknown resolution");
      }
    }
  }
}

2 个答案:

答案 0 :(得分:2)

要么您缺少using子句(可能是System.Runtime左右),要么App只是Application的缩写。所以仔细看看编译错误。并尝试找到合适的usingApp替换Application,这可能会有效。

答案 1 :(得分:0)

Leo:“我使用Visual Studio Express 2012。”

Visual Studio Express 2012有几种不同的风格。 您需要特定的 - “Visual Studio Express 2012 for Windows Phone”。 请注意,它只能在Windows 8(或8.1)上运行。

相关问题