【发布时间】:2016-06-06 21:36:05
【问题描述】:
好的,所以我正在关注本教程Water Reflection XNA,当我使用 monogame 调整代码时,我无法获得最终结果。 所以这是我的 LoadContent 代码:
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
texture = Content.Load<Texture2D>("test");
effect = Content.Load<Effect>("LinearFade");
effect.Parameters["Visibility"].SetValue(0.7f);
}
和我的绘图代码:
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
//effect.CurrentTechnique.Passes[0].Apply();
spriteBatch.Draw(texture, new Vector2(texturePos.X, texturePos.Y + texture.Height), null, Color.White * 0.5f, 0f, Vector2.Zero, 1, SpriteEffects.FlipVertically, 0f);
spriteBatch.End();
spriteBatch.Begin();
spriteBatch.Draw(texture, texturePos, Color.White);
spriteBatch.End();
base.Draw(gameTime);
}
最后是我的 .fx 文件:LinearFade
所以当我应用效果时问题就开始了。我的纹理只是消失了,如果我在 Draw 方法中评论效果部分,我会得到带有淡入淡出的镜像(弄乱 alpha“Color.White * 0.5f”),但没有像他在教程中从图片中间到图片底部那样的淡化效果.我在单体游戏和着色器方面仍然没有太多经验,但我正在学习。
如果有人知道如何解决这个问题或如何使它像上面的教程一样,那就太好了。顺便说一句,英语不好不是我的主要语言。
【问题讨论】: