Commit 40333b34 authored by Chen Jiping's avatar Chen Jiping

feat:增加默认值,调整卡片切换方式

parent 4a413a6e
......@@ -15,15 +15,15 @@ export class Exercises {
overturnPic;
bigCard : ShapeRect;
bigCard: ShapeRect;
leftAnswer;
rightAnswer;
frontCard : ShapeRect;
frontCard: ShapeRect;
backCard :ShapeRect;
backCard: ShapeRect;
answerLabel: Label2;
......@@ -105,26 +105,27 @@ export class Exercises {
index.textAlign = 'center';
index.fontSize = 36;
index.fontName = "GOTHICB";
index.fontColor = "#567790";
index.fontColor = "#567790";
index.setScaleXY(this.scaleX);
index.refreshSize();
index.x = 0;
index.y = 0 +4 * this.scaleY;
index.y = 0 + 4 * this.scaleY;
indexBg.addChild(index);
index.alpha = 1;
this.indexLabel = index;
}
initCard(){
initCard() {
let w = 1000 * this.scaleX;
let h = 600 * this.scaleY
const bigCard = new ShapeRect();
bigCard.anchorX = 0.5;
bigCard.setSize(w, h);
bigCard.fillColor = "#ffffff";
bigCard.setShadow(0, 10,20, "rgba(0, 0, 0, 0.5)");
bigCard.setShadow(0, 10, 20, "rgba(0, 0, 0, 0.5)");
this.bigCard = bigCard;
this.initAnswer();
......@@ -136,7 +137,7 @@ export class Exercises {
this.closePic = this.getColsePic(bigCard);
this.overturnPic = this.getOverturnPic(bigCard);
bigCard.setScaleXY(0);
}
......@@ -147,7 +148,7 @@ export class Exercises {
closePic.scaleX = this.scaleX;
closePic.scaleY = this.scaleY;
closePic.x = parent.width;
closePic.x = parent.width / 2;
closePic.y = 0;
parent.addChild(closePic);
......@@ -161,7 +162,7 @@ export class Exercises {
overturnPic.scaleX = this.scaleX;
overturnPic.scaleY = this.scaleY;
overturnPic.x = parent.width - 20 * this.scaleX - overturnPic.getBoundingBox().width / 2;
overturnPic.x = parent.width / 2 - 20 * this.scaleX - overturnPic.getBoundingBox().width / 2;
overturnPic.y = parent.height - 15 * this.scaleY - overturnPic.getBoundingBox().height / 2;
parent.addChild(overturnPic);
......@@ -174,7 +175,7 @@ export class Exercises {
let frontCard = new ShapeRect();
frontCard.setSize(this.bigCard.width, this.bigCard.height);
frontCard.alpha = 0;
frontCard.x = 0;
frontCard.x = -this.bigCard.width / 2;
frontCard.y = 0;
this.frontCard = frontCard;
this.bigCard.addChild(frontCard);
......@@ -183,7 +184,7 @@ export class Exercises {
let w = 386 * this.scaleX;
let startX = (this.bigCard.width - (dW + w * 2)) / 2;
let startX = (this.bigCard.width - (dW + w * 2)) / 2;
let leftAnswer = new ShapeRect();
this.getAnswerView(leftAnswer, this.data.leftAnswer);
......@@ -198,7 +199,7 @@ export class Exercises {
frontCard.addChild(rightAnswer);
}
getTextView(letterArr){
getTextView(letterArr) {
const getLabelText = (letter) => {
const text = new LabelText();
......@@ -259,13 +260,13 @@ export class Exercises {
answerBg.addChild(pic);
pic.x = w / 2;
if(answerData.letterArr && answerData.letterArr.length > 0){
if (answerData.letterArr && answerData.letterArr.length > 0) {
pic.y = h / 2 - 195 * this.scaleY + 257 * this.scaleY / 2;
const line = new ShapeRect();
line.setSize(180 * this.scaleX, 7 * this.scaleY);
line.fillColor = "#949494";
line.x = (w - line.width ) / 2;
line.x = (w - line.width) / 2;
line.y = h - line.height - 42 * this.scaleY;
answerBg.addChild(line);
answerBg.line = line;
......@@ -277,12 +278,12 @@ export class Exercises {
answerBg.addChild(text);
answerBg.text = text;
}
else{
else {
pic.y = h / 2;
}
}
initBackCard(){
initBackCard() {
let w = 960 * this.scaleX;
......@@ -292,7 +293,7 @@ export class Exercises {
backCard.setSize(w, h);
backCard.alpha = 0;
backCard.visible = false;
backCard.x = (this.bigCard.width - w)/ 2;
backCard.x = -w / 2;
backCard.y = (this.bigCard.height - h) / 2;
this.backCard = backCard;
this.bigCard.addChild(backCard);
......@@ -308,7 +309,7 @@ export class Exercises {
if (scale < 1) {
pic.setScaleXY(scale);
}
backCard.addChild(pic);
}
......@@ -374,11 +375,11 @@ export class Exercises {
tweenChange(this.bigCard, { scaleX: tempScaleX }, 0.3, () => {
if(this.curCard == this.frontCard){
if (this.curCard == this.frontCard) {
this.backCard.visible = true;
this.curCard = this.backCard;
}
else{
else {
this.frontCard.visible = true;
this.curCard = this.frontCard;
}
......@@ -419,13 +420,13 @@ export class Exercises {
this.backCard.visible = false;
}
if(this.leftAnswer.line){
if (this.leftAnswer.line) {
this.leftAnswer.line.alpha = 1;
this.leftAnswer.text.alpha = 0;
}
if(this.rightAnswer.line){
if (this.rightAnswer.line) {
this.rightAnswer.line.alpha = 1;
this.rightAnswer.text.alpha = 0;
......
......@@ -103,7 +103,11 @@ export class PlayComponent implements OnInit, OnDestroy {
if (data && typeof data == 'object') {
this.data = data;
}
console.log('data:', data);
else{
let defaultData = '{"title":{"part1":"C","part2":"Read and point"},"letterArr":[{"isFill":"0","val":"re-","audioUrl":"http://staging-teach.cdn.ireadabc.com/8b5ecca5d4509e1b8a7e81e69d8db615.mp3"},{"isFill":"0","val":"un-","audioUrl":"http://staging-teach.cdn.ireadabc.com/30621df106455523573e3871a5a5c598.mp3"},{"isFill":"0","val":"dis-","audioUrl":"http://staging-teach.cdn.ireadabc.com/b44fa51172b19b555fda30717c773027.mp3"}],"exercisesArr":[{"leftAnswer":{"letterArr":[{"isFill":"0","val":"heat"}],"audioUrl":"http://staging-teach.cdn.ireadabc.com/b62600fd1e72b54d1d1c3bc71b7361af.mp3","picUrl":"http://staging-teach.cdn.ireadabc.com/ce38e5043b8127f03a6829829148f76d.png"},"rightAnswer":{"letterArr":[{"isFill":"1","val":"re"},{"isFill":"0","val":"heat"}],"audioUrl":"http://staging-teach.cdn.ireadabc.com/b62600fd1e72b54d1d1c3bc71b7361af.mp3","picUrl":"http://staging-teach.cdn.ireadabc.com/9901fec296d715fcbee1e8bf19bb3228.png"},"card":{"picUrl":"http://staging-teach.cdn.ireadabc.com/a886b150e8792d433ced3672f4df7dfb.jpg","audioUrl":"http://staging-teach.cdn.ireadabc.com/f95fd3997cdd67abd51a1ab45efd855d.mp3"},"picUrl":"http://staging-teach.cdn.ireadabc.com/d58dcbde56d5868dab8021a7a7548c0d.png"},{"leftAnswer":{"letterArr":[{"isFill":"0","val":"heat"}],"picUrl":"http://staging-teach.cdn.ireadabc.com/ce38e5043b8127f03a6829829148f76d.png"},"rightAnswer":{"letterArr":[{"isFill":"1","val":"re"},{"isFill":"0","val":"heat"}],"picUrl":"http://staging-teach.cdn.ireadabc.com/9901fec296d715fcbee1e8bf19bb3228.png"},"card":{"picUrl":"http://staging-teach.cdn.ireadabc.com/10dab2d49188db958a6a6e6b3ab7b5f5.png","audioUrl":"http://staging-teach.cdn.ireadabc.com/a252c069d04f8e04f91b2a1394072f30.mp3"},"picUrl":"http://staging-teach.cdn.ireadabc.com/d58dcbde56d5868dab8021a7a7548c0d.png"},{"leftAnswer":{"letterArr":[{"isFill":"0","val":"heat"}],"picUrl":"http://staging-teach.cdn.ireadabc.com/ce38e5043b8127f03a6829829148f76d.png"},"rightAnswer":{"letterArr":[{"isFill":"1","val":"re"},{"isFill":"0","val":"heat"}],"picUrl":"http://staging-teach.cdn.ireadabc.com/9901fec296d715fcbee1e8bf19bb3228.png"},"card":{"picUrl":"http://staging-teach.cdn.ireadabc.com/9fb5a33ee489517de5f2a2cf2d926a32.jpg","audioUrl":"http://staging-teach.cdn.ireadabc.com/30621df106455523573e3871a5a5c598.mp3"},"picUrl":"http://staging-teach.cdn.ireadabc.com/d58dcbde56d5868dab8021a7a7548c0d.png"},{"leftAnswer":{"letterArr":[{"isFill":"0","val":"heat"}],"picUrl":"http://staging-teach.cdn.ireadabc.com/10dab2d49188db958a6a6e6b3ab7b5f5.png"},"rightAnswer":{"letterArr":[{"isFill":"1","val":"re"},{"isFill":"0","val":"heat"}],"picUrl":"http://staging-teach.cdn.ireadabc.com/cb6a2f948c3febbb7881e6b6a7417811.png"},"card":{"picUrl":"http://staging-teach.cdn.ireadabc.com/3883964c48ea76d6a08386dfe1bf1204.jpg","audioUrl":"http://staging-teach.cdn.ireadabc.com/30621df106455523573e3871a5a5c598.mp3"},"picUrl":"http://staging-teach.cdn.ireadabc.com/d58dcbde56d5868dab8021a7a7548c0d.png"}],"audioUrl":"http://staging-teach.cdn.ireadabc.com/919b2c150b41b3306869ebe78ecb70b3.mp3"}';
this.data = JSON.parse(defaultData);
}
//console.log('data:', JSON.stringify(data));
// 初始化 各事件监听
this.initListener();
......@@ -825,7 +829,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.bigCardRenderArr.push(exer.bigCard);
}
exer.showBigCard((this.canvasWidth - exer.bigCard.width) / 2, (this.canvasHeight - exer.bigCard.height) / 2, () => {
exer.showBigCard(this.canvasWidth / 2, (this.canvasHeight - exer.bigCard.height) / 2, () => {
//将其它词组设置为不可点击
for (let j = 0; j < this.exercisesArr.length; ++j) {
......
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