XNA / Monogame GraphicsDevice方法改变了吗?什么是实例化它的正确方法?

时间:2014-05-09 23:30:51

标签: xna monogame

我有几个月前写过的游戏,它运行良好。最近我更新了我的Monogame引用,现在已经编译和工作的东西没有了,因为在GraphicsDevice上签名已经改变,但现在还不确定如何最好地实现它。 Haven还没有找到任何例子。

原帖:

var obsticleTexture = new Texture2D(new GraphicsDevice(), 0, 0);

但现在我得到了

  

' Microsoft.Xna.Framework.Graphics.GraphicsDevice'不包含   取0参数的构造函数

签名改为:

GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile graphicsProfile, PresentationParameters presentationParameters)

我尝试过new Texture2D(new GraphicsDevice(null, GraphicsProfile.HiDef, new PresentationParameters()),0,0);,但这没有用。

1 个答案:

答案 0 :(得分:1)

试试这个:

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

Texture2D texture = new Texture2D(newGraphicsDevice, 1, 1)

请注意,Texture2D的宽度和高度必须为> 0

相关问题