Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为我的android应用程序游戏创建分数计数器和排行榜的最简单方法是什么?_Javascript_Android_Leaderboard - Fatal编程技术网

Javascript 为我的android应用程序游戏创建分数计数器和排行榜的最简单方法是什么?

Javascript 为我的android应用程序游戏创建分数计数器和排行榜的最简单方法是什么?,javascript,android,leaderboard,Javascript,Android,Leaderboard,我会尽量让大家理解,我的应用程序是用基于云的应用程序制造商设计和开发的,是一款多选体育游戏。HTML、CSS和JavaScript的布局和按钮已经完成,但我想添加最后的润色 我有一个基本代码,当用户点击正确的按钮时,分数会增加,我想。。。。我只需要改变它,让它在我的游戏中发挥作用 <div id="output">0</div> $('#target1').click(function(){ $('#output').html(function(i, val){ retu

我会尽量让大家理解,我的应用程序是用基于云的应用程序制造商设计和开发的,是一款多选体育游戏。HTML、CSS和JavaScript的布局和按钮已经完成,但我想添加最后的润色

我有一个基本代码,当用户点击正确的按钮时,分数会增加,我想。。。。我只需要改变它,让它在我的游戏中发挥作用

<div id="output">0</div>
$('#target1').click(function(){
$('#output').html(function(i, val){
return val * 1 + 1 });
});
但首先,我被困在如何将问题1的分数转移到所有其他问题上,这样分数就会增加/减少,然后我不知道如何在游戏结束后创建一个简单的排行榜。我的最后一个问题是如何正确地放置代码。最简单或最简单的方法将不胜感激,感谢您花时间阅读本文

TIGZI的HTML代码是这样的

<head>
<script type="text/javascript" src="res/lib/detectmobilebrowser.js">
</script>
<script type="text/javascript">
var screen_mobile = true;
var screen_width = 320;
var screen_height = 480;
var browser_mobile = is_mobile_browser();
if (screen_mobile && !browser_mobile && top == window)
{
top.location.href = './mob-screen-B626.html';
}
</script>
<title>
Question 1
</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta names="apple-mobile-web-app-status-bar-style" content="black-translucent"
/>
<link type="text/css" href="res/lib/jquerymobile/1.0/jquery.mobile-1.0.css"    rel="stylesheet"
/>
<link type="text/css" href="files/views/assets/asset-1312828" rel="stylesheet" />
<script type="text/javascript" src="res/lib/store/json2.js">
</script>
<script type="text/javascript" src="res/lib/jquery/jquery-1.6.4.js">
</script>
<script type="text/javascript" src="res/lib/jquerymobile/jquery.mobile.iepatch.js">
</script>
<script type="text/javascript" src="res/lib/jquerymobile/1.0/jquery.mobile-1.0.js">
</script>
<script type="text/javascript" src="res/lib/mobilebase.js">
</script>
<script type="text/javascript" src="res/lib/store/jstore.js">
</script>
<script type="text/javascript" src="res/lib/event/customEventHandler.js">
</script>
<script type="text/javascript" src="res/lib/base/sha1.js">
</script>
<script type="text/javascript" src="res/lib/base/oauth.js">
</script>
<script type="text/javascript" src="res/lib/base/contexts.js">
</script>
<script type="text/javascript" src="res/lib/base/jsonpath.js">
</script>
<script type="text/javascript" src="res/lib/base/jquery.xml2json.min.js">
</script>
<script type="text/javascript" src="res/lib/base/api.js">
</script>
<script type="text/javascript" src="res/lib/base/impl.js">
</script>
<script type="text/javascript" src="res/lib/phonegap.js">
</script>
<script type="text/javascript" src="res/lib/childbrowser.js">
</script>
<script type="text/javascript" src="res/lib/barcodescanner.js">
</script>
<link href="res/css/mobilebase.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script language="JavaScript" type="text/javascript">
if (navigator.userAgent.match(/iP/i))
{
$(window).bind('orientationchange', function(event)
{
$('meta[name="viewport"]').attr('content', 'initial-scale=1.0,maximum-scale=1.0, ' +    ((window.orientation == 90 || window.orientation == -90 || window.orientation == 270) ? "height=device-width,width=device-height" : "height=device-height,width=device-width"));
}).trigger('orientationchange');
}
    </script>
    <div data-role="page" style="min-height:480px;" id="j_38" class="type-interior">
        <div data-role="header" data-position="fixed" data-theme='a' data-add-back-btn="false"
        name="mobileheader2" id="j_40" class='mobileheader4'>
            <h1 dsid="mobileheader2">
                Question 1
            </h1>
        </div>
        <div data-role="content" id="j_41" name="mobilecontainer2" class="mobilecontainer4"
        dsid="mobilecontainer2" data-theme='b'>
            <link href="screen-B626.css" rel="stylesheet" type="text/css" />
            <script type="text/javascript" src="screen-B626.js">
            </script>
            <div name="mobilelabel1" id="j_42" dsid="mobilelabel1" data-role="tiggr_label" class='mobilelabel3'>
                Who won the Barclays Premier League from 1993-1994?
            </div>
            <div class="mobilebutton7_wrapper ">
                <a data-role="button" name="BR" dsid="BR" class=' mobilebutton7' id='j_43' data-inline='false'
                data-theme='a' tabIndex="1">Blackburn Rovers</a>
            </div>
            <div class="mobilebutton8_wrapper ">
                <a data-role="button" name="AR" dsid="AR" class=' mobilebutton8' id='j_44' data-inline='false'
                data-theme='a' tabIndex="2">Arsenal</a>
            </div>
            <div class="mobilebutton9_wrapper ">
                <a data-role="button" name="MU" dsid="MU" class=' mobilebutton9' id='j_45' data-inline='false'
                data-theme='a' tabIndex="3">Manchester Utd</a>
            </div>
            <div class="mobilebutton10_wrapper ">
                <a data-role="button" name="LI" dsid="LI" class=' mobilebutton10' id='j_46' data-inline='false'
                data-theme='a' tabIndex="4">Liverpool</a>
            </div>
            <div class="mobilebutton11_wrapper ">
                <a data-role="button" name="Home" dsid="Home" class=' mobilebutton11' id='j_47'
                data-icon='arrow-l' data-iconpos='left' data-inline='false' data-theme='a' tabIndex="5">Home</a>
            </div>
        </div>
    </div>
</body>
/*
* JS for Question 1  generated by Exadel Tiggzi
*
* Created on: Sunday, February 26, 2012, 02:05:40 PM (PST)
*/
/************************************
* JS API provided by Exadel Tiggzi  *
************************************/
/* Setting project environment indicator */
Tiggr.env = "apk"; /* Object & array with components "name-to-id" mapping */
var n2id_buf = {
'mobilecontentlayer6': 'j_13',
'mobileheader6': 'j_14',
'mobilecontainer6': 'j_15',
'mobilelabel3': 'j_16',
'mobilefooter6': 'j_17',
'annotationslayer6': 'j_18',
'mobilelabel1': 'j_42',
'BR': 'j_43',
'AR': 'j_44',
'MU': 'j_45',
'LI': 'j_46',
'Home': 'j_47'
};
if ("n2id" in window && n2id != undefined) {
$.extend(n2id, n2id_buf);
} else {
var n2id = n2id_buf;
}

function pageItem(pageName, pageLocation) {
this.name = pageName;
this.location = pageLocation;
}
Tiggr.AppPages = [
new pageItem('Question 5 ', 'screen-D8D7.html'), new pageItem('Incorrect!!!', 'screen-    B60E.html'), new pageItem('News', 'screen-5FA9.html'), new pageItem('T&C', 'screen-A553.html'), new pageItem('Question 1 ', 'screen-B626.html'), new pageItem('Question 4 ', 'screen-5661.html'), new pageItem('Question 3 ', 'screen-BFDF.html'), new pageItem('Home', 'screen-1865.html'), new pageItem('Question 2 ', 'screen-4717.html'), new pageItem('current', 'screen-B626.html')];

function navigateTo(outcome, useAjax) {
Tiggr.navigateTo(outcome, useAjax);
}

function adjustContentHeight() {
Tiggr.adjustContentHeight();
}

function adjustContentHeightWithPadding() {
Tiggr.adjustContentHeightWithPadding();
}

function unwrapAndApply(selector, content) {
Tiggr.unwrapAndApply(selector, content);
}

function setDetailContent(pageUrl) {
Tiggr.setDetailContent(pageUrl);
}
/*********************
* GENERIC SERVICES  *
*********************/
/*************************
* NONVISUAL COMPONENTS  *
*************************/
var datasources = [];
/************************
* EVENTS AND HANDLERS  *
************************/
// screen onload
screen_B626_onLoad = j_38_onLoad = function() {
createSpinner("res/lib/jquerymobile/images/ajax-loader.gif");
Tiggr.__registerComponent('mobilecontentlayer6', new Tiggr.BaseComponent({
    id: 'mobilecontentlayer6'
}));
Tiggr.__registerComponent('mobileheader6', new Tiggr.BaseComponent({
    id: 'mobileheader6'
}));
Tiggr.__registerComponent('mobilecontainer6', new Tiggr.BaseComponent({
    id: 'mobilecontainer6'
}));
Tiggr.__registerComponent('mobilelabel3', new Tiggr.BaseComponent({
    id: 'mobilelabel3'
}));
Tiggr.__registerComponent('mobilefooter6', new Tiggr.BaseComponent({
    id: 'mobilefooter6'
}));
Tiggr.__registerComponent('annotationslayer6', new Tiggr.BaseComponent({
    id: 'annotationslayer6'
}));
Tiggr.__registerComponent('mobilelabel1', new Tiggr.BaseComponent({
    id: 'mobilelabel1'
}));
Tiggr.__registerComponent('BR', new Tiggr.BaseComponent({
    id: 'BR'
}));
Tiggr.__registerComponent('AR', new Tiggr.BaseComponent({
    id: 'AR'
}));
Tiggr.__registerComponent('MU', new Tiggr.BaseComponent({
    id: 'MU'
}));
Tiggr.__registerComponent('LI', new Tiggr.BaseComponent({
    id: 'LI'
}));
Tiggr.__registerComponent('Home', new Tiggr.BaseComponent({
    id: 'Home'
}));
for (var idx = 0; idx < datasources.length; idx++) {
    datasources[idx].__setupDisplay();
}
adjustContentHeightWithPadding();
j_38_deviceEvents();
j_38_windowEvents();
screen_B626_elementsExtraJS();
screen_B626_elementsEvents();
}
// screen window events
screen_B626_windowEvents = j_38_windowEvents = function() {}
// device events
j_38_deviceEvents = function() {
document.addEventListener("deviceready", function() {
adjustContentHeightWithPadding();
});
}
// screen elements extra js
screen_B626_elementsExtraJS = j_38_elementsExtraJS = function() {
// screen (screen-B626) extra code
}
// screen elements handler
screen_B626_elementsEvents = j_38_elementsEvents = function() {
$("a :input,a a,a fieldset label").live({
click: function(event) {
event.stopPropagation();
}
});
$('[name="BR"]').die().live({
vclick: function() {
if (!$(this).attr('disabled')) {
Tiggr.navigateTo('Incorrect!!!', {
transition: 'pop'
});
}
},
});
$('[name="AR"]').die().live({
vclick: function() {
if (!$(this).attr('disabled')) {
Tiggr.navigateTo('Incorrect!!!', {
transition: 'pop'
});
}
},
});
$('[name="MU"]').die().live({
vclick: function() {
if (!$(this).attr('disabled')) {
Tiggr.navigateTo('Question 2 ', {
transition: 'slide',
reverse: false
});
}
},
});
$('[name="LI"]').die().live({
vclick: function() {
if (!$(this).attr('disabled')) {
Tiggr.navigateTo('Incorrect!!!', {
transition: 'pop'
});
}
},
});
$('[name="Home"]').die().live({
vclick: function() {
if (!$(this).attr('disabled')) {
Tiggr.navigateTo('Home', {
transition: 'slide',
reverse: false
});
}
},
});
}
$("body").undelegate("pagebeforeshow").delegate("#j_38", "pagebeforeshow",      function(event, ui) {
j_38_onLoad();
}); 
JavaScript代码是这样的

<head>
<script type="text/javascript" src="res/lib/detectmobilebrowser.js">
</script>
<script type="text/javascript">
var screen_mobile = true;
var screen_width = 320;
var screen_height = 480;
var browser_mobile = is_mobile_browser();
if (screen_mobile && !browser_mobile && top == window)
{
top.location.href = './mob-screen-B626.html';
}
</script>
<title>
Question 1
</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta names="apple-mobile-web-app-status-bar-style" content="black-translucent"
/>
<link type="text/css" href="res/lib/jquerymobile/1.0/jquery.mobile-1.0.css"    rel="stylesheet"
/>
<link type="text/css" href="files/views/assets/asset-1312828" rel="stylesheet" />
<script type="text/javascript" src="res/lib/store/json2.js">
</script>
<script type="text/javascript" src="res/lib/jquery/jquery-1.6.4.js">
</script>
<script type="text/javascript" src="res/lib/jquerymobile/jquery.mobile.iepatch.js">
</script>
<script type="text/javascript" src="res/lib/jquerymobile/1.0/jquery.mobile-1.0.js">
</script>
<script type="text/javascript" src="res/lib/mobilebase.js">
</script>
<script type="text/javascript" src="res/lib/store/jstore.js">
</script>
<script type="text/javascript" src="res/lib/event/customEventHandler.js">
</script>
<script type="text/javascript" src="res/lib/base/sha1.js">
</script>
<script type="text/javascript" src="res/lib/base/oauth.js">
</script>
<script type="text/javascript" src="res/lib/base/contexts.js">
</script>
<script type="text/javascript" src="res/lib/base/jsonpath.js">
</script>
<script type="text/javascript" src="res/lib/base/jquery.xml2json.min.js">
</script>
<script type="text/javascript" src="res/lib/base/api.js">
</script>
<script type="text/javascript" src="res/lib/base/impl.js">
</script>
<script type="text/javascript" src="res/lib/phonegap.js">
</script>
<script type="text/javascript" src="res/lib/childbrowser.js">
</script>
<script type="text/javascript" src="res/lib/barcodescanner.js">
</script>
<link href="res/css/mobilebase.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script language="JavaScript" type="text/javascript">
if (navigator.userAgent.match(/iP/i))
{
$(window).bind('orientationchange', function(event)
{
$('meta[name="viewport"]').attr('content', 'initial-scale=1.0,maximum-scale=1.0, ' +    ((window.orientation == 90 || window.orientation == -90 || window.orientation == 270) ? "height=device-width,width=device-height" : "height=device-height,width=device-width"));
}).trigger('orientationchange');
}
    </script>
    <div data-role="page" style="min-height:480px;" id="j_38" class="type-interior">
        <div data-role="header" data-position="fixed" data-theme='a' data-add-back-btn="false"
        name="mobileheader2" id="j_40" class='mobileheader4'>
            <h1 dsid="mobileheader2">
                Question 1
            </h1>
        </div>
        <div data-role="content" id="j_41" name="mobilecontainer2" class="mobilecontainer4"
        dsid="mobilecontainer2" data-theme='b'>
            <link href="screen-B626.css" rel="stylesheet" type="text/css" />
            <script type="text/javascript" src="screen-B626.js">
            </script>
            <div name="mobilelabel1" id="j_42" dsid="mobilelabel1" data-role="tiggr_label" class='mobilelabel3'>
                Who won the Barclays Premier League from 1993-1994?
            </div>
            <div class="mobilebutton7_wrapper ">
                <a data-role="button" name="BR" dsid="BR" class=' mobilebutton7' id='j_43' data-inline='false'
                data-theme='a' tabIndex="1">Blackburn Rovers</a>
            </div>
            <div class="mobilebutton8_wrapper ">
                <a data-role="button" name="AR" dsid="AR" class=' mobilebutton8' id='j_44' data-inline='false'
                data-theme='a' tabIndex="2">Arsenal</a>
            </div>
            <div class="mobilebutton9_wrapper ">
                <a data-role="button" name="MU" dsid="MU" class=' mobilebutton9' id='j_45' data-inline='false'
                data-theme='a' tabIndex="3">Manchester Utd</a>
            </div>
            <div class="mobilebutton10_wrapper ">
                <a data-role="button" name="LI" dsid="LI" class=' mobilebutton10' id='j_46' data-inline='false'
                data-theme='a' tabIndex="4">Liverpool</a>
            </div>
            <div class="mobilebutton11_wrapper ">
                <a data-role="button" name="Home" dsid="Home" class=' mobilebutton11' id='j_47'
                data-icon='arrow-l' data-iconpos='left' data-inline='false' data-theme='a' tabIndex="5">Home</a>
            </div>
        </div>
    </div>
</body>
/*
* JS for Question 1  generated by Exadel Tiggzi
*
* Created on: Sunday, February 26, 2012, 02:05:40 PM (PST)
*/
/************************************
* JS API provided by Exadel Tiggzi  *
************************************/
/* Setting project environment indicator */
Tiggr.env = "apk"; /* Object & array with components "name-to-id" mapping */
var n2id_buf = {
'mobilecontentlayer6': 'j_13',
'mobileheader6': 'j_14',
'mobilecontainer6': 'j_15',
'mobilelabel3': 'j_16',
'mobilefooter6': 'j_17',
'annotationslayer6': 'j_18',
'mobilelabel1': 'j_42',
'BR': 'j_43',
'AR': 'j_44',
'MU': 'j_45',
'LI': 'j_46',
'Home': 'j_47'
};
if ("n2id" in window && n2id != undefined) {
$.extend(n2id, n2id_buf);
} else {
var n2id = n2id_buf;
}

function pageItem(pageName, pageLocation) {
this.name = pageName;
this.location = pageLocation;
}
Tiggr.AppPages = [
new pageItem('Question 5 ', 'screen-D8D7.html'), new pageItem('Incorrect!!!', 'screen-    B60E.html'), new pageItem('News', 'screen-5FA9.html'), new pageItem('T&C', 'screen-A553.html'), new pageItem('Question 1 ', 'screen-B626.html'), new pageItem('Question 4 ', 'screen-5661.html'), new pageItem('Question 3 ', 'screen-BFDF.html'), new pageItem('Home', 'screen-1865.html'), new pageItem('Question 2 ', 'screen-4717.html'), new pageItem('current', 'screen-B626.html')];

function navigateTo(outcome, useAjax) {
Tiggr.navigateTo(outcome, useAjax);
}

function adjustContentHeight() {
Tiggr.adjustContentHeight();
}

function adjustContentHeightWithPadding() {
Tiggr.adjustContentHeightWithPadding();
}

function unwrapAndApply(selector, content) {
Tiggr.unwrapAndApply(selector, content);
}

function setDetailContent(pageUrl) {
Tiggr.setDetailContent(pageUrl);
}
/*********************
* GENERIC SERVICES  *
*********************/
/*************************
* NONVISUAL COMPONENTS  *
*************************/
var datasources = [];
/************************
* EVENTS AND HANDLERS  *
************************/
// screen onload
screen_B626_onLoad = j_38_onLoad = function() {
createSpinner("res/lib/jquerymobile/images/ajax-loader.gif");
Tiggr.__registerComponent('mobilecontentlayer6', new Tiggr.BaseComponent({
    id: 'mobilecontentlayer6'
}));
Tiggr.__registerComponent('mobileheader6', new Tiggr.BaseComponent({
    id: 'mobileheader6'
}));
Tiggr.__registerComponent('mobilecontainer6', new Tiggr.BaseComponent({
    id: 'mobilecontainer6'
}));
Tiggr.__registerComponent('mobilelabel3', new Tiggr.BaseComponent({
    id: 'mobilelabel3'
}));
Tiggr.__registerComponent('mobilefooter6', new Tiggr.BaseComponent({
    id: 'mobilefooter6'
}));
Tiggr.__registerComponent('annotationslayer6', new Tiggr.BaseComponent({
    id: 'annotationslayer6'
}));
Tiggr.__registerComponent('mobilelabel1', new Tiggr.BaseComponent({
    id: 'mobilelabel1'
}));
Tiggr.__registerComponent('BR', new Tiggr.BaseComponent({
    id: 'BR'
}));
Tiggr.__registerComponent('AR', new Tiggr.BaseComponent({
    id: 'AR'
}));
Tiggr.__registerComponent('MU', new Tiggr.BaseComponent({
    id: 'MU'
}));
Tiggr.__registerComponent('LI', new Tiggr.BaseComponent({
    id: 'LI'
}));
Tiggr.__registerComponent('Home', new Tiggr.BaseComponent({
    id: 'Home'
}));
for (var idx = 0; idx < datasources.length; idx++) {
    datasources[idx].__setupDisplay();
}
adjustContentHeightWithPadding();
j_38_deviceEvents();
j_38_windowEvents();
screen_B626_elementsExtraJS();
screen_B626_elementsEvents();
}
// screen window events
screen_B626_windowEvents = j_38_windowEvents = function() {}
// device events
j_38_deviceEvents = function() {
document.addEventListener("deviceready", function() {
adjustContentHeightWithPadding();
});
}
// screen elements extra js
screen_B626_elementsExtraJS = j_38_elementsExtraJS = function() {
// screen (screen-B626) extra code
}
// screen elements handler
screen_B626_elementsEvents = j_38_elementsEvents = function() {
$("a :input,a a,a fieldset label").live({
click: function(event) {
event.stopPropagation();
}
});
$('[name="BR"]').die().live({
vclick: function() {
if (!$(this).attr('disabled')) {
Tiggr.navigateTo('Incorrect!!!', {
transition: 'pop'
});
}
},
});
$('[name="AR"]').die().live({
vclick: function() {
if (!$(this).attr('disabled')) {
Tiggr.navigateTo('Incorrect!!!', {
transition: 'pop'
});
}
},
});
$('[name="MU"]').die().live({
vclick: function() {
if (!$(this).attr('disabled')) {
Tiggr.navigateTo('Question 2 ', {
transition: 'slide',
reverse: false
});
}
},
});
$('[name="LI"]').die().live({
vclick: function() {
if (!$(this).attr('disabled')) {
Tiggr.navigateTo('Incorrect!!!', {
transition: 'pop'
});
}
},
});
$('[name="Home"]').die().live({
vclick: function() {
if (!$(this).attr('disabled')) {
Tiggr.navigateTo('Home', {
transition: 'slide',
reverse: false
});
}
},
});
}
$("body").undelegate("pagebeforeshow").delegate("#j_38", "pagebeforeshow",      function(event, ui) {
j_38_onLoad();
}); 

非常感谢您的回复,我已经尽了最大努力搜索和测试了这个计分器和领导板,但我发现很难得到结果或任何基本的东西

与OpenFeint集成怎么样?谢谢,我会看一看,我想我可能也必须尝试查看SQlit。如果您只想存储特定用户的高分,SQLite将是一个更好的选择。如果您想在所有用户之间交换、比较和匹配高分,那么我宁愿选择OpenFeint。