draw backgrounds as partially transparent

GitOrigin-RevId: b570a9aab75d18e6f7778dc851537794f30d801a
This commit is contained in:
Colin McMillen 2020-02-17 19:59:20 -05:00
parent 3107c8448e
commit 43f6bded70

View File

@ -166,13 +166,14 @@ namespace SemiColinGames {
spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null); spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null);
// Draw background. // Draw background.
Color bgBlend = Color.FromNonPremultiplied(new Vector4(1, 1, 1, 0.5f));
Rectangle bgSource = new Rectangle( Rectangle bgSource = new Rectangle(
(int) (camera.Left * 0.25), 0, camera.Width, camera.Height); (int) (camera.Left * 0.25), 0, camera.Width, camera.Height);
Rectangle bgTarget = new Rectangle(0, 0, camera.Width, camera.Height); Rectangle bgTarget = new Rectangle(0, 0, camera.Width, camera.Height);
spriteBatch.Draw(grasslandBg2, bgTarget, bgSource, Color.White); spriteBatch.Draw(grasslandBg2, bgTarget, bgSource, bgBlend);
bgSource = new Rectangle( bgSource = new Rectangle(
(int) (camera.Left * 0.5), 0, camera.Width, camera.Height); (int) (camera.Left * 0.5), 0, camera.Width, camera.Height);
spriteBatch.Draw(grasslandBg1, bgTarget, bgSource, Color.White); spriteBatch.Draw(grasslandBg1, bgTarget, bgSource, bgBlend);
spriteBatch.End(); spriteBatch.End();
// Set up transformation matrix for drawing world objects. // Set up transformation matrix for drawing world objects.
@ -180,12 +181,12 @@ namespace SemiColinGames {
spriteBatch.Begin( spriteBatch.Begin(
SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null, null, transform); SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null, null, transform);
// Draw player.
player.Draw(spriteBatch);
// Draw foreground tiles. // Draw foreground tiles.
world.Draw(spriteBatch); world.Draw(spriteBatch);
// Draw player.
player.Draw(spriteBatch);
// Aaaaand we're done. // Aaaaand we're done.
spriteBatch.End(); spriteBatch.End();