Commit 1f50f558 authored by wjf's avatar wjf

Merge branch 'master' of gitlab2.dui88.com:MrKwon/game2048

parents 4043dbc1 f2dadebc
......@@ -1041,10 +1041,12 @@ export class PlayScene extends Scene {
currMoveType
combineCount: number = 0
addScore: number = 0
moveToLeft(type) {
let arr = [], tag = false
this.currMoveType = "left"
this.combineCount = 0
this.addScore = 0
for (let x = 0; x < 4; x++) {
arr[x] = new Array()
arr[x] = this.board[x]
......@@ -1054,6 +1056,20 @@ export class PlayScene extends Scene {
}
}
this.score += this.addScore
if (this.addScore > 0) {
this.scoreTips = this.drawTxt("+" + this.addScore, 250, 340, "#ffffff", 34)
this.scoreTips.alpha = 0
this.addChild(this.scoreTips)
Tween.get(this.scoreTips)
.to({ y: 300, alpha: 1 }, 200)
.wait(200)
.to({ y: 250, alpha: 0 }, 100)
.call(() => {
this.removeChild(this.scoreTips)
})
}
if (this.combineCount > 0) {
if (this.combineCount == 1) {
checkMusic("createEle", this.isPlayMusic)
......@@ -1072,6 +1088,7 @@ export class PlayScene extends Scene {
let arr = [], tag = false
this.currMoveType = "top"
this.combineCount = 0
this.addScore = 0
for (let y = 0; y < 4; y++) {
arr[y] = new Array()
for (let x = 0; x < 4; x++) {
......@@ -1084,6 +1101,20 @@ export class PlayScene extends Scene {
}
}
this.score += this.addScore
if (this.addScore > 0) {
this.scoreTips = this.drawTxt("+" + this.addScore, 250, 340, "#ffffff", 34)
this.scoreTips.alpha = 0
this.addChild(this.scoreTips)
Tween.get(this.scoreTips)
.to({ y: 300, alpha: 1 }, 200)
.wait(200)
.to({ y: 250, alpha: 0 }, 100)
.call(() => {
this.removeChild(this.scoreTips)
})
}
if (this.combineCount > 0) {
if (this.combineCount == 1) {
checkMusic("createEle", this.isPlayMusic)
......@@ -1109,6 +1140,7 @@ export class PlayScene extends Scene {
let arr = [], tag = false
this.currMoveType = "right"
this.combineCount = 0
this.addScore = 0
for (let x = 0; x < 4; x++) {
arr[x] = new Array()
// 数组反向传入处理函数
......@@ -1120,6 +1152,20 @@ export class PlayScene extends Scene {
if (type) this.updateArr(arr[x], x)
}
this.score += this.addScore
if (this.addScore > 0) {
this.scoreTips = this.drawTxt("+" + this.addScore, 250, 340, "#ffffff", 34)
this.scoreTips.alpha = 0
this.addChild(this.scoreTips)
Tween.get(this.scoreTips)
.to({ y: 300, alpha: 1 }, 200)
.wait(200)
.to({ y: 250, alpha: 0 }, 100)
.call(() => {
this.removeChild(this.scoreTips)
})
}
if (this.combineCount > 0) {
if (this.combineCount == 1) {
checkMusic("createEle", this.isPlayMusic)
......@@ -1144,6 +1190,7 @@ export class PlayScene extends Scene {
let arr = [], tag = false
this.currMoveType = "bottom"
this.combineCount = 0
this.addScore = 0
for (let y = 0; y < 4; y++) {
arr[y] = new Array()
for (let x = 0; x < 4; x++) {
......@@ -1153,6 +1200,20 @@ export class PlayScene extends Scene {
if (type) this.updateArr(arr[y], y)
}
this.score += this.addScore
if (this.addScore > 0) {
this.scoreTips = this.drawTxt("+" + this.addScore, 250, 340, "#ffffff", 34)
this.scoreTips.alpha = 0
this.addChild(this.scoreTips)
Tween.get(this.scoreTips)
.to({ y: 300, alpha: 1 }, 200)
.wait(200)
.to({ y: 250, alpha: 0 }, 100)
.call(() => {
this.removeChild(this.scoreTips)
})
}
if (this.combineCount > 0) {
if (this.combineCount == 1) {
......@@ -1193,7 +1254,6 @@ export class PlayScene extends Scene {
}
}
// 判断相加/合并
let addScore = 0
for (let i = 1; i < arr.length; i++) {
if (arr[i] === 0) break
if (arr[i] === arr[i - 1] && arr[i - 1] < 2048) {
......@@ -1253,23 +1313,9 @@ export class PlayScene extends Scene {
}
})
addScore += arr[i - 1]
this.score += arr[i - 1]
}
if (addScore > 0) {
this.scoreTips = this.drawTxt("+" + addScore, 250, 340, "#ffffff", 34)
this.scoreTips.alpha = 0
this.addChild(this.scoreTips)
Tween.get(this.scoreTips)
.to({ y: 300, alpha: 1 }, 200)
.wait(200)
.to({ y: 250, alpha: 0 }, 100)
.call(() => {
this.removeChild(this.scoreTips)
})
this.addScore += arr[i - 1]
// this.score += arr[i - 1]
}
}
}
......
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