简体   繁体   English

游戏控制台为StringBuilder,String []还是其他?

[英]Game console as StringBuilder, String[] or something else?

I'm making an XNA game console which should draw the output lines as they are added. 我正在制作XNA游戏机,该游戏机应在添加输出时绘制输出线。 I want to draw only the last 10 lines and I can't figure out how to produce the actual output string. 我只想画最后10行,我不知道如何产生实际的输出字符串。

I was trying to use StringBuilder to collect all lines in it and then read the last lines into a String , but it turns out StringBuilder doesn't have a specific line retrieval method. 我试图使用StringBuilder收集其中的所有行,然后将最后几行读入String ,但是事实证明StringBuilder没有特定的行检索方法。 I tried using String[] , but it adds significant lag increasing over time. 我尝试使用String[] ,但是随着时间的推移,它会增加明显的延迟。 How should I do this? 我应该怎么做?

If you no longer need messages older than 10 lines, you could use a typed Queue . 如果您不再需要超过10行的消息,则可以使用键入的Queue

Depending on how you're rendering it, it might be the easiest way of managing that data. 根据呈现方式的不同,它可能是管理数据的最简单方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM