So I'm making a game in a C# Console Application and I am curious on how to do something like a animated text style like you see in RPG's for example. Any help would be appreciated.
Asked
Active
Viewed 182 times
-4
-
https://stackoverflow.com/questions/737195/blink-text-in-c-sharp – ElectricRouge Oct 20 '16 at 10:08
-
This isn't exactly what I'm looking for. – Harry Court Oct 20 '16 at 10:14
-
http://stackoverflow.com/questions/33538527/display-a-image-in-a-console-application/33604540 – fubo Oct 20 '16 at 10:24
-
Be more specific. We can only guess what you mean by "animated text style like you see in RPG's". – CookedCthulhu Oct 20 '16 at 10:25
-
https://forums.unrealengine.com/attachment.php?attachmentid=32362&d=1427507365 – Harry Court Oct 21 '16 at 05:30
1 Answers
1
This function should do the trick:
static void SimulateTyping(string message, int delay = 100) { //'delay' is optional when calling the function
foreach (char character in message) //take every character from your string seperately
{
Console.Write(character); //print one character
System.Threading.Thread.Sleep(delay); //wait for a small amount of time
}
}
You can also make it generic, to write more than just strings (int, float etc.):
static void SimulateTyping<T>(T message, int delay = 100) {
foreach (char character in message.ToString())
{
Console.Write(character);
System.Threading.Thread.Sleep(delay);
}
}

CookedCthulhu
- 744
- 5
- 14
-
-
-
`using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace C_sharp_Testing { class Program { static void Main(string[] args) { } static void SimulateTyping
(T message, int delay = 100) { foreach (char character in message.ToString()) { Console.Write(character); System.Threading.Thread.Sleep(delay); } } } } ` – Harry Court Oct 21 '16 at 10:54 -
I copied your code into VS and it works without errors. Try to rebuild your solution or copy it into a new project. – CookedCthulhu Oct 21 '16 at 12:25