Commit fb2533ce authored by yu's avatar yu

调整

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