[英]Javascript High Score Table
我目前不確定該如何做這件事。
我有一個高分表,該表當前顯示游戲中每個個人跑步的得分,最高為10分。
我現在需要做的就是勾勒為該高分附加名稱的功能,這將在您獲得高分后完成。
有什么想法嗎?
我當前的設置如下:
highscoreList
是一個數組,其中包含10個highscoreLine
數組。
highscoreLine
是一個數組,其中包含要繪制的7個數字,以作為高分表本身的直觀表示。
highScores
是一個包含高分本身的數組。
這是實際繪制數字的循環。
for (var h = 0; h < highscoreList.length; ++h)
{
for (var i = 0; i < highscoreList[h].length; ++i)
{
highscoreList[h][i].frameList = highscoreDigits[getDigit(highScores[h], i)].frameList;
highscoreList[h][i].inbetweensList = highscoreDigits[getDigit(highScores[h], i)].inbetweensList;
}
}
您可以將highscoreList設置為對象數組: {name:highscore_name, highscoreLine:array}
如果要按某種值對數組排序,請參見以下示例:
var highscoreList=[
{score:2, name:'John', highscoreLine:[3,1,4,5,4,3,2]},
{score:5, name:'John B', highscoreLine:[3,1,4,5,2,3,3]},
{score:10, name:'John C', highscoreLine:[3,1,4,5,7,6,8]},
{score:4, name:'John', highscoreLine:[3,1,4,5,9,8,7]}
];
highscoreList.sort(function(a,b){return a.score < b.score});
console.log(highscoreList)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.