htmlローカルストレージにゲームをプレイするときにプレーヤーが取得するスコアを追加しますか? どうすればこのことをやりますか? さらに、誰にもあまり問題にならないなら、どうすれば地元の店舗からスコアを取得してランキング表の中に入れることができますか?コードのほとんど はちょうど私が見カントいくつかのことは、私はあなたが書いたゲームを見たとき、私は本当に感動しました、プレーヤーのスコアをローカルストレージに送信するにはどうすればよいですか?
https://jsfiddle.net/gugui3z24/ab4gaf15/2/
/* This function is called when a logged in user
plays the game and gets a score */
function updateScore(newScore) {
//Get the JavaScript object that holds the data for the logged in user
var usrObj = JSON.parse(localStorage[localStorage.loggedInUser]);
//Update the user object with the new top score
/* NOTE YOU NEED TO CHANGE THIS CODE TO CHECK TO SEE IF THE NEW SCORE
IS GREATER THAN THE OLD SCORE */
usrObj.topscore = newScore;
//Put the user data back into local storage.
localStorage[localStorage.loggedInUser] = JSON.stringify(usrObj);
}
/* Loads the rankings table.
This function should be called when the page containing the rankings table loads */
function showRankingsTable() {
//Get a reference to the div that will hold the rankings table.
var rankingDiv = document.getElementById("RankingsTable");
//Create a variable that will hold the HTML for the rankings table
var htmlStr = "";
//Add a heading
htmlStr += "<h1>Rankings Table</h1>";
//Add the table tag
htmlStr += "<table>";
//Work through all of the keys in local storage
for (var key in localStorage) {
//All of the keys should point to user data except loggedInUser
if (key !== "loggedInUser") {
//Extract object containing user data
//Extract user name and top score
htmlStr += "David";
//Add a table row to the HTML string.
}
}
//Finish off the table
htmlStr += "</table>";
あなたは何を理解していませんか? – SLaks
ユーザーがlocalstorageに得たスコアを送信する方法、次にlocalstorageからスコアを取得し、他のユーザーの得点が表示されている場所にランキングを入力してください –