Commit 0c5eb5b6 authored by Tt's avatar Tt

电池排列处理

parent 00a69e13
...@@ -2260,9 +2260,9 @@ ...@@ -2260,9 +2260,9 @@
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
"_target": null, "_target": null,
"_alignFlags": 8, "_alignFlags": 32,
"_left": 1646.9679999999998, "_left": 1646.9679999999998,
"_right": 0, "_right": -16.967999999999847,
"_top": 0, "_top": 0,
"_bottom": 0, "_bottom": 0,
"_verticalCenter": 0, "_verticalCenter": 0,
...@@ -2273,7 +2273,7 @@ ...@@ -2273,7 +2273,7 @@
"_isAbsBottom": true, "_isAbsBottom": true,
"_isAbsHorizontalCenter": true, "_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true, "_isAbsVerticalCenter": true,
"_originalWidth": 0, "_originalWidth": 290,
"_originalHeight": 0, "_originalHeight": 0,
"_id": "a2jfsVgYxNuLfbGl4yEA9T" "_id": "a2jfsVgYxNuLfbGl4yEA9T"
}, },
...@@ -2636,13 +2636,13 @@ ...@@ -2636,13 +2636,13 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "img_ battery6", "_name": "img_battery6",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 55 "__id__": 55
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 57 "__id__": 57
...@@ -2730,13 +2730,13 @@ ...@@ -2730,13 +2730,13 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "img_ battery4", "_name": "img_battery4",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 55 "__id__": 55
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 59 "__id__": 59
...@@ -2824,13 +2824,13 @@ ...@@ -2824,13 +2824,13 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "img_ battery5", "_name": "img_battery5",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 55 "__id__": 55
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 61 "__id__": 61
...@@ -2918,13 +2918,13 @@ ...@@ -2918,13 +2918,13 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "img_ battery3", "_name": "img_battery3",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 55 "__id__": 55
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 63 "__id__": 63
...@@ -3012,13 +3012,13 @@ ...@@ -3012,13 +3012,13 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "img_ battery2", "_name": "img_battery2",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 55 "__id__": 55
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 65 "__id__": 65
...@@ -3106,13 +3106,13 @@ ...@@ -3106,13 +3106,13 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "img_ battery1", "_name": "img_battery1",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 55 "__id__": 55
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 67 "__id__": 67
...@@ -4893,6 +4893,18 @@ ...@@ -4893,6 +4893,18 @@
"layout_canvas": { "layout_canvas": {
"__id__": 32 "__id__": 32
}, },
"layout_battery_left": {
"__id__": 46
},
"layout_battery_right": {
"__id__": 48
},
"item_battery_text": {
"__id__": 54
},
"item_battery_img": {
"__id__": 50
},
"_id": "5b78aJTZFGI79ubV+y7E/s" "_id": "5b78aJTZFGI79ubV+y7E/s"
} }
] ]
\ No newline at end of file
...@@ -28,9 +28,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -28,9 +28,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initData(); this.initData();
this.initView(); this.initView();
this.initEvent(); this.initEvent();
pg.view.find(this, 'layout_xiaodi').getComponent(dg_xiaodi).playEnter(this.data.npcAudio).then(() => { // pg.view.find(this, 'layout_xiaodi').getComponent(dg_xiaodi).playEnter(this.data.npcAudio).then(() => {
// this.initGame();
// })
this.initGame(); this.initGame();
})
} }
_cantouch = null; _cantouch = null;
...@@ -64,13 +65,67 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -64,13 +65,67 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 初始化游戏 // 初始化游戏
initGame() { initGame() {
this.updateCanvas(); this.updateCanvas();
this.initLayoutBattery();
} }
@property(cc.Node) layout_canvas: cc.Node = null; @property(cc.Node) layout_canvas: cc.Node = null;
@property(cc.Node) layout_battery_left: cc.Node = null;
@property(cc.Node) layout_battery_right: cc.Node = null;
@property(cc.Node) item_battery_text: cc.Node = null;
@property(cc.Node) item_battery_img: cc.Node = null;
updateCanvas() { updateCanvas() {
let img = pg.view.find(this.layout_canvas, 'img'); let img = pg.view.find(this.layout_canvas, 'img');
pg.view.setNetImg(img, this.currentQuestion.bgItem.url, { w: 1220, h: 790 }) pg.view.setNetImg(img, this.currentQuestion.bgItem.url, { w: 1220, h: 790 })
} }
initLayoutBattery() {
let color = 1;
let orgPosY = 500;
let spaceImgY = 300;
let spaceTextY = 200;
// 电池显示 左边4个 右边4个 如果是6个就是左三个 右三个
let hotZoneItemArr = this.currentQuestion.hotZoneItemArr
let lineNum = Math.ceil(hotZoneItemArr.length / 2)
let lastY = null;
hotZoneItemArr.forEach((data, i) => {
let isleft = i + 1 <= lineNum
let layout = isleft ? this.layout_battery_left : this.layout_battery_right;
if (i + 1 - lineNum == 1) {
lastY = null;
}
if (data.itemType == 'text') {
let item = pg.view.clone(this.item_battery_text)
if (isleft) {
// 左侧
pg.view.visible(pg.view.find(item, 'bg/img_battery' + 1), i == 0)
pg.view.visible(pg.view.find(item, 'bg/img_battery' + 2), i == 1)
pg.view.visible(pg.view.find(item, 'bg/img_battery' + 3), i == 2)
pg.view.visible(pg.view.find(item, 'bg/img_battery' + 4), i == 3)
} else {
// 右侧
pg.view.visible(pg.view.find(item, 'bg/img_battery' + 5), i == 4 || i == 6)
pg.view.visible(pg.view.find(item, 'bg/img_battery' + 6), i == 5 || i == 7)
}
item.active = true;
item.x = 0;
if (!lastY && lastY != 0) lastY = orgPosY;
item.y = lastY -= spaceTextY;
layout.addChild(item);
lastY = item.y;
color++;
if (color > 6) color = 1;
} else if (data.itemType == 'pic') {
let item = pg.view.clone(this.item_battery_img)
item.active = true;
item.x = 0;
if (!lastY && lastY != 0) lastY = orgPosY;
item.y = lastY -= spaceImgY;
layout.addChild(item);
lastY = item.y;
}
console.log(data);
})
}
......
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