开发者

How do I save scores in my game using cookies?

开发者 https://www.devze.com 2023-04-09 20:44 出处:网络
I am currently making an Jeopardy game on the topic of开发者_StackOverflow社区 HTML using jQuery. Right now it works well, but I want to add a recent saved scores tag using cookies. I don\'t know how

I am currently making an Jeopardy game on the topic of开发者_StackOverflow社区 HTML using jQuery. Right now it works well, but I want to add a recent saved scores tag using cookies. I don't know how to achieve this.

I know cookies but I don't know how I will get the name and score and then save it.

I want to do something like this:

Recent Saved Scores

{NAME HERE}....{Score HERE}

{NAME HERE}....{Score HERE}

{NAME HERE}....{Score HERE}

And it's supposed to save.

Here's a link to my game: http://redirectme.yolasite.com/resources/jeopardy.html


I would suggest to use something like jstorage It uses localStorage or cookies if localStorage is not available.


Assuming that you know how to get/set cookie with javascript, just use json to encode the array of recent scores.

NOTE. cookies will register only results for the particular computer. if you need highscore chart, then you need some kind of backend e.g. php for storing and retrieving results.

let me know if you need any further guidance.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号