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) {
if (!isYelling) {
this.level.progress -= ((1 / this.timer) / 60)
}
} else {
this.gameOver()
}
......@@ -179,8 +182,11 @@ cc.Class({
// 添加分数
gainScore: function() {
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()
}
}
},
......
......@@ -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,18 +42,10 @@ 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),
......@@ -54,12 +53,20 @@ cc.Class({
disableSwivel,
)
// coming.runAction(comingAction)
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)
},
update: function(dt) {
// console.log('🐞-checking', this.isSwiveling)
} else {
stupidHead.runAction(actionRight)
}
}
},
// 获取转头时间的数组, [0.6, 1.2, 2.3, 3.4, 4.8, 5.2, 6.3]
......@@ -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()
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