This is a new start in the summer of 2025. capribeach studio is up and running!
MonoGame Extended and GUM
I love coding because it is fundamentally about problem-solving. Each time I find a solution that works, I experience a satisfying sense of success. On particularly good days, I might solve multiple problems, but even one solution is enough to keep me motivated. The trickier the issue, the greater the eventual reward.
Recently, one of the most challenging tasks I’ve faced has been ensuring that my game’s display ratios are correct for all screen sizes and resolutions. I needed to get the GUM user interface library to work seamlessly with MonoGame.Extended. Using the MonoGame Extended viewportAdapter was straightforward when the application only needed to scale up or down according to the screen size. However, I initially struggled with the BoxingViewportAdapter, which involves letterboxing and pillarboxing.
After some effort, I finally found the appropriate transformMatrix.Translation that allows all UI elements to scale correctly. If you’re facing a similar issue, my GumSizing() method might be helpful. Happy coding!
GUM TransformMatrix
private void GumSizing()
{
if (_viewportAdapter == null) { return; }
//_viewportAdapter.Reset();
GraphicalUiElement.CanvasWidth = _viewportAdapter.ViewportWidth;
GraphicalUiElement.CanvasHeight = _viewportAdapter.ViewportHeight;
var newX = _viewportAdapter.Viewport.X;
var newY = _viewportAdapter.Viewport.Y;
var transformMatrix = Matrix.Identity;
transformMatrix.Translation = new Vector3(-newX, -newY, 0);
GumService.Default.Cursor.TransformMatrix = transformMatrix;
GumService.Default.Root?.UpdateLayout();
}
A New Start
Design Your Life - Code Your Dream. This is the capribeach website. It offers a glimpse into my work. And now and then I share colorful pictures that I have photographed. Welcome.