是否可以永久更改纹理的alpha值而不将其渲染到另一个表面?
You could use Texture2D.GetData<Color>()
and Texture2D.SetData<Color>()
and overwrite the alpha value.
This method could be a bit tricky when using Textures with premultiplied alpha.
If you need to change the transparency in game simply multiply Color.White by the amount you want it to be transparent. This has almost no additional overhead as the pixels color values are already being multiplied by what color you pass into the draw function. Its simply 1 additional flop per loop.
spriteBatch.Draw(texture, position, sourceRect, Color.White * 0.5f, .......)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.