public void Draw(GraphicsDevice gdev, SpriteBatch spriteBatch) { spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, Camera.WorldSpaceMatrix); DrawGrid(spriteBatch); Map.Draw(spriteBatch); foreach (LevelGeometry geom in SelectedObjects) { ShapeRenderer.OutlineRect(spriteBatch, new Color(0.0f, 0.0f, 1.0f), geom.Position, geom.Size); } foreach (LevelGeometry geom in Map.Geometry) { Rectangle rect = new Rectangle(geom.Position.ToPoint(), geom.Size.ToPoint()); if (rect.Contains(Camera.ScreenToWorldCoordinates(MousePosition))) { ShapeRenderer.OutlineRect(spriteBatch, new Color(0.5f, 0.5f, 1.0f), geom.Position, geom.Size); } } ShapeRenderer.Rect(spriteBatch, Color.Red, Camera.Position, new Vector2(3, 3)); spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred); var value = Camera.ScreenToWorldCoordinates(MousePosition); string debugText = String.Format("mouz: {0} {1} {2} {3} {4} {5}", MousePosition.X, MousePosition.Y, value.X, value.Y, Camera.ViewportWidth, Camera.ViewportHeight ); TextRenderer.Print(spriteBatch, debugText, Vector2.Zero, Color.White); spriteBatch.End(); }