Commit fb2533ce authored by yu's avatar yu

调整

parent a2cb5174
...@@ -101,6 +101,7 @@ export default class NewClass extends cc.Component { ...@@ -101,6 +101,7 @@ export default class NewClass extends cc.Component {
return; return;
} }
const bigStarBg = this.bigStarArr[this.curGroupIndex++]; const bigStarBg = this.bigStarArr[this.curGroupIndex++];
if (!bigStarBg) return;
const starBig = bigStarBg.starBig; const starBig = bigStarBg.starBig;
starBig.scale = 1; starBig.scale = 1;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -15,6 +15,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -15,6 +15,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
private ani_flower; private ani_flower;
private rightClip; private rightClip;
private wrongClip; private wrongClip;
private roundIdx: number = 0;
private questIdx: number = 0;
addPreloadImage() { addPreloadImage() {
...@@ -45,7 +47,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -45,7 +47,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 所有全局变量 默认都是null // 所有全局变量 默认都是null
Game.getIns().aniEnter = this.data.aniEnter; Game.getIns().aniEnter = this.data.aniEnter;
this._cantouch = true; this._cantouch = true;
this.randomData();
this._colors = ["#4ab222", "#e6223f", "#5f63e8", "#f28c20", "#dc43ff", "#f851bc", "#00aec9", "#a766ec"]; this._colors = ["#4ab222", "#e6223f", "#5f63e8", "#f28c20", "#dc43ff", "#f851bc", "#00aec9", "#a766ec"];
} }
initView() { initView() {
...@@ -53,7 +54,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -53,7 +54,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.ani_flower = cc.find("particle_star", this.node); this.ani_flower = cc.find("particle_star", this.node);
this.rightClip = cc.find('Canvas/res/audio/right').getComponent(cc.AudioSource).clip; this.rightClip = cc.find('Canvas/res/audio/right').getComponent(cc.AudioSource).clip;
this.wrongClip = cc.find('Canvas/res/audio/wrong').getComponent(cc.AudioSource).clip; this.wrongClip = cc.find('Canvas/res/audio/wrong').getComponent(cc.AudioSource).clip;
pg.event.emit("mouse_num", this.data.item.group.length); pg.event.emit("mouse_num", this.data.item.length);
this.updateRound(); this.updateRound();
this.showGame(); this.showGame();
...@@ -238,7 +239,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -238,7 +239,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
private randomData() { private randomData() {
this.upArr = []; this.upArr = [];
this.downArr = []; this.downArr = [];
let data = this.data.item.group; let dt = this.data.item[this.roundIdx];
if (!dt) return;
let data = dt.group;
data.forEach((dt, idx) => { data.forEach((dt, idx) => {
if (dt.up) { if (dt.up) {
dt.up.id = idx; dt.up.id = idx;
...@@ -254,27 +257,41 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -254,27 +257,41 @@ export default class SceneComponent extends MyCocosSceneComponent {
private updateRound() { private updateRound() {
let label_round = cc.find("bg/page/lable", this.node); let label_round = cc.find("bg/page/lable", this.node);
label_round.getComponent(cc.Label).string = this._drawIndex + "/" + this.data.item.group.length; let round = this.roundIdx + 1;
// label_round.getComponent(cc.Label).string = "1/1"; if (round > this.data.item.length) round = this.data.item.length;
label_round.getComponent(cc.Label).string = round + "/" + this.data.item.length;
} }
private showGame() { private showGame() {
if (this.roundIdx >= this.data.item.length) {
this.gameOver();
return;
}
this.randomData();
this.showQuestion(); this.showQuestion();
this.showLayout(); this.showLayout();
} }
private checkisPicOrText() {
if (this.upArr.length != 4) return false;
let t1 = this.upArr[0].type == 1;
let t2 = this.downArr[0].type == 1;
return t1 && t2;
}
private showLayout() { private showLayout() {
let data = this.data.item.group; let data = this.data.item.group;
let lift = cc.find("lift", this.node); let lift = cc.find("lift", this.node);
let right = cc.find("right", this.node); let right = cc.find("right", this.node);
lift.removeAllChildren(); lift.removeAllChildren();
right.removeAllChildren(); right.removeAllChildren();
let isSpY = this.checkisPicOrText();
right.getComponent(cc.Layout).spacingY = isSpY ? 30 : 10;
lift.getComponent(cc.Layout).spacingY = isSpY ? 30 : 10;
this.upArr.forEach((item) => { this.upArr.forEach((item) => {
if (item.type == 1) { if (item.type == 1) {
let textItem = this.getItemNode(1); let textItem = this.getItemNode(1, isSpY);
let size = this.getHeadSize(1); let size = this.getHeadSize(1);
this.initTextItem(textItem, item, 1); this.initTextItem(textItem, item, 1);
textItem.parent = lift; textItem.parent = lift;
...@@ -288,7 +305,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -288,7 +305,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.downArr.forEach((item) => { this.downArr.forEach((item) => {
if (item.type == 1) { if (item.type == 1) {
let textItem = this.getItemNode(2); let textItem = this.getItemNode(2, isSpY);
let size = this.getHeadSize(2); let size = this.getHeadSize(2);
this.initTextItem(textItem, item); this.initTextItem(textItem, item);
textItem.parent = right; textItem.parent = right;
...@@ -313,7 +330,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -313,7 +330,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// // this.updataMouse(); // // this.updataMouse();
// return; // return;
// } // }
let quest = this.data.item; let quest = this.data.item[this.roundIdx];
// this.showCheckGroup(quest); // this.showCheckGroup(quest);
let question = cc.find("question", this.node); let question = cc.find("question", this.node);
...@@ -344,11 +361,11 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -344,11 +361,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
let img_laba02 = item.getChildByName("img_close"); let img_laba02 = item.getChildByName("img_close");
let desc = item.getChildByName("desc"); let desc = item.getChildByName("desc");
desc.getComponent(cc.Label).string = data.text; desc.getComponent(cc.Label).string = data.text;
if (item.width - desc.width > 10) {
setTimeout(() => { setTimeout(() => {
if (desc.width - item.width > -15 && item.name != "type4") {
item.width = desc.width + 30; item.width = desc.width + 30;
}, 30);
} }
}, 30);
item.on(cc.Node.EventType.TOUCH_END, () => { item.on(cc.Node.EventType.TOUCH_END, () => {
setTimeout(() => { setTimeout(() => {
this.checkLing(); this.checkLing();
...@@ -400,41 +417,61 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -400,41 +417,61 @@ export default class SceneComponent extends MyCocosSceneComponent {
let liftIdx = -1; let liftIdx = -1;
let rightIdx = -1; let rightIdx = -1;
liftLayout.children.forEach((ch, idx) => { liftLayout.children.forEach((ch, idx) => {
let circle_right = ch.getChildByName("circle_right");
let t = ch.getComponent(cc.Toggle); let t = ch.getComponent(cc.Toggle);
if (t.isChecked) { if (t.isChecked) {
liftIdx = idx; liftIdx = idx;
lift = ch; lift = ch;
if (circle_right) circle_right.opacity = 255;
} else {
if (circle_right) circle_right.opacity = 0;
} }
}); });
rightLayout.children.forEach((ch, idx) => { rightLayout.children.forEach((ch, idx) => {
let circle_lift = ch.getChildByName("circle_lift");
let t = ch.getComponent(cc.Toggle); let t = ch.getComponent(cc.Toggle);
if (t.isChecked) { if (t.isChecked) {
right = ch; right = ch;
rightIdx = idx; rightIdx = idx;
if (circle_lift) circle_lift.opacity = 255;
} else {
if (circle_lift) circle_lift.opacity = 0;
} }
}); });
if (!lift || !right) return; if (!lift || !right) return;
if (lift.data.id == right.data.id) { if (lift.data.id == right.data.id) {
console.log("匹配成功!···") console.log("匹配成功!···")
lift.getComponent(cc.Toggle).interactable = false;
right.getComponent(cc.Toggle).interactable = false;
this.drawLine(lift, right); this.drawLine(lift, right);
} else { } else {
pg.audio.playAudio(this.wrongClip, () => { pg.audio.playAudio(this.wrongClip, () => {
}); });
this.rotateShake(lift, 0.5); this.rotateShake(lift, 0.5);
this.rotateShake(right, 0.5); this.rotateShake(right, 0.5);
this.resetLayout();
} }
}
private resetLayout() {
let liftLayout = cc.find("lift", this.node);
let rightLayout = cc.find("right", this.node);
liftLayout.children.forEach((ch) => { liftLayout.children.forEach((ch) => {
let t = ch.getComponent(cc.Toggle); let t = ch.getComponent(cc.Toggle);
t.isChecked = false; t.isChecked = false;
let circle_right = ch.getChildByName("circle_right");
if (circle_right) circle_right.opacity = 0;
}); });
rightLayout.children.forEach((ch) => { rightLayout.children.forEach((ch) => {
let t = ch.getComponent(cc.Toggle); let t = ch.getComponent(cc.Toggle);
t.isChecked = false; t.isChecked = false;
let circle_lift = ch.getChildByName("circle_lift");
if (circle_lift) circle_lift.opacity = 0;
}); });
} }
private showAniFlower(target) { private showAniFlower(target) {
if (!target.getComponent(cc.Toggle).interactable) return;
let pos = target.convertToWorldSpaceAR(cc.Vec2.ZERO); let pos = target.convertToWorldSpaceAR(cc.Vec2.ZERO);
let pos2 = this.node.convertToNodeSpaceAR(pos); let pos2 = this.node.convertToNodeSpaceAR(pos);
let ani_flower = cc.instantiate(this.ani_flower); let ani_flower = cc.instantiate(this.ani_flower);
...@@ -464,16 +501,16 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -464,16 +501,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
drawLine(lift, right) { private drawLine(lift, right) {
let pos1 = null; let pos1 = null;
let pos2 = null; let pos2 = null;
// if (point1.type == 0) {
pos1 = lift.convertToWorldSpaceAR(cc.v2(lift.x + lift.width / 2 - 10, 0)); let circle_right = lift.getChildByName("circle_right");
pos2 = right.convertToWorldSpaceAR(cc.v2(right.x - right.width / 2, 0));
// } else { let circle_lift = right.getChildByName("circle_lift");
// pos1 = this.upOps.node.children[point2.lineIndex].convertToWorldSpaceAR(cc.v2(0, -85)); pos1 = circle_right.convertToWorldSpaceAR(cc.v2(- 10, 0));
// pos2 = this.downOps.node.children[point1.lineIndex].convertToWorldSpaceAR(cc.v2(0, 85)); pos2 = circle_lift.convertToWorldSpaceAR(cc.v2(10, 0));
// }
let graphics = cc.find("graphics", this.node).getComponent(cc.Graphics); let graphics = cc.find("graphics", this.node).getComponent(cc.Graphics);
...@@ -494,14 +531,24 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -494,14 +531,24 @@ export default class SceneComponent extends MyCocosSceneComponent {
graphics.moveTo(pos1.x, pos1.y); graphics.moveTo(pos1.x, pos1.y);
graphics.lineTo(pos2.x, pos2.y); graphics.lineTo(pos2.x, pos2.y);
graphics.stroke(); graphics.stroke();
this.resetLayout();
}, },
0.3 / 30, 0.3 / 30,
30 30
); );
this._drawIndex++; this._drawIndex++;
if (this._drawIndex >= this.data.item[this.roundIdx].group.length) {
this.scheduleOnce(() => {
this._drawIndex = 0;
graphics.clear();
this.roundIdx++;
this.showGame();
this.updateRound(); this.updateRound();
pg.event.emit("mouse_add"); pg.event.emit("mouse_add");
if (this._drawIndex >= this.data.item.group.length) { }, 1);
}
}
private gameOver() {
setTimeout(() => { setTimeout(() => {
let mouse_end = pg.view.find(this, "mouse_end"); let mouse_end = pg.view.find(this, "mouse_end");
mouse_end.active = true; mouse_end.active = true;
...@@ -509,7 +556,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -509,7 +556,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
}) })
}, 1800); }, 1800);
} }
}
private updateItemWidth(layout: cc.Node) { private updateItemWidth(layout: cc.Node) {
let width = 0; let width = 0;
layout.children.forEach((ch) => { layout.children.forEach((ch) => {
...@@ -521,7 +567,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -521,7 +567,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}); });
} }
private getItemNode(type) { private getItemNode(type, isSpY = false) {
let item; let item;
if (this.upArr.length == 5) { if (this.upArr.length == 5) {
if (type == 1) { if (type == 1) {
...@@ -531,9 +577,11 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -531,9 +577,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
} else if (this.upArr.length == 4) { } else if (this.upArr.length == 4) {
if (type == 1) { if (type == 1) {
item = cc.instantiate(cc.find("items/type5", this.node)); if (isSpY) item = cc.instantiate(cc.find("items/type1", this.node));
else item = cc.instantiate(cc.find("items/type5", this.node));
} else { } else {
item = cc.instantiate(cc.find("items/type5", this.node)); if (isSpY) item = cc.instantiate(cc.find("items/type4", this.node));
else item = cc.instantiate(cc.find("items/type5", this.node));
} }
} else if (this.upArr.length == 3) { } else if (this.upArr.length == 3) {
if (type == 1) { if (type == 1) {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// "text": "This is a test label.", // "text": "This is a test label.",
// "audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3" // "audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3"
// } // }
export const defaultData ={ export const defaultData = {
"aniEnter": { "aniEnter": {
"skeJsonData": {}, "skeJsonData": {},
"texJsonData": {}, "texJsonData": {},
...@@ -12,162 +12,237 @@ export const defaultData ={ ...@@ -12,162 +12,237 @@ export const defaultData ={
"audioUrl": null, "audioUrl": null,
"time": 1 "time": 1
}, },
"item": { "item": [{
"group": [ "title": "ghjdhjghjsd",
// { "audio_title": "",
// "up": { "group": [{
// "type": 1, "up": {
// "pic_url": "http://staging-teach.cdn.ireadabc.com/e359730cf593c396a58e020333026fac.png", "type": 1,
// "text": "", "pic_url": "",
// "audio_url": "" "text": "34534",
// }, "audio_url": ""
// "down": { },
// "type": 1, "down": {
// "pic_url": "http://staging-teach.cdn.ireadabc.com/6689e11c1646fba838a51c212b7770d2.png", "type": 1,
// "text": "第三位发送到gdfkgdfgdfgdf", "pic_url": "",
// "audio_url": "http://staging-teach.cdn.ireadabc.com/71348a317c47ec2a0b3056b0d7ca2e99.mp3" "text": "432",
// } "audio_url": ""
// }, }
// { }, {
// "up": { "up": {
// "type": 0, "type": 1,
// "pic_url": "http://staging-teach.cdn.ireadabc.com/e359730cf593c396a58e020333026fac.png", "pic_url": "",
// "text": "2", "text": "hjky",
// "audio_url": "" "audio_url": ""
// }, },
// "down": { "down": {
// "type": 1, "type": 1,
// "pic_url": "", "pic_url": "",
// "text": "4534543", "text": "312",
// "audio_url": "http://staging-teach.cdn.ireadabc.com/526624b47ba5e46f698add9e152a4b4e.mp3" "audio_url": ""
// } }
// }, }, {
"up": {
"type": 1,
"pic_url": "",
"text": "jkllkl",
"audio_url": ""
},
"down": {
"type": 1,
"pic_url": "",
"text": "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkk",
"audio_url": ""
}
},
{ {
"up": { "up": {
"type": 0, "type": 1,
"pic_url": "http://staging-teach.cdn.ireadabc.com/bcc13bb8f504b17ee9d07d8f5204b12f.png", "pic_url": "",
"text": "2", "text": "郭德付个",
"audio_url": "" "audio_url": ""
}, },
"down": { "down": {
"type": 1, "type": 1,
"pic_url": "", "pic_url": "",
"text": "萨大师赛所", "text": "能不能看",
"audio_url": "" "audio_url": ""
} }
}, },
{ {
"up": {
"type": 1,
"pic_url": "",
"text": "女包",
"audio_url": ""
},
"down": {
"type": 1,
"pic_url": "",
"text": "牛牛斯蒂芬",
"audio_url": ""
}
}
]
}, {
"title": "非凡哥的",
"audio_title": "",
"group": [{
"up": { "up": {
"type": 0, "type": 0,
"pic_url": "http://staging-teach.cdn.ireadabc.com/b84efeac2d0bc3f32f1dffb6734aeea6.png", "pic_url": "http://staging-teach.cdn.ireadabc.com/6693ddf8840e95046b8c726c6ba6ca54.png",
"text": "4", "text": "",
"audio_url": "" "audio_url": ""
}, },
"down": { "down": {
"type": 1, "type": 1,
"pic_url": "", "pic_url": "",
"text": "那边不谷歌包", "text": "就认识的方法的",
"audio_url": "http://staging-teach.cdn.ireadabc.com/9df3f14bc88bcffc49b6717c40428ed8.mp3" "audio_url": ""
} }
}, {
"up": {
"type": 0,
"pic_url": "http://staging-teach.cdn.ireadabc.com/6689e11c1646fba838a51c212b7770d2.png",
"text": "",
"audio_url": ""
}, },
{ "down": {
"type": 1,
"pic_url": "",
"text": "跟换成",
"audio_url": ""
}
}, {
"up": { "up": {
"type": 0, "type": 0,
"pic_url": "http://staging-teach.cdn.ireadabc.com/ce43980b533f674f9debe6ce9cae7b8d.png", "pic_url": "http://staging-teach.cdn.ireadabc.com/e359730cf593c396a58e020333026fac.png",
"text": "5", "text": "",
"audio_url": ""
},
"down": {
"type": 1,
"pic_url": "",
"text": "兰陵缭乱",
"audio_url": ""
}
}, {
"up": {
"type": 0,
"pic_url": "http://staging-teach.cdn.ireadabc.com/bcc13bb8f504b17ee9d07d8f5204b12f.png",
"text": "",
"audio_url": ""
},
"down": {
"type": 1,
"pic_url": "",
"text": "太多",
"audio_url": ""
}
}
]
}, {
"title": "搞明白发给",
"audio_title": "",
"group": [{
"up": {
"type": 1,
"pic_url": "",
"text": "非凡哥",
"audio_url": "" "audio_url": ""
}, },
"down": { "down": {
"type": 1, "type": 1,
"pic_url": "", "pic_url": "",
"text": "5345344343", "text": "湖广会馆",
"audio_url": "" "audio_url": ""
} }
}, {
"up": {
"type": 1,
"pic_url": "",
"text": "皇家公馆和",
"audio_url": ""
},
"down": {
"type": 1,
"pic_url": "",
"text": "十三道",
"audio_url": ""
} }
], }, {
"title": "电话客服劵花费电话客服劵花费电话客服劵花费电话客服劵花费电话客服劵花费", "up": {
"audio_title": "http://staging-teach.cdn.ireadabc.com/f7fb9f71ab7d460ac2f78c85efba7610.mp3" "type": 1,
"pic_url": "",
"text": "更方便",
"audio_url": ""
},
"down": {
"type": 1,
"pic_url": "",
"text": "不女",
"audio_url": ""
} }
} }
]
// { }, {
// "aniEnter": { "title": "工本费播放码",
// "skeJsonData": {}, "audio_title": "",
// "texJsonData": {}, "group": [{
// "texPngData": {}, "up": {
// "audioUrl": "http://staging-teach.cdn.ireadabc.com/526624b47ba5e46f698add9e152a4b4e.mp3", "type": 0,
// "time": 1 "pic_url": "http://staging-teach.cdn.ireadabc.com/7ab9b9239675038288b09ca3525e111e.png",
// }, "text": "",
// "item": { "audio_url": ""
// "group": [{ },
// "up": { "down": {
// "type": 1, "type": 0,
// "pic_url": "", "pic_url": "http://staging-teach.cdn.ireadabc.com/7ab9b9239675038288b09ca3525e111e.png",
// "text": "1", "text": "",
// "audio_url": "" "audio_url": ""
// }, }
// "down": { }, {
// "type": 1, "up": {
// "pic_url": "", "type": 0,
// "text": "第三位发送到", "pic_url": "http://staging-teach.cdn.ireadabc.com/bcc13bb8f504b17ee9d07d8f5204b12f.png",
// "audio_url": "" "text": "",
// } "audio_url": ""
// }, { },
// "up": { "down": {
// "type": 1, "type": 0,
// "pic_url": "", "pic_url": "http://staging-teach.cdn.ireadabc.com/bcc13bb8f504b17ee9d07d8f5204b12f.png",
// "text": "2", "text": "",
// "audio_url": "" "audio_url": ""
// }, }
// "down": { }, {
// "type": 1, "up": {
// "pic_url": "", "type": 0,
// "text": "4534543", "pic_url": "http://staging-teach.cdn.ireadabc.com/b84efeac2d0bc3f32f1dffb6734aeea6.png",
// "audio_url": "http://staging-teach.cdn.ireadabc.com/526624b47ba5e46f698add9e152a4b4e.mp3" "text": "",
// } "audio_url": ""
// }, { },
// "up": { "down": {
// "type": 1, "type": 0,
// "pic_url": "", "pic_url": "http://staging-teach.cdn.ireadabc.com/b84efeac2d0bc3f32f1dffb6734aeea6.png",
// "text": "3", "text": "",
// "audio_url": "" "audio_url": ""
// }, }
// "down": { }, {
// "type": 1, "up": {
// "pic_url": "", "type": 0,
// "text": "萨大师赛所", "pic_url": "http://staging-teach.cdn.ireadabc.com/ce43980b533f674f9debe6ce9cae7b8d.png",
// "audio_url": "" "text": "",
// } "audio_url": ""
// }, { },
// "up": { "down": {
// "type": 1, "type": 0,
// "pic_url": "", "pic_url": "http://staging-teach.cdn.ireadabc.com/ce43980b533f674f9debe6ce9cae7b8d.png",
// "text": "4", "text": "",
// "audio_url": "" "audio_url": ""
// }, }
// "down": { }
// "type": 1, ]
// "pic_url": "", }
// "text": "那边不谷歌包", ]
// "audio_url": "" }
// }
// }, {
// "up": {
// "type": 1,
// "pic_url": "",
// "text": "5",
// "audio_url": ""
// },
// "down": {
// "type": 1,
// "pic_url": "",
// "text": "5345344343",
// "audio_url": ""
// }
// }
// ],
// "title": "电话客服劵花费",
// "audio_title": "http://staging-teach.cdn.ireadabc.com/f7fb9f71ab7d460ac2f78c85efba7610.mp3"
// }
// }
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