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

时间:2012-03-28 01:27:49

标签: javascript android leaderboard

我会尝试尽可能地理解这一点,我的应用程序是使用基于云的应用程序制造商设计和开发的,是一款多选体育游戏。 HTML,CSS和JavaScript布局和按钮已完成,但我想添加最后润色。

我有基本代码,当用户点击正确的按钮时,我认为分数会增加....(我只需要更改它,以便它在我的游戏中运行。)

<div id="output">0</div>
$('#target1').click(function(){
$('#output').html(function(i, val){
return val * 1 + 1 });
});

我知道它的错误......

$('#target2').click(function(){
$('#output').html(function(i, val){
return val * 1 - 1 });
});

但首先我坚持如何将问题1中的分数转移到所有其他问题,以便增加/减少然后我不确定如何在游戏结束后创建简单的排行榜。我的最后一个问题是如何正确放置代码。非常感谢最简单或最简单的方式,感谢您花时间阅读本文。

Tiggzi 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>

JavaScript代码就是这个......

/*
* 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();
}); 

非常感谢,如果你要回复,我已经尝试过我最好的搜索和测试,以获得这个得分计数器和排行榜,但我发现很难得到结果或任何基本的。

0 个答案:

没有答案