当尝试运行TheFlop()并从Shuffle数组添加子画面时,由于未定义子画面而不会加载。为什么改组后未定义
我试图循环播放该功能并将其放在其他功能的前面和后面,但是没有一个起作用。
按开始按钮时首先运行随机播放功能,在尝试时我也总是这样做。它无法读取精灵并加载图像
<!DOCTYPE html>
<html lang="en">
<!--
Functions:
- The flop (Dealer reveals three community cards)
- The turn (Dealer reveals the forth community card)
- The river (Dealer reveals the fifth community card)
-->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="//cdn.jsdelivr.net/npm/phaser@3.16.2/dist/phaser.js"></script>
<title>Hihi</title>
</head>
<body>
<script type="text/javascript">
var config = {
type: Phaser.WEBGL,
parent: 'phaser-example',
width: 1910,
height: 870,
scene: {
preload: preload,
create: create,
update: update
}
};
var game = new Phaser.Game(config);;
var rndNum = 0;
var deck = [];
var shuffle = [];
var statusChoice = [];
let players = [1, 2, 3, 4];
let playerCash = [500, 500, 500, 500];
let round = [];
var currentTableValue = 0;
var pot = 0;
function preload() {
this.load.image('background', 'assets/general/background.png');
this.load.image('2S', 'assets/cards/2S.png');
this.load.image('2C', 'assets/cards/2C.png');
this.load.image('2H', 'assets/cards/2H.png');
this.load.image('2D', 'assets/cards/2D.png');
this.load.image('3S', 'assets/cards/3S.png');
this.load.image('3C', 'assets/cards/3C.png');
this.load.image('3H', 'assets/cards/3H.png');
this.load.image('3D', 'assets/cards/3D.png');
this.load.image('4S', 'assets/cards/4S.png');
this.load.image('4C', 'assets/cards/4C.png');
this.load.image('4H', 'assets/cards/4H.png');
this.load.image('4D', 'assets/cards/4D.png');
this.load.image('5S', 'assets/cards/5S.png');
this.load.image('5C', 'assets/cards/5C.png');
this.load.image('5H', 'assets/cards/5H.png');
this.load.image('5D', 'assets/cards/5D.png');
this.load.image('6S', 'assets/cards/6S.png');
this.load.image('6C', 'assets/cards/6C.png');
this.load.image('6H', 'assets/cards/6H.png');
this.load.image('6D', 'assets/cards/6D.png');
this.load.image('7S', 'assets/cards/7S.png');
this.load.image('7C', 'assets/cards/7C.png');
this.load.image('7H', 'assets/cards/7H.png');
this.load.image('7D', 'assets/cards/7D.png');
this.load.image('8S', 'assets/cards/8S.png');
this.load.image('8C', 'assets/cards/8C.png');
this.load.image('8H', 'assets/cards/8H.png');
this.load.image('8D', 'assets/cards/8D.png');
this.load.image('9S', 'assets/cards/9S.png');
this.load.image('9C', 'assets/cards/9C.png');
this.load.image('9H', 'assets/cards/9H.png');
this.load.image('9D', 'assets/cards/9D.png');
this.load.image('10S', 'assets/cards/10S.png');
this.load.image('10C', 'assets/cards/10C.png');
this.load.image('10H', 'assets/cards/10H.png');
this.load.image('10D', 'assets/cards/10D.png');
this.load.image('JS', 'assets/cards/JS.png');
this.load.image('JC', 'assets/cards/JC.png');
this.load.image('JH', 'assets/cards/JH.png');
this.load.image('JD', 'assets/cards/JD.png');
this.load.image('QS', 'assets/cards/QS.png');
this.load.image('QC', 'assets/cards/QC.png');
this.load.image('QH', 'assets/cards/QH.png');
this.load.image('QD', 'assets/cards/QD.png');
this.load.image('KS', 'assets/cards/KS.png');
this.load.image('KC', 'assets/cards/KC.png');
this.load.image('KH', 'assets/cards/KH.png');
this.load.image('KD', 'assets/cards/KD.png');
this.load.image('AS', 'assets/cards/AS.png');
this.load.image('AC', 'assets/cards/AC.png');
this.load.image('AH', 'assets/cards/AH.png');
this.load.image('AD', 'assets/cards/AD.png');
this.load.image('call', 'assets/general/call.png');
this.load.image('check', 'assets/general/check.png');
this.load.image('fold', 'assets/general/fold.png');
this.load.image('raise', 'assets/general/raise.png');
this.load.image('start', 'assets/general/start.png');
}
function create() {
var background = this.add.sprite(0, 0, 'background').setOrigin(0);
var btnCall = this.add.sprite(1050, 690, 'call').setInteractive();
var btnCheck = this.add.sprite(1110, 690, 'check').setInteractive();
var btnFold = this.add.sprite(1170, 690, 'fold').setInteractive();
var btnRaise = this.add.sprite(1230, 690, 'raise').setInteractive();
var btnStart = this.add.sprite(1290, 690, 'start').setInteractive();
//weekLoop = this.time.addEvent({ delay: 6000, callback: TheTurn, callbackScope: this });
//weekLoop = this.time.addEvent({ delay: 7000, callback: TheRiver, callbackScope: this });
//weekLoop = this.time.addEvent({ delay: 5000, callback: TheFlop, callbackScope: this });
p1igm = 1000;
p2igm = 1000;
p3igm = 1000;
p4igm = 1000;
txtp1igm = this.add.text(980, 750);
txtp2igm = this.add.text(120, 540);
txtp3igm = this.add.text(980, 30);
txtp4igm = this.add.text(1450, 540);
txtMainPlayer = this.add.text(980, 780);
txtp2n = this.add.text(120, 570);
txtPot = this.add.text(830, 540);
deck = ["2S", "2C", "2H", "2D", "3S", "3C", "3H", "3D", "4S", "4C", "4H", "4D",
"5S", "5C", "5H", "5D", "6S", "6C", "6H", "6D", "7S", "7C", "7H", "7D",
"8S", "8C", "8H", "8D", "9S", "9C", "9H", "9D", "10S", "10C", "10H", "10D",
"JS", "JC", "JH", "JD", "QS", "QC", "QH", "QD", "KS", "KC", "KH", "KD",
"AS", "AC", "AH", "AD"];
btnCall.on('pointerdown', function (pointer) {
Round('call');
}, this);
btnCheck.on('pointerdown', function (pointer) {
Round('check');
}, this);
btnFold.on('pointerdown', function (pointer) {
Round('fold');
}, this);
btnRaise.on('pointerdown', function (pointer) {
Round('raise');
}, this);
btnStart.on('pointerdown', function (pointer) {
ShuffleDeck();
}, this);
}
function update() {
txtp1igm.setText('Game Money: ' + '$' + p1igm)
txtp2igm.setText('Game Money: ' + '$' + p2igm)
txtp3igm.setText('Game Money: ' + '$' + p3igm)
txtp4igm.setText('Game Money: ' + '$' + p4igm)
txtMainPlayer.setText('You');
txtp2n.setText('Daniel');
txtPot.setText('Current Pot: ' + '$' + pot);
}
function ShuffleDeck() {
let i = 52;
while (i != 0) {
var rnd = Math.floor(Math.random() * i);
shuffle.splice(0, 0, deck[rnd]);
deck.splice(rnd, 1);
i--;
}
}
function DealCards() {
var player_one_C1 = this.add.sprite(750, 670, shuffle[1]).setInteractive().setOrigin(0).setScale(0.2, 0.2);
var player_one_C2 = this.add.sprite(860, 670, shuffle[2]).setInteractive().setOrigin(0).setScale(0.2, 0.2);
var player_two_C1 = this.add.sprite(120, 370, shuffle[3]).setInteractive().setOrigin(0).setScale(0.2, 0.2);
var player_two_C2 = this.add.sprite(230, 370, shuffle[4]).setInteractive().setOrigin(0).setScale(0.2, 0.2);
var player_three_C1 = this.add.sprite(750, 30, shuffle[5]).setInteractive().setOrigin(0).setScale(0.2, 0.2);
var player_three_C2 = this.add.sprite(860, 30, shuffle[6]).setInteractive().setOrigin(0).setScale(0.2, 0.2);
var player_four_C1 = this.add.sprite(1450, 370, shuffle[7]).setInteractive().setOrigin(0).setScale(0.2, 0.2);
var player_four_C2 = this.add.sprite(1560, 370, shuffle[8]).setInteractive().setOrigin(0).setScale(0.2, 0.2);
}
function TheFlop() {
var card1 = this.add.sprite(630, 370, shuffle[9]).setInteractive().setOrigin(0).setScale(0.2, 0.2);
var card2 = this.add.sprite(740, 370, shuffle[10]).setInteractive().setOrigin(0).setScale(0.2, 0.2);
var card3 = this.add.sprite(850, 370, shuffle[11]).setInteractive().setOrigin(0).setScale(0.2, 0.2);
}
function TheTurn() {
var card4 = this.add.sprite(960, 370, shuffle[12]).setInteractive().setOrigin(0).setScale(0.2, 0.2);
}
function TheRiver() {
var card5 = this.add.sprite(1070, 370, shuffle[13]).setInteractive().setOrigin(0).setScale(0.2, 0.2);
}
let i = 0;
let j = 0;
function Round(result) {
if (i == 4) {
i = 0;
}
else {
if (result == "raise") {
round = [];
round.push(result);
//test.innerHTML = round;
}
else {
if (round.length > 2) {
TheFlop();
round.push(result);
round = [];
//test.innerHTML = round;
j++;
}
else {
round.push(result);
}
}
i++;
}
}
function RndCards() {
return Math.floor(Math.random() * (5 - 1) + 1);
}
</script>
</body>
</html>