如何在c#中制作RPG动画文本
本文关键字:RPG 动画 文本 | 更新日期: 2023-09-27 18:13:52
我正在c#控制台应用程序中制作一款游戏,我很好奇如何做一些像RPG中看到的动画文本风格的东西。
这个函数应该可以达到这个效果:
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
}
}
你也可以使它泛型,写的不仅仅是字符串(int, float等):
static void SimulateTyping<T>(T message, int delay = 100) {
foreach (char character in message.ToString())
{
Console.Write(character);
System.Threading.Thread.Sleep(delay);
}
}