简体   繁体   English

我将如何创建这样的输入系统?

[英]How would I go about creating an input system like this?

I just started making a text-adventure in javascript this weekend. 这个周末,我刚刚开始使用javascript进行文字冒险。

I realized that the prompt input system can get really annoying, so I wanted to change over to a bar-input system that would collect input and store it in the "action" variable (see source), exactly like the one is this example I managed to find: http://iainlobb.com/dork/ 我意识到,提示输入系统确实很烦人,所以我想切换到一种条形输入系统,该系统将收集输入并将其存储在“ action”变量中(请参见源代码),就像本示例中的例子一样设法找到: http : //iainlobb.com/dork/

SOURCE: http://dl.dropbox.com/u/96609235/mainfile.txt 来源: http : //dl.dropbox.com/u/96609235/mainfile.txt

(I know this might not be the most efficient way to make a text adventure, so I don't really want a lesson in the layout) (我知道这可能不是进行文字冒险的最有效方法,所以我真的不想在版式上上课)

Steal his ;-) 偷他的;-)

Or if you want to make your own you basically just: 或者,如果您想制作自己的东西,基本上就是:

  1. An input with width="100%"; 输入的宽度为=“ 100%”; this will be the "bar-input" 这将是“栏输入”
  2. Attach a keypress event handler to that input, and listen for any enter key-presses that happen 将keypress事件处理程序附加到该输入,并监听发生的所有enter按键
  3. When that event fires, have your handler ... handle it (move the user in to the next room or whatever) 当该事件触发时,请您的处理程序...处理(将用户移至下一个房间或其他任何地方)
  4. Whenever you write more text out to the user, re-position the input (depending on the HTML/CSS you use, this might happen automatically). 每当您向用户写出更多文本时,请重新定位输入(取决于您使用的HTML / CSS,这可能会自动发生)。

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

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