Commit f5a3c159 authored by yu's avatar yu

6.27调整

parent e8ce17ba
...@@ -83,6 +83,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -83,6 +83,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.view.touchOn(topTitle, this.playTopLaba, this); pg.view.touchOn(topTitle, this.playTopLaba, this);
// let btn_check = cc.find("btn_check", this.node); // let btn_check = cc.find("btn_check", this.node);
// pg.view.touchOn(btn_check, this.touchOver, this); // pg.view.touchOn(btn_check, this.touchOver, this);
this.showQuestion();
this.showGame(); this.showGame();
} }
private touchOver() { private touchOver() {
...@@ -93,9 +94,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -93,9 +94,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.playLocalAudio("finish"); this.playLocalAudio("finish");
let btn_check = cc.find("btn_check", this.node); let btn_check = cc.find("btn_check", this.node);
btn_check.getComponent(cc.Button).interactable = true; btn_check.getComponent(cc.Button).interactable = true;
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;
mouse_end.getComponent("mrbr04_mouse_end").play().then(() => { // mouse_end.getComponent("mrbr04_mouse_end").play().then(() => {
//结算 //结算
let data: any = {}; let data: any = {};
let questions = this.logs.concat(); let questions = this.logs.concat();
...@@ -107,7 +108,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -107,7 +108,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
data.score = score; data.score = score;
console.log(data); console.log(data);
onHomeworkFinish(); onHomeworkFinish();
}) // })
}, 1800); }, 1800);
} }
private showGame() { private showGame() {
...@@ -118,17 +119,18 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -118,17 +119,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.randomData(); this.randomData();
this.showQuestion();
this.showLayout(); this.showLayout();
} }
private showQuestion() { private showQuestion() {
let quest = this.data.questions[this.roundIdx]; let quest = this.data.top;
let desc = cc.find("top/topTitle/title", this.node); let desc = cc.find("top/topTitle/title", this.node);
let img = cc.find("top/boy", this.node);
desc.active = true; desc.active = true;
desc.getComponent(cc.Label).string = quest.text; desc.getComponent(cc.Label).string = quest.text;
if (quest.questionAudio) { if (quest.audio) {
this.playTopLaba() this.playTopLaba()
} }
pg.view.setNetImg(img, quest.image, { w: 70, h: 70 });
} }
private intervalId; private intervalId;
private playTopLaba() { private playTopLaba() {
...@@ -151,8 +153,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -151,8 +153,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
}, 150) }, 150)
let quest = this.data.questions[this.roundIdx]; let quest = this.data.top;
quest.questionAudio && pg.audio.playAudioByUrl(quest.questionAudio).then(() => { stop = true; }) quest.audio && pg.audio.playAudioByUrl(quest.audio).then(() => { stop = true; })
} }
private randomData() { private randomData() {
...@@ -273,7 +275,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -273,7 +275,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}); });
} }
item.on(cc.Node.EventType.TOUCH_END, () => { item.on(cc.Node.EventType.TOUCH_END, () => {
if (item.touch == touchState.FINISH) return; // if (item.touch == touchState.FINISH) return;
this.playLocalAudio("btn"); this.playLocalAudio("btn");
this.playLaba(item); this.playLaba(item);
this.updateClickImg(item.parent, data.id); this.updateClickImg(item.parent, data.id);
...@@ -301,7 +303,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -301,7 +303,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
item.y = 0; item.y = 0;
// item.opacity = 0.1; // item.opacity = 0.1;
item.on(cc.Node.EventType.TOUCH_END, () => { item.on(cc.Node.EventType.TOUCH_END, () => {
if (item.touch == touchState.FINISH) return; // if (item.touch == touchState.FINISH) return;
this.playLocalAudio("btn"); this.playLocalAudio("btn");
this.playLaba(item); this.playLaba(item);
this.updateClickImg(item.parent, data.id); this.updateClickImg(item.parent, data.id);
...@@ -314,7 +316,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -314,7 +316,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private updateClickImg(layout, id) { private updateClickImg(layout, id) {
layout.children.forEach((item) => { layout.children.forEach((item) => {
if (!item.data) return; if (!item.data) return;
if (item.touch == touchState.FINISH) return; // if (item.touch == touchState.FINISH) return;
let select = cc.find("select", item); let select = cc.find("select", item);
let normal = cc.find("normal", item); let normal = cc.find("normal", item);
let finish = cc.find("finish", item); let finish = cc.find("finish", item);
...@@ -322,8 +324,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -322,8 +324,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
item.touch = touchState.SELECT; item.touch = touchState.SELECT;
select.active = true; select.active = true;
normal.active = false; normal.active = false;
finish.active = false;
} else { } else {
item.touch = touchState.NORMAL; item.touch = item.touch == touchState.FINISH ? touchState.FINISH : touchState.NORMAL;
select.active = false; select.active = false;
normal.active = true; normal.active = true;
} }
...@@ -361,11 +364,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -361,11 +364,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
}); });
if (!lift || !right) return; if (!lift || !right) return;
if (lift.data.id == right.data.id) { // if (lift.data.id == right.data.id) {
let isRight = lift.data.id == right.data.id;
this.playLocalAudio("check") this.playLocalAudio("check")
console.log("匹配成功!···") console.log("匹配成功!···")
lift.touch = touchState.FINISH;
right.touch = touchState.FINISH;
lift.getComponent(cc.Button).interactable = false; lift.getComponent(cc.Button).interactable = false;
right.getComponent(cc.Button).interactable = false; right.getComponent(cc.Button).interactable = false;
this.drawLine(lift, right); this.drawLine(lift, right);
...@@ -379,23 +381,23 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -379,23 +381,23 @@ export default class SceneComponent extends MyCocosSceneComponent {
log.option = Game.getIns().getDataByPage(this.roundIdx); log.option = Game.getIns().getDataByPage(this.roundIdx);
// log.submit = datas; // log.submit = datas;
log.isRight = true; log.isRight = true;
log.score += Game.getIns().score; log.score = isRight ? log.score += Game.getIns().score : log.score += 0;
} else { } else {
this.logs.push({ this.logs.push({
option: Game.getIns().getDataByPage(this.roundIdx), option: Game.getIns().getDataByPage(this.roundIdx),
// submit: datas, // submit: datas,
isRight: true, isRight: true,
score: Game.getIns().score score: isRight ? Game.getIns().score : 0
}) })
} }
} 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(); // this.resetLayout();
} // }
} }
private resetLayout() { private resetLayout() {
...@@ -426,7 +428,35 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -426,7 +428,35 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (circle_lift) circle_lift.opacity = 0; if (circle_lift) circle_lift.opacity = 0;
}); });
} }
private resetLeftCardStateById(id) {
this.layout_left.children.forEach((item) => {
if (item.data.id == id) {
item.touch = touchState.NORMAL;
let select = cc.find("select", item);
let normal = cc.find("normal", item);
let finish = cc.find("finish", item);
normal.active = true;
select.active = false;
finish.active = false;
return;
}
});
}
private resetRightCardStateById(id) {
this.layout_right.children.forEach((item) => {
if (item.data.id == id) {
item.touch = touchState.NORMAL;
let select = cc.find("select", item);
let normal = cc.find("normal", item);
let finish = cc.find("finish", item);
normal.active = true;
select.active = false;
finish.active = false;
return;
}
});
}
private rotateShake(item, rate = 1) { private rotateShake(item, rate = 1) {
const time = 0.9; const time = 0.9;
...@@ -441,8 +471,27 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -441,8 +471,27 @@ export default class SceneComponent extends MyCocosSceneComponent {
.start(); .start();
} }
private cleanLine(id, type) {
this.graphicsArr.forEach((gs, idx) => {
if (type == 1 && gs.data.left == id) {
gs.getComponent(cc.Graphics).clear();
this.graphicsArr.splice(idx, 1);
gs.parent = null;
gs.destroy();
this.resetLeftCardStateById(gs.data.left);
this.resetRightCardStateById(gs.data.right);
}
if (type == 0 && gs.data.right == id) {
gs.getComponent(cc.Graphics).clear();
this.graphicsArr.splice(idx, 1);
gs.parent = null;
gs.destroy();
this.resetRightCardStateById(gs.data.right);
this.resetLeftCardStateById(gs.data.left);
}
})
}
private graphicsArr = [];
private drawLine(lift, right) { private drawLine(lift, right) {
let pos1 = null; let pos1 = null;
let pos2 = null; let pos2 = null;
...@@ -454,14 +503,23 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -454,14 +503,23 @@ export default class SceneComponent extends MyCocosSceneComponent {
pos2 = circle_lift.convertToWorldSpaceAR(cc.v2(10, 0)); pos2 = circle_lift.convertToWorldSpaceAR(cc.v2(10, 0));
let graphics = cc.find("graphics", this.node).getComponent(cc.Graphics); this.cleanLine(lift.data.id, 1);
this.cleanLine(right.data.id, 0);
lift.touch = touchState.FINISH;
right.touch = touchState.FINISH;
let graphicsNode = cc.instantiate(cc.find("graphics", this.node));
let graphics = graphicsNode.getComponent(cc.Graphics);
graphicsNode.data = { left: lift.data.id, right: right.data.id };
let color = this._colors[this._drawIndex]; let color = this._colors[this.graphicsArr.length];
graphics.strokeColor = new cc.Color().fromHEX(color); graphics.strokeColor = new cc.Color().fromHEX(color);
// let line = [point1, point2, color]; // let line = [point1, point2, color];
// this.lined.push(line); // this.lined.push(line);
this.graphicsArr.push(graphicsNode);
this.node.addChild(graphicsNode, 5);
let group_item = cc.find("group_item", this.node);
group_item.zIndex = 99;
let deltaY = pos1.y - pos2.y; let deltaY = pos1.y - pos2.y;
let drawX = pos1.x + 1; let drawX = pos1.x + 1;
let drawY = pos1.y + 1; let drawY = pos1.y + 1;
...@@ -487,11 +545,18 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -487,11 +545,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.resetLayout(); this.resetLayout();
}, 0.15); }, 0.15);
this._drawIndex++; this._drawIndex++;
if (this._drawIndex >= this.data.questions[this.roundIdx].options.length) { if (this.graphicsArr.length >= this.data.questions[this.roundIdx].options.length) {
this.scheduleOnce(() => { this.scheduleOnce(() => {
this._drawIndex = 0; this._drawIndex = 0;
this.roundIdx++; this.roundIdx++;
if (this.roundIdx < this.data.questions.length) graphics.clear(); if (this.roundIdx < this.data.questions.length) {
this.graphicsArr.forEach((gs, idx) => {
gs.getComponent(cc.Graphics).clear();
gs.parent = null;
gs.destroy();
})
this.graphicsArr.length = 0;
}
this.showGame(); this.showGame();
// this.updateRound(); // this.updateRound();
// pg.event.emit("mouse_add"); // pg.event.emit("mouse_add");
......
export const defaultData = { export const defaultData = {
"score": 0, "score": 5,
"top": { "top": {
"image": "", "image": "http://staging-teach.cdn.ireadabc.com/00557f0ccc97e8396a3512a11def67bc.png",
"text": "1", "text": "wha",
"audio": "" "audio": "http://staging-teach.cdn.ireadabc.com/65c62cd89703cce9cec9c68b41b92f5d_l.mp3"
}, },
"questions": [ "questions": [
{ {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -80,11 +80,11 @@ ...@@ -80,11 +80,11 @@
<input type="text" nz-input [(ngModel)]="item.score" (blur)="save()"> <input type="text" nz-input [(ngModel)]="item.score" (blur)="save()">
<span style="font-size: 20px;">标题文字: </span> <span style="font-size: 20px;">标题文字: </span>
<input type="text" nz-input [(ngModel)]="item.top.text" (blur)="save()"> <input type="text" nz-input [(ngModel)]="item.top.text" (blur)="save()">
<!-- <span style="font-size: 20px;">标题图片: </span> <span style="font-size: 20px;">标题图片: </span>
<div style="width:300px"> <div style="width:300px">
<app-upload-image-with-preview [picUrl]="item.top.image" <app-upload-image-with-preview [picUrl]="item.top.image"
(imageUploaded)="onImageUploadSuccess($event,'image', item.top)"></app-upload-image-with-preview> (imageUploaded)="onImageUploadSuccess($event,'image', item.top)"></app-upload-image-with-preview>
</div> --> </div>
<span style="font-size: 20px;">标题音频: </span> <span style="font-size: 20px;">标题音频: </span>
<div style="display:flex ;"> <div style="display:flex ;">
<div> <div>
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
</div> </div>
<div class="option-text"> <!-- <div class="option-text">
<div class="word-input-title"> <div class="word-input-title">
<span style="color:red;margin-left:-15px">* </span> <span style="color:red;margin-left:-15px">* </span>
<span>题干文字: </span> <span>题干文字: </span>
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
</span> </span>
</div> </div>
</div> </div>
</div> </div> -->
<!-- <div class="option-img"> <!-- <div class="option-img">
<div class="word-input-title"> <div class="word-input-title">
......
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