如何在C#中制作RPG动画文字?

时间:2016-10-20 10:05:17

标签: c# console

所以我在C#控制台应用程序中制作游戏,我很好奇如何像你在RPG中看到的那样做一些动画文本样式。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

这个功能可以解决问题:

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);
    }
}