public override void Draw(GameTime gameTime) { ResolutionManager.BeginDraw(); spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Camera2D.GetTransformMatrix()); mapManager.Draw(spriteBatch); spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, ResolutionManager.GetTransformationMatrix()); windowManager.Draw(spriteBatch); spriteBatch.End(); }
private static void CalculateMatrixAndRectangle() { //The math involved with calculated our transformMatrix and screenRect is a little intense, so instead of calling the math whenever we need these variables, //we'll calculate them once each frame and store them... when someone needs these variables we will simply return the stored variable instead of re cauclating them every time. //Calculate the camera transform matrix: transformMatrix = Matrix.CreateTranslation(new Vector3(-position, 0)) * Matrix.CreateRotationZ(rotation) * Matrix.CreateScale(new Vector3(zoom, zoom, 1)) * Matrix.CreateTranslation(new Vector3(ResolutionManager.VirtualWidth * 0.5f, ResolutionManager.VirtualHeight * 0.5f, 0)); //Now combine the camera's matrix with the Resolution Manager's transform matrix to get our final working matrix: transformMatrix = transformMatrix * ResolutionManager.GetTransformationMatrix(); //Round the X and Y translation so the camera doesn't jerk as it moves: transformMatrix.M41 = (float)Math.Round(transformMatrix.M41, 0); transformMatrix.M42 = (float)Math.Round(transformMatrix.M42, 0); //Calculate the rectangle that represents where our camera is at in the world: screenRect = VisibleArea(); }
public override void Draw(GameTime gameTime) { _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullNone, null, ResolutionManager.GetTransformationMatrix()); _spriteBatch.Draw(Texture, Position, null, (Color * _colorStrength * Alpha), Rotation, Origin, Scale, SpriteEffects.None, 1.0f); // TODO: use body pos/rot or Sprite pos/rot? _spriteBatch.End(); //_spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend); //_spriteBatch.Draw(_texture, _position, null, (_color * _colorStrength * _fadeAlpha), _rotation, _origin, _scale, SpriteEffects.None, 1.0f); //_spriteBatch.End(); }
public override void Draw(GameTime gameTime) { if (isActive) { _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullNone, null, ResolutionManager.GetTransformationMatrix()); for (int i = 0; i < _barrierBodies.Count; i++) { _spriteBatch.Draw(Texture, ConvertUnits.ToDisplayUnits(_barrierBodies[i].Position), null, Color, _barrierBodies[i].Rotation, Origin, 1.0f, SpriteEffects.None, 1f); } _spriteBatch.End(); } }
public override void Draw(GameTime gameTime) { _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullNone, null, ResolutionManager.GetTransformationMatrix()); _spriteBatch.Draw(Texture, Position, null, Color * Alpha, Rotation, Origin, Scale, SpriteEffects.None, 1.0f); _spriteBatch.End(); }
public override void Draw(GameTime gameTime) { if (Visible) { _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullNone, null, ResolutionManager.GetTransformationMatrix()); DrawingHelper.DrawString(_spriteBatch, _font, _content, _rectangle, DrawingHelper.Alignment.Center, 3, Color.Black); _spriteBatch.End(); } base.Draw(gameTime); }