定义两个 SpriteSortModes? [英] Defining two SpriteSortModes?
问题描述
在 DirectX 中,可以将 D3DXSPRITE 参数设置为两者的组合:
In DirectX it is possible to set the D3DXSPRITE parameters to be a combination of both:
D3DXSPRITE_SORT_DEPTH_BACKTOFRONT
和
D3DXSPRITE_SORT_TEXTURE
意味着精灵首先按层深度排序,然后按它们所在的纹理排序.我正在尝试在 XNA 中做同样的事情,但我遇到了一些问题.我试过了:
Meaning that sprites are sorted first by their layer depth and then secondly by the texture that they are on. I'm trying to do the same in XNA and i'm having some problems. I've tried:
SpriteBtch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront & SpriteSortMode.Texture, SaveStateMode.None);
但它不起作用,似乎只是按照纹理排序来执行它们,而忽略了纹理层深度.难道我做错了什么!?还是根本不可能?
But it doesn't work and just seems to do them in Texture ordering, ignoring the textures layer depth. Am I doing something wrong!? Or is it not even possible?
推荐答案
SpriteSortMode 是一个枚举,应该使用 | 进行组合.操作员:
SpriteSortMode is an enum and should be combined using the | operator:
SpriteSortMode.BackToFront | SpriteSortMode.Texture
更新:如这篇文章 提到,您的场景在 XNA 中是不可能的:
Update: as this article mentions, your scenario is not possible in XNA:
按深度排序和排序依据纹理是互斥的
sorting by depth and sorting by texture are mutually exclusive
这篇关于定义两个 SpriteSortModes?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!