Reputation: 1
I'm making a game in monogame that uses fake windows as a puzzle element. I'm able to resize the windows, and I figured out how to crop images at the edges of the window, but I can't figure out how to crop text when you resize a window.
I can't just remove each letter when they go behind the border, because:
SpriteFont
class and _spriteBatch.DrawString
method for my text.Basically, I want the following code to crop the text in some way
SpriteFont font = Content.Load<SpriteFont> ("font file");
_spriteBatch.Begin();
_spriteBatch.DrawString(
font,
"Text here",
Vector2.Zero,
Color.White
);
_spriteBatch.End();
I looked through the documentation, but couldn't find any overloads that let you crop text. Please help.
Upvotes: 0
Views: 42
Reputation: 2058
There is a property on the sprite batch for a scissor rectangle, use it to specify the area which it is allowed to draw within.
Upvotes: 0