我有以下陣列:迭代通過陣列3項
var text = [
"RISE AND SHINE, JONATHON! HMM, ",
"THAT'S A MOUTHFUL, HOW ABOUT ",
"I JUST CALL YOU JOHN? MY ",
"NAME IS PROFESSOR ",
"PHIL. I BUILT YOU FROM ",
"SCRATCH. I WANT TO TELL YOU ",
"A LITTLE STORY BEFORE WE START."
];
我再通過數組循環:
for (var i = 0; i < 3; i++) {
this.font.draw(text[i]);
}
這顯然輸出:
RISE AND SHINE, JONATHON! HMM,
THAT'S A MOUTHFUL, HOW ABOUT
I JUST CALL YOU JOHN? MY
我需要什麼與被創建將通過接下來的3行重複,以然後顯示一個功能有所幫助:
NAME IS PROFESSOR
PHIL. I BUILT YOU FROM
SCRATCH. I WANT TO TELL YOU
..和等等。
這是用於聊天氣泡代碼,我正在寫一個JavaScript/HTML5遊戲,其中我的聊天對話在任何給定時間只能容納3行文本。
一旦對話已達成的最後一句話。我希望它從一開始就繼續下去。
你能給我們演示嗎? –
我不清楚。如果有12行,該怎麼辦?該程序然後做什麼 – polin
「迭代通過接下來的3行」...什麼時候?立即? 'X'發生後?更多的信息會有幫助... –