English 中文(简体)
XNA: 是否有办法直接从零敲碎打中抽取tile?
原标题:XNA : Is there a way to draw tile from a tileset directly?
  • 时间:2012-01-13 10:49:25
  •  标签:
  • xna
  • tiles

To elaborate : I have a tileset with 4 tiles [32 x 32]. For sake of the example let s call them Dirt, Grass, Asphalt, Cement.
I want to draw a relatively long surface of Grass [96 x 32]. Is there any way to use the tiling mechanism of XNA (LinearWarp) to draw them using single Draw() call ?

我尝试:

spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap,null,null);
GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
spriteBatch.Draw(_tileSetTexture /* 64 x 64 */, destRectangle/* 96 x 32*/, TileFrame /*32 x 32*/, Color.White, 0f , Vector2.Zero ,SpriteEffects.None, 0f);

我知道,可以选择将每一块土地推向不同的文本2D,然后使用XNA LinearWrap的“延伸”源径,以填补这一空白,但我需要它们都掌握一个大的TileSet图像,并尽可能简单地加以实现。

最佳回答

做不到这一点,但好消息是,没有理由这样做。 业绩福利几乎肯定会完全忽略不计。 请注意:SpriteBatch.Draw() 电话:t really 提取任何东西;在缓冲结束时添加 sp信息;在你打电话时,全方位缓冲器一度照亮。

你可以用几度的tile光覆盖整个屏幕,只使用手工艺的bat,而这种 is子在现代录像卡的批量附近任何地方会走。

问题回答

暂无回答




相关问题
copying a texture in xna into another texture

I am loading a Texture2D that contains multiple sprite textures. I would like to pull the individual textures out when I load the initial Texture to store into separate Texture2D objects, but can t ...

XNA Antialias question!

I ve got problems with XNA and antialiasing. I can activate it using graphics.PreferMultiSampling = true; graphics.ApplyChanges(); however - it s only 2x antialiasing. Even if I set ...

Take screen shot in XNA

How can I take a screen shot of the screen in XNA? Is it possible without System.Drawing.Graphics.CopyFromScreen or Win32API? If it s not possible, Is there any way to draw a System.Drawing.Bitmap to ...

XNA .Fbx textures

I m using the standard .fbx importer with custom shaders in XNA. The .fbx model is UV wrapped properly and is textured appropriately when I use BasicEffect. However when I use my custom effect I have ...

Can t install XNA

I m trying to install XNA. When the installation starts I got an error that says "XNA GSE 1.0 refresh requires Visual C# 2005 express edition sp1..." I use Windows 7 and I have Visual Studio 2008 &...

Is there a 3D equivalant to clamp in XNA?

I m building a 3D game but i only plan on using a 2D perspective thus not taking the z axis into the equasion, i want to be able to limit the movement of one of my models so it doesn t move out of the ...

Fetching the vertices from the backbuffer (HLSL) on XNA

Hello and sorry for the obscure title :} I`ll try to explain the best i can. First of all, i am new to HLSL but i understand about the pipeline and stuff that are from the fairy world. What i`m ...

Simple XNA 2d physics library

Working on a 2D project and wanted some recommendations on a simple 2d physics library for use in C# with the XNA framework. I was looking at Farseer or physics2d. Anyone have any other suggestions? ...