问题描述
我的Texture2D的二维阵列,它持有该阵列中的地图的不同部分。我有一个问题,虽然,当我运行游戏,地图绘制正确,但由于某些原因,数组[0,0]质地重叠我所有的纹理包括我的球员的纹理和质感鼠标。每隔质地可以作为我的鼠标和球员质感正确重叠地图。
我现在在地图纹理被拉到一起使用嵌套循环是真糊涂
下面是我为我的地图,我在比赛中的Draw方法调用绘制方法:
公共无效抽奖()
{
//从二维数组
绘制地图供(排INT = 0;排< mapTexture.GetLength(0) ;排++)
{
为(INT COL = 0;&山坳LT; mapTexture.GetLength(1);西++)
{
spriteBatch.Draw(mapTexture [行,列] ,mapPosition [行,列],Color.White);
} //结束为
} //结束为
} //结束绘制()
我的实际抽奖方式:
保护覆盖无效抽奖(gameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(SpriteSortMode.BackToFront,BlendState.AlphaBlend);
spriteBatch.Draw(mouseIcon,mouseIconPosition,Color.White);
player.Draw();
map.Draw();
spriteBatch.End();
base.Draw方法(gameTime);
} //结束绘制()
尝试颠倒顺序,他们正在绘制的,并使用 SpriteSortMode.Deferred
I have an 2d array of Texture2D, it holds the different parts of the map in this array. I have a problem though, when I run the game, the map is drawn correctly but for some reason the array[0, 0] texture overlaps all my textures including my player texture and mouse texture. Every other texture works as my mouse and player texture correctly overlaps the map.
I'm really confused right now as the map textures are being drawn together using a nested for loop.
Here is my draw method for my map which I call in the Game's Draw method:
public void Draw()
{
// Draws the Map from a 2D Array
for (int row = 0; row < mapTexture.GetLength(0); row++)
{
for (int col = 0; col < mapTexture.GetLength(1); col++)
{
spriteBatch.Draw(mapTexture[row, col], mapPosition[row, col], Color.White);
}//end for
}//end for
}//end Draw()
My actual draw method:
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
spriteBatch.Draw(mouseIcon, mouseIconPosition, Color.White);
player.Draw();
map.Draw();
spriteBatch.End();
base.Draw(gameTime);
}//end Draw()
Try inverting the order that they're drawn, AND use SpriteSortMode.Deferred
这篇关于XNA绘制顺序不工作的权利的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!