Xna游戏开发 - 游戏背景问题

时间:2021-11-16 11:32:06

Im starting with XNA and i need an advice about the following.

我从XNA开始,我需要有关以下内容的建议。

I have a .jpg file with my space ship game background with the following size:

我的太空船游戏背景有一个.jpg文件,大小如下:

   width:  5000px 

   height: 4800px

When i try to load the texture i get the following error:

当我尝试加载纹理时,我收到以下错误:

Texture width or height is larger than the device supports

纹理宽度或高度大于设备支持

What is the most used technique to move the background at the same time that your ship is moving?

在船舶移动的同时移动背景最常用的技术是什么?

Thanks a lot.

非常感谢。

Kind Regards.

Josema.

3 个解决方案

#1


One way would be to separate your image into smaller tiles and draw the visible ones.

一种方法是将图像分成较小的图块并绘制可见图像。

However this technique suffers from a problem when bilinear sampling is used, because the colors bleeds from the one side of the texture to the other. You can probably compensate by disabling texture WRAP sampling or by grabbing a single of pixels from the tiles next to.

然而,当使用双线性采样时,该技术存在问题,因为颜色从纹理的一侧渗透到另一侧。您可以通过禁用纹理WRAP采样或从旁边的图块中抓取一个像素来进行补偿。

For example if you want 256x256 textures, you would only display 255x255 tiles, because one line (right and bottom) is a copy from the tiles next to it.

例如,如果您需要256x256纹理,则只显示255x255个图块,因为一行(右侧和底部)是其旁边的图块的副本。

Hope it makes sense, otherwise I'll have to paint a picture :-)

希望它有意义,否则我将不得不画一幅画:-)

#2


The texture limit is determined by graphics card, I believe. You want to break the texture down to smaller images.

我相信纹理限制是由显卡决定的。您希望将纹理分解为较小的图像。

Try something like this. He's tiling a simple 40x40, but you might use it a a guideline on how to tile yours. http://forums.xna.com/forums/p/19835/103704.aspx

尝试这样的事情。他正在为一个简单的40x40平铺,但你可以用它作为如何平铺你的指南。 http://forums.xna.com/forums/p/19835/103704.aspx

#3


To move the background at the same time that your ship is moving you can implement a camera.

要在船舶移动的同时移动背景,您可以实施相机。

The following links might help-

以下链接可能有所帮助 -

http://adambruenderman.wordpress.com/2011/04/05/create-a-2d-camera-in-xna-gs-4-0/ http://www.dreamincode.net/forums/topic/237979-2d-camera-in-xna/

#1


One way would be to separate your image into smaller tiles and draw the visible ones.

一种方法是将图像分成较小的图块并绘制可见图像。

However this technique suffers from a problem when bilinear sampling is used, because the colors bleeds from the one side of the texture to the other. You can probably compensate by disabling texture WRAP sampling or by grabbing a single of pixels from the tiles next to.

然而,当使用双线性采样时,该技术存在问题,因为颜色从纹理的一侧渗透到另一侧。您可以通过禁用纹理WRAP采样或从旁边的图块中抓取一个像素来进行补偿。

For example if you want 256x256 textures, you would only display 255x255 tiles, because one line (right and bottom) is a copy from the tiles next to it.

例如,如果您需要256x256纹理,则只显示255x255个图块,因为一行(右侧和底部)是其旁边的图块的副本。

Hope it makes sense, otherwise I'll have to paint a picture :-)

希望它有意义,否则我将不得不画一幅画:-)

#2


The texture limit is determined by graphics card, I believe. You want to break the texture down to smaller images.

我相信纹理限制是由显卡决定的。您希望将纹理分解为较小的图像。

Try something like this. He's tiling a simple 40x40, but you might use it a a guideline on how to tile yours. http://forums.xna.com/forums/p/19835/103704.aspx

尝试这样的事情。他正在为一个简单的40x40平铺,但你可以用它作为如何平铺你的指南。 http://forums.xna.com/forums/p/19835/103704.aspx

#3


To move the background at the same time that your ship is moving you can implement a camera.

要在船舶移动的同时移动背景,您可以实施相机。

The following links might help-

以下链接可能有所帮助 -

http://adambruenderman.wordpress.com/2011/04/05/create-a-2d-camera-in-xna-gs-4-0/ http://www.dreamincode.net/forums/topic/237979-2d-camera-in-xna/