Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XNA/单游戏图形设备方法更改?什么是实例化它的正确方法?_Xna_Monogame - Fatal编程技术网

XNA/单游戏图形设备方法更改?什么是实例化它的正确方法?

XNA/单游戏图形设备方法更改?什么是实例化它的正确方法?,xna,monogame,Xna,Monogame,几个月前我写了一个游戏,效果很好。最近我更新了我的Monogame参考,现在一些以前编译和工作过的东西没有更新,因为GraphicsDevice上的签名已更改,但不确定现在如何最好地实现它。还没有找到任何例子 原始行: var obsticleTexture = new Texture2D(new GraphicsDevice(), 0, 0); 但现在我明白了 “Microsoft.Xna.Framework.Graphics.GraphicsDevice”不包含 接受0个参数的构造函数 签

几个月前我写了一个游戏,效果很好。最近我更新了我的Monogame参考,现在一些以前编译和工作过的东西没有更新,因为GraphicsDevice上的签名已更改,但不确定现在如何最好地实现它。还没有找到任何例子

原始行:

var obsticleTexture = new Texture2D(new GraphicsDevice(), 0, 0);
但现在我明白了

“Microsoft.Xna.Framework.Graphics.GraphicsDevice”不包含 接受0个参数的构造函数

签名已更改为:

GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile graphicsProfile, PresentationParameters presentationParameters)
我尝试了
newtexture2d(新图形设备(null,GraphicsProfile.HiDef,newpresentationparameters()),0,0)但这不起作用。

试试这个:

GraphicsDevice newGraphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, new PresentationParameters());

Texture2D texture = new Texture2D(newGraphicsDevice, 1, 1)
请记住
纹理2d的宽度和高度必须大于0