0
#branchID pool
branch0 = "This is a wall of text. This is a wall of text. This is a wall of text. This is a wall of text. This is a wall of text. This is a wall of text."
branch1 = "This is a second wall of text."
branch2 = "This is a third wall of text."
#classes section
#pulls text from pools above.
branch = (name, branchid)->
stringID = String(branchid)
document.write("<h1 id=\'#{stringID}\'>#{name}</h1>")
document.getElementById(stringID).onclick = ->
document.write(branchid)
#This is where the game goes. It will be built with conditionals
window.onload = ->
branch('Start', branch0)
我使用CoffeeScript创建基于浏览器的“选择您自己的冒险游戏”。以上是我迄今为止的代码。它创建一个HTML元素,并在单击时,一个文本字符串被写入一个巨块中的页面。一次单击一次显示句子中的大字符串
我的问题是,我怎么能这样做,所以一次只加载一个句子,然后单击时,下一句加载,然后下一句,直到字符串中没有其他任何内容?
非常感谢你。这非常有帮助。 – bryanwillis7