Commit cb223069 authored by Chen Jiping's avatar Chen Jiping

优化

parent d7e354d2
...@@ -54,10 +54,10 @@ ...@@ -54,10 +54,10 @@
<tr *ngFor="let data of answersTable.data;let j = index"> <tr *ngFor="let data of answersTable.data;let j = index">
<td>{{j+1}}</td> <td>{{j+1}}</td>
<td> <td>
<nz-select [(ngModel)]="data.contentType" nzPlaceHolder="请选择" (ngModelChange)="setAnswerType($event, data)"> <nz-radio-group [(ngModel)]="data.contentType" (ngModelChange)="setAnswerType($event, data)">
<nz-option nzValue="T" nzLabel="文字"></nz-option> <label nz-radio nzValue="T">文字</label>
<nz-option nzValue="P" nzLabel="图片"></nz-option> <label nz-radio nzValue="P">图片</label>
</nz-select> </nz-radio-group>
</td> </td>
<td> <td>
<div *ngIf="data.contentType == 'P'"> <div *ngIf="data.contentType == 'P'">
......
...@@ -83,8 +83,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -83,8 +83,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
*/ */
save() { save() {
(<any> window).courseware.setData(this.item, null, this.saveKey); (<any> window).courseware.setData(this.item, null, this.saveKey);
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh(); this.refresh();
} }
......
...@@ -5,7 +5,7 @@ import { ...@@ -5,7 +5,7 @@ import {
Label Label
} from './Unit'; } from './Unit';
export class Exercise{ export class Exercise {
exercise; exercise;
...@@ -13,24 +13,30 @@ export class Exercise{ ...@@ -13,24 +13,30 @@ export class Exercise{
answers = []; answers = [];
constructor(exercise){ constructor(exercise) {
this.exercise = exercise; this.exercise = exercise;
} }
addAnswer(answer : Answer){ addAnswer(answer: Answer) {
this.answers.push(answer); this.answers.push(answer);
} }
set listeningAudio(audio){ set listeningAudio(audio) {
this._listeningAudio = audio; this._listeningAudio = audio;
} }
get listeningAudio(){ get listeningAudio() {
return this._listeningAudio; return this._listeningAudio;
} }
reset() {
for (let i = 0; i < this.answers.length; ++i) {
this.answers[i].reset();
}
}
} }
export class Answer{ export class Answer {
bg; bg;
...@@ -54,7 +60,7 @@ export class Answer{ ...@@ -54,7 +60,7 @@ export class Answer{
selected = false; selected = false;
constructor(images, answerContent){ constructor(images, answerContent) {
this.images = images; this.images = images;
...@@ -100,7 +106,7 @@ export class Answer{ ...@@ -100,7 +106,7 @@ export class Answer{
let scale = Math.min((parItem.height - 15 * this.scaleX) / h, (parItem.width - 15 * this.scaleY) / w); let scale = Math.min((parItem.height - 15 * this.scaleX) / h, (parItem.width - 15 * this.scaleY) / w);
//如果小于1,则缩放图片 //如果小于1,则缩放图片
if(scale < 1){ if (scale < 1) {
content_pic.setScaleXY(scale); content_pic.setScaleXY(scale);
} }
...@@ -140,11 +146,11 @@ export class Answer{ ...@@ -140,11 +146,11 @@ export class Answer{
} }
getWidth(){ getWidth() {
return 234 * this.scaleX; return 234 * this.scaleX;
} }
getHeight(){ getHeight() {
return 178 * this.scaleY; return 178 * this.scaleY;
} }
...@@ -181,21 +187,21 @@ export class Answer{ ...@@ -181,21 +187,21 @@ export class Answer{
* @param callback * @param callback
*/ */
moveOut(toX, toY, callback = null) { moveOut(toX, toY, callback = null) {
if (this.contentType == 'T') { if (this.contentType == 'T') {
this.bg.x = toX; this.bg.x = toX;
this.bg.y = toY; this.bg.y = toY;
tweenChange(this.contentSprite, { alpha: 0 }, 0.3, callback); tweenChange(this.contentSprite, { alpha: 0 }, 0.3, callback);
} }
else if (this.contentType == 'P') { else if (this.contentType == 'P') {
this.bg.x = toX; this.bg.x = toX;
this.bg.y = toY; this.bg.y = toY;
tweenChange(this.contentSprite, { alpha: 0 }, 0.3, callback); tweenChange(this.contentSprite, { alpha: 0 }, 0.3, callback);
} }
} }
reset(){ reset() {
this.selected = false; this.selected = false;
} }
} }
\ No newline at end of file
...@@ -713,16 +713,18 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -713,16 +713,18 @@ export class PlayComponent implements OnInit, OnDestroy {
return box; return box;
} }
const midBox = initBox('mid');
midBox.boxBg.x = (this.canvasWidth - midBox.boxBg.width) / 2;
this.midBox = midBox;
const rightBox = initBox('right'); const rightBox = initBox('right');
rightBox.boxBg.x = 869 * this.mapScale; rightBox.boxBg.x = midBox.boxBg.x + 99 * this.mapScale + midBox.boxBg.width;
this.rightBox = rightBox; this.rightBox = rightBox;
const midBox = initBox('mid');
midBox.boxBg.x = 506 * this.mapScale;
this.midBox = midBox;
const leftBox = initBox('left'); const leftBox = initBox('left');
leftBox.boxBg.x = 133 * this.mapScale; leftBox.boxBg.x = midBox.boxBg.x - 99 * this.mapScale - rightBox.boxBg.width;
this.leftBox = leftBox; this.leftBox = leftBox;
} }
...@@ -809,6 +811,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -809,6 +811,10 @@ export class PlayComponent implements OnInit, OnDestroy {
initGame() { initGame() {
for (let i = 0; i < this.exerciseArr.length; ++i) {
this.exerciseArr[i].reset();
}
this.tempExerciseArr = randomSortByArr(this.exerciseArr); this.tempExerciseArr = randomSortByArr(this.exerciseArr);
this.lemonArr = []; this.lemonArr = [];
...@@ -905,6 +911,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -905,6 +911,8 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
if (this.checkClickTarget(this.restartBtn.bg)) { if (this.checkClickTarget(this.restartBtn.bg)) {
this.canTouch = false;
this.restartBtn.click(() => { this.restartBtn.click(() => {
this.player.reset(); this.player.reset();
......
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