Commit fef972aa authored by yu's avatar yu

1

parent 5493ee25
......@@ -155,6 +155,8 @@ export default class Game {
text: item.text,
width: item.rect.width * scX,
height: item.rect.height * scY,
index: item.index,
pic_url: item.pic_url,
}
})
this.pointsArr = arr.concat();
......
This diff is collapsed.
......@@ -171,39 +171,65 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
this.layout_op.removeAllChildren();
let op = Game.getIns().opdata;
let item = cc.instantiate(this.item_op);
let item = this.item_op;
// let item = cc.instantiate(this.item_op);
item.active = true;
// item.parent = this.layout_op;
op.forEach((dt, idx) => {
if (idx % 8 == 0) {
item = cc.instantiate(this.item_op);
item.active = true;
item.parent = this.layout_op;
}
let id = idx % 8;
let ch = item.children[id];
this.log(id)
// if (idx % 8 == 0) {
// }
// let id = idx % 8;
let ch = item.children[idx];
// this.log(id)
if (!ch) return;
ch.active = true;
let desc = cc.find("desc", ch);
desc.getComponent(cc.Label).string = dt.text;
desc.active = true;
let img = cc.find("img", ch);
let node;
if (dt.pic_url && dt.pic_url != "") {
pg.view.setNetImg(img, dt.pic_url, { w: 200, h: 150 });
desc.getComponent(cc.Label).string = "";
img.active = true;
desc.active = false;
node = img;
} else {
desc.getComponent(cc.Label).string = dt.text;
img.active = false;
desc.active = true;
node = desc;
}
let data: any = {};
data.text = dt.text;
data.audio = dt.audio_url || "";
data.index = dt.index;
data.parent = ch;
data.x = desc.x;
data.y = desc.y;
desc.data = data;
data.x = node.x;
data.y = node.y;
node.data = data;
desc.on(cc.Node.EventType.TOUCH_START, this.onItemTouchStart, this);
desc.on(cc.Node.EventType.TOUCH_MOVE, this.onItemTouchMove, this);
desc.on(cc.Node.EventType.TOUCH_END, this.onItemTouchEnd, this);
desc.on(cc.Node.EventType.TOUCH_CANCEL, this.onItemTouchCancel, this);
node.on(cc.Node.EventType.TOUCH_START, this.onItemTouchStart, this);
node.on(cc.Node.EventType.TOUCH_MOVE, this.onItemTouchMove, this);
node.on(cc.Node.EventType.TOUCH_END, this.onItemTouchEnd, this);
node.on(cc.Node.EventType.TOUCH_CANCEL, this.onItemTouchCancel, this);
ch.getComponent(cc.Layout).enabled = false;
let stone1 = cc.find("stone1", ch);
this.stSction(stone1);
})
cc.find("ScrollView", this.node).getComponent(cc.ScrollView).enabled = op.length > 4;
let size = cc.view.getCanvasSize();
let scale = (size.width / size.height) / (1920 / 1080);
let oplen = scale > 1.2 ? 5 : 4;
if (op.length > oplen) {
cc.find("ScrollView", this.node).getComponent(cc.ScrollView).enabled = false;
this.layout_op.getComponent(cc.Layout).enabled = true;
let x = 0;
if (op.length > 12) x = 7680;
else if (op.length > 8) x = 5760;
else if (op.length > oplen) x = 3840;
cc.tween(item).repeatForever(cc.tween().by(10, { x: -x })
.call(() => { item.x = -960 * scale; }))
.start();
}
}
private creaetPosPic() {
let pos = Game.getIns().pointsArr;
......@@ -216,7 +242,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
// let desc = cc.find("desc", item);
// desc.getComponent(cc.Label).string = li.text;
this.cardBgs.push(item);
let data = { text: li.text };
let data = li;
item.data = data;
item.width = li.width;
item.height = li.height;
......@@ -293,13 +319,13 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
// let dis = this.getDistances(target.getPosition(), bg.getPosition());
let dis = this.getDistances(target, bg);
// if (dis < 100 && bg.sortId == data.id) {
if (dis < 100 && bg.data.text == data.text) {
if (dis < 100 && bg.data.index == data.index) {
return bg;
}
return null;
})
//检测是否在区域内
if (!itemBg || itemBg.data.text != data.text) {
if (!itemBg) {
target.parent = data.parent;
target.setPosition(data.x, data.y);
// this.playLocalAudio("error");
......@@ -315,8 +341,14 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
let layer_candy = cc.find("layer_candy", itemBg);
layer_candy.active = true;
let desc = cc.find("desc", itemBg);
desc.getComponent(cc.Label).string = data.text;
if (itemBg.data.pic_url && itemBg.data.pic_url != "") {
let img = cc.find("img", itemBg);
pg.view.setNetImg(img, itemBg.data.pic_url, { w: itemBg.data.width, h: itemBg.data.height });
} else {
let desc = cc.find("desc", itemBg);
desc.getComponent(cc.Label).string = data.text;
}
this.playLocalAudio("right").then(async () => {
......
......@@ -258,12 +258,12 @@ let pg = {
node.net_url = res;
if (!cc.isValid(node)) return pg.logger.i("节点已销毁");
if (!node) return pg.logger.w("节点已销毁");
if (w && h && custom) {
if (w && h) {
let scaleX = w / nw;
let scaleY = h / nh;
let scale = scaleX <= scaleY ? scaleX : scaleY;
node.width = nw * scaleX;
node.height = nh * scaleY;
node.width = custom ? nw * scaleX : nw * scale;
node.height = custom ? nh * scaleY : nw * scale;
}
node.active = true;
resolve({ w: nw, h: nh });
......
{
"ver": "2.3.5",
"uuid": "dfa36e3a-d7b9-429d-a759-7962c373a135",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 7680,
"height": 350,
"platformSettings": {},
"subMetas": {
"stone1": {
"ver": "1.0.4",
"uuid": "79b766ef-9ba2-45fb-8893-5ff148e34bcd",
"rawTextureUuid": "dfa36e3a-d7b9-429d-a759-7962c373a135",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"trimX": 0,
"trimY": 1,
"width": 7680,
"height": 349,
"rawWidth": 7680,
"rawHeight": 350,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "fa76097d-29d1-4c74-b2ff-7bfb123d650a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 7680,
"height": 350,
"platformSettings": {},
"subMetas": {
"stone2": {
"ver": "1.0.4",
"uuid": "5c1e928d-859c-44b7-aa24-d6e596582f62",
"rawTextureUuid": "fa76097d-29d1-4c74-b2ff-7bfb123d650a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 6,
"offsetY": -22,
"trimX": 19,
"trimY": 45,
"width": 7654,
"height": 304,
"rawWidth": 7680,
"rawHeight": 350,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
......@@ -42,6 +42,7 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
name: '文本',
text: true,
audio: true,
pic: true,
// action: {
// type: 'text',
// option: [
......
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