[英]Jackpot game is not returning result text
背景信息:
創建了頭獎游戲,並且在每輪結束時-將顯示贏或輸的文本
已經做了什么:
創建了一個switch語句來檢查每個插槽的元素。 創建了一個條件檢查語句來檢查所有3個插槽是否相同-會贏,否則會輸
問題:
在每次旋轉結束時-沒有贏或輸的更新文本:
碼:
var BLURB_TBL = [
'JACKPOT!'
];
switch (this.state) {
case 1: // all slots spinning
if (now - this.lastUpdate > RUNTIME) {
this.state = 2;
this.lastUpdate = now;
}
break;
case 2: // slot 1
this.stopped1 = _check_slot( this.offset1, this.result1 );
if ( this.stopped1 ) {
this.speed1 = 0;
this.state++;
this.lastUpdate = now;
}
break;
case 3: // slot 1 stopped, slot 2
this.stopped2 = _check_slot( this.offset2, this.result2 );
if ( this.stopped2 ) {
this.speed2 = 0;
this.state++;
this.lastUpdate = now;
}
break;
case 4: // slot 2 stopped, slot 3
this.stopped3 = _check_slot( this.offset3, this.result3 );
if ( this.stopped3 ) {
this.speed3 = 0;
this.state++;
}
break;
case 5: // slots stopped
if ( now - this.lastUpdate > 3000 ) {
this.state = 6;
}
break;
case 6: // check results
if ((that.items1[that.result1].id == 'gold-64' && that.items2[that.result2].id == 'gold-64' && that.items3[that.result3].id == 'gold-64') || (that.items1[that.result1].id == 'cash-64' && that.items2[that.result2].id == 'cash-64' && that.items3[that.result3].id == 'cash-64') || (that.items1[that.result1].id == 'energy-64' && that.items2[that.result2].id == 'energy-64' && that.items3[that.result3].id == 'energy-64') || (that.items1[that.result1].id == 'staff-64' && that.items2[that.result2].id == 'staff-64' && that.items3[that.result3].id == 'staff-64') || (that.items1[that.result1].id == 'build-64' && that.items2[that.result2].id == 'build-64' && that.items3[that.result3].id == 'build-64') || (that.items1[that.result1].id == 'goods-64' && that.items2[that.result2].id == 'goods-64' && that.items3[that.result3].id == 'goods-64')){
$('#status').text(BLURB_TBL);
}else {
$('#status').text("GOOD TRY!!");
}
this.state = 7;
break;
case 7: // game ends
break;
default:
}
this.lastupdate = now;
您缺少返回函數。
對於此示例:
function a() {
alert('A');
}
//alerts 'A', returns undefined
function b() {
alert('B');
return a;
}
//alerts 'B', returns function a
function c() {
alert('C');
return a();
}
//alerts 'C', alerts 'A', returns undefined
alert("Function 'a' returns " + a());
alert("Function 'b' returns " + b());
alert("Function 'c' returns " + c());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.