Commit b8715fce by Eddy Guo

feat: add another bigHead and yell

parent 61c69f2b
......@@ -154,8 +154,11 @@ cc.Class({
// 更改时间进度条
updateLevelProgress: function() {
var isYelling = this.teacher.getComponent('Teacher').isYelling
if(this.level.progress > 0) {
this.level.progress -= ((1 / this.timer) / 60)
if (!isYelling) {
this.level.progress -= ((1 / this.timer) / 60)
}
} else {
this.gameOver()
}
......@@ -179,8 +182,11 @@ cc.Class({
// 添加分数
gainScore: function() {
this.score += 1;
this.score_number.string = this.score.toString();
var isYelling = this.teacher.getComponent('Teacher').isYelling
if (!isYelling) {
this.score += 1;
this.score_number.string = this.score.toString();
}
},
// 被抓检测
......@@ -203,7 +209,9 @@ cc.Class({
if (this.gameState === 'action') {
this.updateLevelProgress()
if (this.getCaught()) {
this.gameFail()
// this.gameFail()
this.teacher.getComponent('Teacher').showFailImage()
}
}
},
......@@ -221,7 +229,7 @@ cc.Class({
this.hand.active = false
this.board.active = false
this.teacher.active = false
this.gameState = 'stop'
this.gameState = 'stop'
},
// 游戏结束
......
......@@ -12,16 +12,23 @@ cc.Class({
coming: {
default: null,
type: cc.Node,
},
stupidHead: { // [600, 0]
default: null,
type: cc.Node,
},
failImage: { // [750, -30]
default: null,
type: cc.Node,
}
},
onLoad: function() {
// this.startSwivel()
this.isYelling = false // 被抓住显示失败图片的时间
this.isSwiveling = false // 是否回头
this.totalTime = 60 * 1000 // 总时间, bed
this.animationTime = 1 * 1000 // 转头过程单位时间, bed
this.needSwivelCount = 20 // 需要回头的次数
},
swivelAnimation: function() {
......@@ -35,32 +42,32 @@ cc.Class({
this.isSwiveling = false
}, this)
// var coming = cc.find("coming", this.node)
var bigHead = cc.find("big_head", this.node)
// var comingAction = cc.sequence(
// cc.moveTo(time, cc.p(100, 0)),
// cc.delayTime(time),
// cc.moveTo(time, cc.p(-50, 0)),
// cc.delayTime(time)
// )
var stupidHead = cc.find("stupid_head", this.node)
var action = cc.sequence(
// cc.delayTime(time * 5), // for coming time
cc.moveTo(5 * time, cc.p(100, 0)),
enableSwivel,
cc.delayTime(4 * time),
cc.moveTo(time, cc.p(0, 0)),
disableSwivel,
)
// coming.runAction(comingAction)
bigHead.runAction(action)
},
update: function(dt) {
// console.log('🐞-checking', this.isSwiveling)
},
var actionRight = cc.sequence(
cc.moveTo(5 * time, cc.p(430, 20)),
enableSwivel,
cc.delayTime(4 * time),
cc.moveTo(time, cc.p(600, 0)),
disableSwivel,
)
if (!this.isYelling) {
if (Math.random() > 0.5) {
bigHead.runAction(action)
} else {
stupidHead.runAction(actionRight)
}
}
},
// 获取转头时间的数组, [0.6, 1.2, 2.3, 3.4, 4.8, 5.2, 6.3]
getSwivelTimeArray: function(totalTime, count, animationTime) {
......@@ -79,7 +86,6 @@ cc.Class({
var swivelTimeArray = this.getSwivelTimeArray(this.totalTime, this.needSwivelCount, this.animationTime)
var lastTime
var swivelFunc = (timeArray) => {
const nextTime = timeArray.shift()
if (nextTime) {
......@@ -88,7 +94,9 @@ cc.Class({
setTimeout(() => {
this.swivelAnimation()
swivelFunc(timeArray)
if (!this.isYelling) {
swivelFunc(timeArray)
}
}, intervel)
}
}
......@@ -96,4 +104,26 @@ cc.Class({
swivelFunc(swivelTimeArray)
},
showFailImage: function() {
this.isSwiveling = false
this.isYelling = true
var gameFail = cc.callFunc(function() {
this.game.gameFail()
}, this)
var action = cc.sequence(
cc.moveTo(0.2, cc.p(260, -30)),
cc.delayTime(40),
gameFail,
)
var bigHead = cc.find("big_head", this.node)
bigHead.stopAllActions()
var stupidHead = cc.find("stupid_head", this.node)
stupidHead.stopAllActions()
var failImage = cc.find("failImage", this.node)
failImage.runAction(action)
},
})
\ No newline at end of file
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