Commit 34df0cb5 authored by huangwenjie's avatar huangwenjie

1

parent 977c6ace
...@@ -90,6 +90,7 @@ export class PlayScene extends Scene { ...@@ -90,6 +90,7 @@ export class PlayScene extends Scene {
unlockGradeTxt: TextField unlockGradeTxt: TextField
initUI() { initUI() {
this.y = -(1624 - layers.stageHeight) / 2; this.y = -(1624 - layers.stageHeight) / 2;
...@@ -198,6 +199,19 @@ export class PlayScene extends Scene { ...@@ -198,6 +199,19 @@ export class PlayScene extends Scene {
} }
resetGame() {
for (let x = 0; x < 4; x++) {
for (let y = 0; y < 4; y++) {
this.board[x][y] = 0
}
}
this.generateOneElement()
this.generateOneElement()
this.renderBoard()
this.score = 0
}
createAniPool = [] createAniPool = []
createArr = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048] createArr = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
loadSvgas() { loadSvgas() {
...@@ -919,7 +933,7 @@ export class PlayScene extends Scene { ...@@ -919,7 +933,7 @@ export class PlayScene extends Scene {
// 随机生成基础元素 // 随机生成基础元素
generateOneElement() { generateOneElement() {
// 随机生成一个数字 2or4 // 随机生成一个数字 2or4
let randNumber = Math.random() < 0.9 ? 2 : 4 let randNumber = Math.random() < 0.5 ? 2 : 2048
// 随机生成位置 // 随机生成位置
let randNumberX = Math.floor(Math.random() * 4) let randNumberX = Math.floor(Math.random() * 4)
let randNumberY = Math.floor(Math.random() * 4) let randNumberY = Math.floor(Math.random() * 4)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment