如果我使用以下文字:
for(int i = 255; i > 0; i--)
{
Color transparentBlack = new Color(0, 0, 0, i);
}
我使用这种颜色来从黑色到轻灰色,然后当甲型数值达到零时看不见。 然而,如果我开始怀着白色的价值:
new Color(255, 255, 255, i);
这些物体永远不会被看不到,只能停留在白色。 我也注意到,如果我使用比黑色(50、50、50)光线的数值,则从达尔文到看不见的白色。
我假定,我不理解甲型混杂工程如何,但是否有办法使白色颜色变得容易渗透?
Edit:我引用的背景是科罗拉·CornflowerBlue(100,149,237,255)。
Edit: Sample XNA Program reproduction the interpret. 供使用;创建新的XNA游戏室4.0项目——Windows 游戏(4.0),称为AlphaBlend 测试和测验; 在内容项目中增加新的标准,称之为测试。
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace AlphaBlendTest
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
SpriteFont font;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
font = Content.Load<SpriteFont>("testfont");
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
//spriteBatch.Draw(tR, new Rectangle(100, 100, 100, 100), Color.Red);
Vector2 v2 = new Vector2(0, 0);
spriteBatch.DrawString(font, "Test - White", v2, Color.White);
v2.Y = v2.Y + 50;
spriteBatch.DrawString(font, "Test - Black", v2, Color.Black);
v2.Y = v2.Y + 50;
Color BlackTransparent = new Color(0, 0, 0, 0);
spriteBatch.DrawString(font, "Test - Black Transparent", v2, BlackTransparent);
v2.Y = v2.Y + 50;
Color WhiteTransparent = new Color(255, 255, 255, 0);
spriteBatch.DrawString(font, "Test - White Transparent", v2, WhiteTransparent);
spriteBatch.End();
base.Draw(gameTime);
}
}
}
Edit: This is the image this code draws:
Edit: One of the comments is concerned that this is a Text only related feature of windows. I used text as an example to keep the demo program small; testing with an image gives the same result.
在脱盲方案中添加方括号;制作白白民族党形象,并在内容目录中添加(使用内容管道的缺省值)。 之后加进这一类:
Texture2D tWhiteBox;
在装载方法中添加:
tWhiteBox = Content.Load<Texture2D>("whitebox");
之后在引文中添加以下案文:
v2.Y = v2.Y + 50;
spriteBatch.Draw(tWhiteBox, v2, WhiteTransparent);