Commit f5a3c159 authored by yu's avatar yu

6.27调整

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