Commit ea2c7a4e authored by Tt's avatar Tt

泡泡的具体更新逻辑拆分成独立函数,传入节点和数据, 自行处理显示内容

parent 847d8c27
...@@ -3479,7 +3479,7 @@ ...@@ -3479,7 +3479,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "bubble", "_name": "img",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 76 "__id__": 76
...@@ -3502,8 +3502,8 @@ ...@@ -3502,8 +3502,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 240, "width": 60,
"height": 240 "height": 60
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -3537,7 +3537,7 @@ ...@@ -3537,7 +3537,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "c82xd9qHpBaY3cEGeKTIVp" "_id": "66oMgtlA9LR55toWGd4Ae4"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -3555,7 +3555,7 @@ ...@@ -3555,7 +3555,7 @@
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "ee7ceefa-fc90-447c-ad40-9909bc242a4b" "__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 0, "_sizeMode": 0,
...@@ -3569,11 +3569,11 @@ ...@@ -3569,11 +3569,11 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "0fFqNj60RIkoLf9MMvpK34" "_id": "26syoaPC9DiZaenc3mDFGI"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "bubble_broken", "_name": "text",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 76 "__id__": 76
...@@ -3596,8 +3596,8 @@ ...@@ -3596,8 +3596,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 240, "width": 68.51,
"height": 240 "height": 37.8
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -3631,10 +3631,10 @@ ...@@ -3631,10 +3631,10 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "9aMjDSvq5N7YTpu+Gah7n7" "_id": "54bNiQNLNOmarb6V8WL+O8"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Label",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
...@@ -3648,26 +3648,27 @@ ...@@ -3648,26 +3648,27 @@
], ],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_string": "Label",
"__uuid__": "d467620d-7515-405b-9d15-3693bc6beb45" "_N$string": "Label",
}, "_fontSize": 28,
"_type": 0, "_lineHeight": 30,
"_sizeMode": 0, "_enableWrapText": true,
"_fillType": 0, "_N$file": null,
"_fillCenter": { "_isSystemFontUsed": true,
"__type__": "cc.Vec2", "_spacingX": 0,
"x": 0, "_batchAsBitmap": false,
"y": 0 "_styleFlags": 0,
}, "_underlineHeight": 0,
"_fillStart": 0, "_N$horizontalAlign": 1,
"_fillRange": 0, "_N$verticalAlign": 1,
"_isTrimmedMode": true, "_N$fontFamily": "Arial",
"_atlas": null, "_N$overflow": 0,
"_id": "59VZnhWc1KPZ6Cb0LtuHLx" "_N$cacheMode": 0,
"_id": "5dd0wHF9RFJZh6KdVsSS3o"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "img", "_name": "bubble",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 76 "__id__": 76
...@@ -3690,8 +3691,8 @@ ...@@ -3690,8 +3691,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 60, "width": 240,
"height": 60 "height": 240
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -3725,7 +3726,7 @@ ...@@ -3725,7 +3726,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "66oMgtlA9LR55toWGd4Ae4" "_id": "c82xd9qHpBaY3cEGeKTIVp"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -3743,7 +3744,7 @@ ...@@ -3743,7 +3744,7 @@
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061" "__uuid__": "ee7ceefa-fc90-447c-ad40-9909bc242a4b"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 0, "_sizeMode": 0,
...@@ -3757,11 +3758,11 @@ ...@@ -3757,11 +3758,11 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "26syoaPC9DiZaenc3mDFGI" "_id": "0fFqNj60RIkoLf9MMvpK34"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "text", "_name": "bubble_broken",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 76 "__id__": 76
...@@ -3784,8 +3785,8 @@ ...@@ -3784,8 +3785,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 68.51, "width": 240,
"height": 37.8 "height": 240
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -3819,10 +3820,10 @@ ...@@ -3819,10 +3820,10 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "54bNiQNLNOmarb6V8WL+O8" "_id": "9aMjDSvq5N7YTpu+Gah7n7"
}, },
{ {
"__type__": "cc.Label", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
...@@ -3836,23 +3837,22 @@ ...@@ -3836,23 +3837,22 @@
], ],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_string": "Label", "_spriteFrame": {
"_N$string": "Label", "__uuid__": "d467620d-7515-405b-9d15-3693bc6beb45"
"_fontSize": 28, },
"_lineHeight": 30, "_type": 0,
"_enableWrapText": true, "_sizeMode": 0,
"_N$file": null, "_fillType": 0,
"_isSystemFontUsed": true, "_fillCenter": {
"_spacingX": 0, "__type__": "cc.Vec2",
"_batchAsBitmap": false, "x": 0,
"_styleFlags": 0, "y": 0
"_underlineHeight": 0, },
"_N$horizontalAlign": 1, "_fillStart": 0,
"_N$verticalAlign": 1, "_fillRange": 0,
"_N$fontFamily": "Arial", "_isTrimmedMode": true,
"_N$overflow": 0, "_atlas": null,
"_N$cacheMode": 0, "_id": "59VZnhWc1KPZ6Cb0LtuHLx"
"_id": "5dd0wHF9RFJZh6KdVsSS3o"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
......
...@@ -76,34 +76,16 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -76,34 +76,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
let layer_paopao = pg.view.find(this, 'layer_game/layer_paopao') let layer_paopao = pg.view.find(this, 'layer_game/layer_paopao')
let paoaoParent = pg.view.find(this, 'layer_game/paopao') let paoaoParent = pg.view.find(this, 'layer_game/paopao')
let newPaoPao = cc.instantiate(paoaoParent) let newPaoPao = cc.instantiate(paoaoParent)
// 点击泡泡
pg.view.touchOn(newPaoPao, this.touchPaoPao, this)
let paopao = newPaoPao.getChildByName("bubble")
let broken = newPaoPao.getChildByName("bubble_broken")
let img = newPaoPao.getChildByName("img")
let text = newPaoPao.getChildByName("text")
// 判断是显示图片还是文字
if (this.currentQuestion.options[this.touchNumber - 1].type === 'img') {
pg.view.visible(img, true)
pg.view.visible(text, false)
pg.view.setNetImg(img, this.currentQuestion.options[this.touchNumber - 1].image, { w: 60, h: 60 })
} else {
pg.view.visible(img, false)
pg.view.visible(text, true)
pg.view.setString(text, this.currentQuestion.options[this.touchNumber - 1].text)
}
let btn = cc.tween(bottom_megaphone)
layer_paopao.addChild(newPaoPao) layer_paopao.addChild(newPaoPao)
this.updatePaoPao(newPaoPao, this.currentQuestion.options[this.touchNumber - 1]);
let btn = cc.tween(bottom_megaphone)
btn.to(0.1, { x: -5 }).to(0.1, { x: 0 }).to(0.1, { x: 5 }).to(0.1, { x: 0 }) btn.to(0.1, { x: -5 }).to(0.1, { x: 0 }).to(0.1, { x: 5 }).to(0.1, { x: 0 })
btn.to(0.1, { x: -5 }).to(0.1, { x: 0 }).to(0.1, { x: 5 }).to(0.1, { x: 0 }) btn.to(0.1, { x: -5 }).to(0.1, { x: 0 }).to(0.1, { x: 5 }).to(0.1, { x: 0 })
.call(() => { .call(() => {
newPaoPao.x = 135 newPaoPao.x = 135
newPaoPao.y = -450 newPaoPao.y = -450
paopao.width = 70
paopao.height = 70
newPaoPao.opacity = 0 newPaoPao.opacity = 0
pg.view.visible(newPaoPao, true) pg.view.visible(newPaoPao, true)
pg.view.visible(broken, false)
cc.tween(newPaoPao).to(0.8, { opacity: 255 }).call(() => { cc.tween(newPaoPao).to(0.8, { opacity: 255 }).call(() => {
let positionY = Math.floor(Math.random() * 300) let positionY = Math.floor(Math.random() * 300)
let positionX = this.getPositionX() let positionX = this.getPositionX()
...@@ -121,6 +103,28 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -121,6 +103,28 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
this.touchNumber++; this.touchNumber++;
} }
updatePaoPao(item, data) {
let paopao = item.getChildByName("bubble")
let broken = item.getChildByName("bubble_broken")
let img = item.getChildByName("img")
let text = item.getChildByName("text")
paopao.width = 70
paopao.height = 70
pg.view.visible(broken, false)
// 判断是显示图片还是文字
if (data.type === 'img') {
pg.view.visible(img, true)
pg.view.visible(text, false)
pg.view.setNetImg(img, data.image, { w: 60, h: 60 })
} else {
pg.view.visible(img, false)
pg.view.visible(text, true)
pg.view.setString(text, data.text)
}
// 点击泡泡
pg.view.touchOn(item, this.touchPaoPao, this)
}
getPositionX() { getPositionX() {
if (Math.random() < 0.5) { if (Math.random() < 0.5) {
......
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