2016-10-20 28 views
-4

所以我在一個C#控制檯應用程序中製作遊戲,我很好奇如何做一些像RPG遊戲中看到的動畫文本樣式。任何幫助,將不勝感激。如何在C#中製作RPG動畫文本?

+0

https://開頭計算器.com/questions/737195/blink-text-in-c-sharp – ElectricRouge

+0

這並不是我正在尋找的東西。 –

+0

http://stackoverflow.com/questions/33538527/display-a-image-in-a-console-application/33604540 – fubo

回答

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

你也可以把它通用的,寫的不僅僅是串以上(整數,浮點等):

static void SimulateTyping<T>(T message, int delay = 100) { 
    foreach (char character in message.ToString()) 
    { 
     Console.Write(character); 
     System.Threading.Thread.Sleep(delay); 
    } 
} 
+0

它向我顯示一個錯誤:錯誤CS5001。 –

+0

它向我顯示一個錯誤;錯誤CS5001 –

+0

'using System; using System.Collections.Generic;使用System.Linq的 ; using System.Text; using System.Threading.Tasks; 命名空間C_sharp_Testing { 類節目 { 靜態無效的主要(字符串[]參數) { } 靜態無效SimulateTyping (T消息,INT延遲= 100) { 的foreach(在消息字符的字符。 ToString()) { Console.Write(character); System.Threading.Thread.Sleep(delay); } } } } ' –