Commit b8715fce by Eddy Guo

feat: add another bigHead and yell

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