如何为RenderTarget2D解决此参数错误?

时间:2013-04-03 19:09:02

标签: arguments xna-4.0 rendertarget

作为初学者,我正在使用一些XNA代码。所以我使用这个教程,但似乎我正在做一些事情,我不知道为什么。

http://www.xnadevelopment.com/tutorials/theroadnottaken/theroadnottaken.shtml

我处于路径冲突的部分,这就是我的代码编写方式!

mTrackRender = new RenderTarget2D(graphics.GraphicsDevice, mCarWidth + 100,
               mCarHeight + 100, 1, SurfaceFormat.Color,DepthFormat.Depth24);

mTrackRenderRotated = new RenderTarget2D(graphics.GraphicsDevice, mCarWidth + 100,
                   mCarHeight + 100, 1);

我已经声明了mTrackREnder,并且mTrackREnderRotated在类级别有对象。

嗯,问题是我得到了这两个错误:

  

错误3'Microsoft.Xna.Framework.Graphics.RenderTarget2D'没有   包含一个带有4个参数'

的构造函数

我做错了什么?我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

看看constructors of the RenderTarget2D class。他们都没有接受你试图传递的论据。

在第一种情况下,您传递一个构造函数需要布尔值的整数。在C#中,整数不能隐含地转换为布尔值;使用truefalse代替1和0。

在第二种情况下,不清楚你试图调用哪个构造函数,但是它们都没有采用4个参数,并且没有一个采用整数作为第4个参数。

相关问题