Commit bd0b2481 authored by jeff's avatar jeff

修改bug

parent 99555427
const tools = require("../script/tools"); const tools = require("../script/tools");
var onlyOne
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
...@@ -15,6 +14,7 @@ cc.Class({ ...@@ -15,6 +14,7 @@ cc.Class({
data: null, data: null,
onLoad() { onLoad() {
this._playing = false
this.quan.active = false this.quan.active = false
this.tipsAnim.node.active = false this.tipsAnim.node.active = false
this.handAnim.node.active = false this.handAnim.node.active = false
...@@ -29,14 +29,12 @@ cc.Class({ ...@@ -29,14 +29,12 @@ cc.Class({
}, },
initWithData(data, scale) { initWithData(data, scale) {
console.log(scale)
this.data = data this.data = data
let rect = this.data.rect let rect = this.data.rect
this.node.x = (rect.x + rect.width / 2) / scale this.node.x = (rect.x + rect.width / 2) / scale
this.node.y = (-rect.y - rect.height / 2) / scale this.node.y = (-rect.y - rect.height / 2) / scale
this.node.width = rect.width / scale this.node.width = rect.width / scale
this.node.height = rect.height / scale this.node.height = rect.height / scale
console.log(this.node)
this.sprite.node.active = false this.sprite.node.active = false
if (data.useHand) { if (data.useHand) {
this.handAnim.node.active = true this.handAnim.node.active = true
...@@ -50,19 +48,10 @@ cc.Class({ ...@@ -50,19 +48,10 @@ cc.Class({
}, },
onTouchStart() { onTouchStart() {
if (this._playing) return
if (this.audioId) return if (this.audioId) return
if (this.data) { if (this.data) {
let url = this.data.audio_url if (this.data.pic_url && this.data.gIdx == 0) {
if (url && url != '') {
this.playAudio(url)
this.tipsAnim.node.active = true
this.tipsAnim.play()
} else {
this.scheduleOnce(() => {
this.quan.active = false
}, 0.2)
}
if (this.data.pic_url) {
tools.getSpriteFrimeByUrl(this.data.pic_url, (sp) => { tools.getSpriteFrimeByUrl(this.data.pic_url, (sp) => {
this.sprite.spriteFrame = sp this.sprite.spriteFrame = sp
this.sprite.node.width = this.node.width this.sprite.node.width = this.node.width
...@@ -75,33 +64,62 @@ cc.Class({ ...@@ -75,33 +64,62 @@ cc.Class({
} }
this.handAnim.stop() this.handAnim.stop()
this.handAnim.node.active = false this.handAnim.node.active = false
cc.audioEngine.play(this.tipClip) if (!this._playing) {
this._playing = true
cc.systemEvent.once('stopMusic', this.onStopAudio, this)
let id = cc.audioEngine.play(this.tipClip)
cc.audioEngine.setFinishCallback(id, () => {
if (onlyOne != this) {
this._playing = false
return
}
let url = this.data.audio_url
if (url && url != '') {
this.playAudio(url)
this.tipsAnim.node.active = true
this.tipsAnim.play()
} else {
this._playing = false
}
})
}
if (onlyOne && onlyOne != this) {
onlyOne.hideBox()
}
onlyOne = this
} }
}, },
/**隐藏边框 */
hideBox() {
this.quan.active = false
this.stopAudio()
},
/** 播放音乐 */ /** 播放音乐 */
playAudio(url) { playAudio(url) {
cc.assetManager.loadRemote(url, (err, audioClip) => { cc.assetManager.loadRemote(url, (err, audioClip) => {
if (err) return if (err) return
cc.systemEvent.once('stopMusic', this.stopAudio, this) if (!this._playing) return
this.audioId = cc.audioEngine.play(audioClip, false, 0.8); this.audioId = cc.audioEngine.play(audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(this.audioId, this.stopAudio.bind(this)); cc.audioEngine.setFinishCallback(this.audioId, this.stopAudio.bind(this));
}); });
}, },
onStopAudio() {
this._playing = false
this.stopAudio()
},
stopAudio() { stopAudio() {
this._playing = false
if (this.audioId != null) { if (this.audioId != null) {
cc.audioEngine.stop(this.audioId) cc.audioEngine.stop(this.audioId)
this.audioId = null this.audioId = null
this.quan.active = false
this.tipsAnim.stop()
this.tipsAnim.node.active = false
if (this.data.useHand) {
this.handAnim.node.active = true
this.handAnim.play()
}
cc.systemEvent.off('stopMusic', this.stopAudio, this)
} }
this.tipsAnim.stop()
this.tipsAnim.node.active = false
cc.systemEvent.off('stopMusic', this.onStopAudio, this)
}, },
/** 音频id */ /** 音频id */
audioId: null, audioId: null,
......
...@@ -12,6 +12,8 @@ cc.Class({ ...@@ -12,6 +12,8 @@ cc.Class({
this._hitItem = [] this._hitItem = []
this._items = this.node.getChildByName('items') this._items = this.node.getChildByName('items')
this._sprite = this.getComponentInChildren(cc.Sprite) this._sprite = this.getComponentInChildren(cc.Sprite)
this.borders[0].active = false
this.borders[1].active = false
}, },
initWithData(data) { initWithData(data) {
...@@ -36,6 +38,8 @@ cc.Class({ ...@@ -36,6 +38,8 @@ cc.Class({
this.node.width = originRect.width this.node.width = originRect.width
this.node.height = originRect.height this.node.height = originRect.height
} }
this.borders[0].active = true
this.borders[1].active = true
this.borders[0].x = -this.node.width / 2 this.borders[0].x = -this.node.width / 2
this.borders[1].x = this.node.width / 2 this.borders[1].x = this.node.width / 2
this._sprite.spriteFrame = sp this._sprite.spriteFrame = sp
......
...@@ -1440,8 +1440,8 @@ ...@@ -1440,8 +1440,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
-16.572, 42.455,
3.038, -7.606,
0, 0,
0, 0,
0, 0,
...@@ -1619,8 +1619,8 @@ ...@@ -1619,8 +1619,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
97.71, 135.449,
3.038, -6.961,
0, 0,
0, 0,
0, 0,
...@@ -1852,9 +1852,6 @@ ...@@ -1852,9 +1852,6 @@
"btnClip": { "btnClip": {
"__uuid__": "39ef1939-3bf9-4d21-a67a-bc1dede521a9" "__uuid__": "39ef1939-3bf9-4d21-a67a-bc1dede521a9"
}, },
"tipClip": {
"__uuid__": "e0bcf4cc-35a7-4d61-b202-8dd49299c2c0"
},
"_id": "a1ibU1vO9Nwbfwjsm/NgGR" "_id": "a1ibU1vO9Nwbfwjsm/NgGR"
} }
] ]
\ No newline at end of file
...@@ -100,7 +100,7 @@ cc.Class({ ...@@ -100,7 +100,7 @@ cc.Class({
}, },
getDefaultData() { getDefaultData() {
const dataJson = '[{"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/31bde9b15582618fa5db4ac7cbc275b4.gif","rect":{"x":84.63,"y":0,"width":1411.73,"height":594}},"hotZoneItemArr":[{"id":"1620785442406","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/aa0d852ef05d9d8de158f10b4a727376.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/bd0502e664d0d279ccbec4e22b60f051.mp3","itemType":"pic","fontScale":1.23515625,"imgScale":0.48055555555555557,"mapScale":1.23515625,"gIdx":"0","useHand":true,"useBorder":true,"rect":{"x":1149.88,"y":4,"width":346,"height":346}}]},{"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/e74a1c89473132b6ce53633fc53a6aee.jpg","rect":{"x":566.43,"y":0,"width":448.14,"height":594}},"hotZoneItemArr":[]},{}]' const dataJson = '[{"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/335dea1b83498b0c7c05be637dc13dad.jpeg","rect":{"x":246.27,"y":0,"width":114.46,"height":233},"useBorder":true},"hotZoneItemArr":[{"id":"1620754084744","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/335dea1b83498b0c7c05be637dc13dad.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/8f73a6b73a217d25ca4f4a2e234c1513.mp3","itemType":"rect","fontScale":0.47421875,"imgScale":0.4640625,"mapScale":0.47421875,"gIdx":"1","useHand":true,"useBorder":true,"rect":{"x":184.73,"y":92,"width":69.01,"height":69.01}},{"id":"1621558296515","index":1,"audio_url":"http://staging-teach.cdn.ireadabc.com/c8a7dd49a778b0b6dd509aac0ef437ff.mp3","itemType":"rect","fontScale":0.47421875,"imgScale":1,"mapScale":0.47421875,"gIdx":"1","useHand":true,"useBorder":true,"rect":{"x":-140.27,"y":99,"width":59,"height":59}}]},{"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/31bde9b15582618fa5db4ac7cbc275b4.gif","rect":{"x":56.34,"y":0,"width":1005.32,"height":423}},"hotZoneItemArr":[{"id":"1621560079894","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/335dea1b83498b0c7c05be637dc13dad.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/8f73a6b73a217d25ca4f4a2e234c1513.mp3","itemType":"pic","fontScale":0.8734375,"imgScale":0.19338422391857507,"mapScale":0.8734375,"gIdx":"0","useHand":true,"useBorder":true,"rect":{"x":773.66,"y":47.15,"width":76,"height":154.71}},{"id":"1621560091737","index":1,"audio_url":"http://staging-teach.cdn.ireadabc.com/8f73a6b73a217d25ca4f4a2e234c1513.mp3","itemType":"rect","fontScale":0.8734375,"imgScale":1,"mapScale":0.8734375,"gIdx":"1","useHand":true,"useBorder":true,"rect":{"x":150.66,"y":26.5,"width":200,"height":200}}]}]'
const data = JSON.parse(dataJson); const data = JSON.parse(dataJson);
return data; return data;
}, },
...@@ -225,7 +225,7 @@ cc.Class({ ...@@ -225,7 +225,7 @@ cc.Class({
leftMove() { leftMove() {
this.stopAudio() this.stopAudio()
this._cantouch = false; this._cantouch = false;
let width = cc.winSize.width+64 let width = cc.winSize.width + 64
this.picNode.x = 0 this.picNode.x = 0
this.picTempNode.x = width this.picTempNode.x = width
this.setContent(this.picTempNode, this.data[this.curPage]) this.setContent(this.picTempNode, this.data[this.curPage])
...@@ -248,7 +248,7 @@ cc.Class({ ...@@ -248,7 +248,7 @@ cc.Class({
rightMove() { rightMove() {
this.stopAudio() this.stopAudio()
this._cantouch = false; this._cantouch = false;
let width = cc.winSize.width+64 let width = cc.winSize.width + 64
this.picNode.x = 0 this.picNode.x = 0
this.picTempNode.x = -width this.picTempNode.x = -width
this.setContent(this.picTempNode, this.data[this.curPage]) this.setContent(this.picTempNode, this.data[this.curPage])
......
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