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