我的代码似乎编译好了,但是当我尝试运行它时,它的挂起非常糟糕.
我已经与Riemers XNA教程一直跟随一起在这里.
我对C#很熟悉,但绝不是专家.到目前为止,我没有遇到任何问题,并且没有任何错误或异常被抛出......它只是挂断了.我在他的相关论坛上看过,用户讨论过其他问题,通常与拼写错误或代码错误有关,但那里没有这样的东西......每个人似乎都可以运行得很好.
有没有我做错了?底部的嵌套for循环对我来说似乎有点笨拙.screenWidth和screenHeight分别为500和500.
BTW:这是从LoadContent重写方法运行的,所以它应该只运行一次,据我所知.
private void GenerateTerrainContour()
{
terrainContour = new int[screenWidth];
for (int x = 0; x < screenWidth; x++)
terrainContour[x] = screenHeight / 2;
}
private void CreateForeground()
{
Color[] foregroundColors = new Color[screenWidth * screenHeight];
for (int x = 0; x < screenWidth; x++)
{
for (int y = 0; y < screenHeight; y++)
{
if (y > terrainContour[x])
foregroundColors[x + y * screenWidth] = Color.Green;
else
foregroundColors[x + y * screenWidth] = …Run Code Online (Sandbox Code Playgroud) 这是基本信息:
而问题是:
每次我尝试编译一段使用任何表单方法的代码时,都会收到此错误:
error CS0234: The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)
我到处都看.我该怎么做才能解决这个问题?
PS - 如果您真的想要或需要查看代码,我可以将其粘贴到响应中.我不会这样做,除非有人问,因为它有点长.