How do I make a word wrap that detects when the text would run off the screen, and put an enter?
Here is the formula I have:
[CODE]if fontsize<18
{
amountofcharactersthatwillfitonthescreen = 18 + (18-fontsize)
}
else
{
amountofcharactersthatwillfitonthescreen = 18 + (fontsize - 18)
}
I don't know if that formula will work, and what the character that represents "
" is. (I know it's not technically a formula).
That doesn't make even the SLIGHTEST amount of sense. Heres something I wrote right here, i haven't compiled it, but it looks gud.
Code:
public static WordWrap(String text, Spritefont font, Rectangle screen)
{
//Seperate string to words
string[] words = text.Split(' ');
//Keep track of how much x space it needs
int tempX = 0;
//Return string
string ret = string.Empty;
//Add first word automatically
ret += words[0];
//Go through other words
for (int i = 1; i < words.Length; i++)
{
Vector2D size = font.MeasureString(text);
if ((size.X + tempX) < Rectangle.Width)
{
ret += " " + words[i];
tempX += size.X;
}
else
{
//Reset tempX
tempX = 0;
//Add new line and word
ret += "rn" + words[i];
}
}
return ret;
}
Let me know if it works
Zuneapps...Can you let me know if this helped you.
Im not a fan of the OP topic abandoning
__________________
~Shutout5591~ [FINAL] Asteroids 1.0
If you like me work or I have helped you, + Rep me!
That doesn't make even the SLIGHTEST amount of sense. Heres something I wrote right here, i haven't compiled it, but it looks gud.
Code:
public static WordWrap(String text, Spritefont font, Rectangle screen)
{
//Seperate string to words
string[] words = text.Split(' ');
//Keep track of how much x space it needs
int tempX = 0;
//Return string
string ret = string.Empty;
//Add first word automatically
ret += words[0];
//Go through other words
for (int i = 1; i < words.Length; i++)
{
Vector2D size = font.MeasureString(text);
if ((size.X + tempX) < Rectangle.Width)
{
ret += " " + words[i];
tempX += size.X;
}
else
{
//Reset tempX
tempX = 0;
//Add new line and word
ret += "rn" + words[i];
}
}
return ret;
}
Let me know if it works
Zuneapps...Can you let me know if this helped you.
Im not a fan of the OP topic abandoning
You'll be waiting for a while; his posting got disabled.
"Silly ZuneApps, multiple accounts are for kids!"
__________________
o/ lolBeatrice \o
Quote:
Originally Posted by #sos-dan
21:42 <Azu-nyan>: And no, no happying. <.<
21:42 <Azu-nyan>: fapping*
21:42 <vonPreussen>: Freudian typos xD
You'll be waiting for a while; his posting got disabled.
"Silly ZuneApps, multiple accounts are for kids!"
What is this? I only have this account. The other account is my brother's. Also, as you can see, my posting has never been disabled, so you should stop spreading rumors.
What is this? I only have this account. The other account is my brother's. Also, as you can see, my posting has never been disabled, so you should stop spreading rumors.
Actually, it was. I saw it myself. It was probably re-enabled before you logged in.
__________________
"Against logic there is no armor like ignorance." - Laurence J. Peter
First of all, why was his posting abilities disabled? Second, he merged with me. Third, I have the program on my flash drive, and it's been having some problems, so I can't test it until it gets fixed.
First of all, why was his posting abilities disabled? Second, he merged with me. Third, I have the program on my flash drive, and it's been having some problems, so I can't test it until it gets fixed.
Con-grad-ya-****ing-lations. This thread has useful code and it is now in the flame board because of you. Im gonanr epost it, DO NOT TOUCH THE THHREAD I AM MAKING FOR IT>
__________________
~Shutout5591~ [FINAL] Asteroids 1.0
If you like me work or I have helped you, + Rep me!
I don't care usually-I just did myself in fact-but the mere fact that it's ZuneApps says that it probably shouldn't be brought back for anything but historical record.
__________________
o/ lolBeatrice \o
Quote:
Originally Posted by #sos-dan
21:42 <Azu-nyan>: And no, no happying. <.<
21:42 <Azu-nyan>: fapping*
21:42 <vonPreussen>: Freudian typos xD