Commit 44390a77 authored by Chen Jiping's avatar Chen Jiping

feat:支持缩放位置调整

parent 81b80e23
...@@ -8,6 +8,9 @@ export class ExercisesBean extends Obj{ ...@@ -8,6 +8,9 @@ export class ExercisesBean extends Obj{
//单词数组 //单词数组
word2Arr = []; word2Arr = [];
//放大位置:默认首字母
zoomIn = '0';
} }
export function getDefaultExercises(){ export function getDefaultExercises(){
......
...@@ -123,6 +123,15 @@ ...@@ -123,6 +123,15 @@
</button> </button>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="2">放大位置</nz-form-label>
<nz-form-control [nzSpan]="4">
<nz-radio-group [(ngModel)]="item.exercises.zoomIn" (ngModelChange)="save()">
<label nz-radio nzValue="0">首字母</label>
<label nz-radio nzValue="1">尾字母</label>
</nz-radio-group>
</nz-form-control>
</nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-control [nzOffset]="2" [nzSpan]="15"> <nz-form-control [nzOffset]="2" [nzSpan]="15">
<nz-table #wordTable2 nzBordered [nzData]="item.exercises.word2Arr" nzBordered nzTitle="单词数组" <nz-table #wordTable2 nzBordered [nzData]="item.exercises.word2Arr" nzBordered nzTitle="单词数组"
......
...@@ -76,6 +76,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -76,6 +76,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
if(!this.item.exercises.word2Arr){ if(!this.item.exercises.word2Arr){
this.item.exercises.word2Arr = []; this.item.exercises.word2Arr = [];
} }
if(!this.item.exercises.zoomIn){
this.item.exercises.zoomIn = "0";
this.save();
}
} }
......
...@@ -731,7 +731,7 @@ ...@@ -731,7 +731,7 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 880, "width": 500,
"height": 300 "height": 300
}, },
"_anchorPoint": { "_anchorPoint": {
...@@ -1263,7 +1263,7 @@ ...@@ -1263,7 +1263,7 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 300, "width": 250,
"height": 60 "height": 60
}, },
"_anchorPoint": { "_anchorPoint": {
......
...@@ -425,24 +425,54 @@ cc.Class({ ...@@ -425,24 +425,54 @@ cc.Class({
continue; continue;
} }
//首字母 if(this.data.exercises.zoomIn == '0'){
let initial = wordArr[i].val.substr(0, 1); //首字母
let label = this.getWord(initial, 80, true); let initial = wordArr[i].val.substr(0, 1);
label.isInitial = true; let label = this.getWord(initial, 80, true);
wordNodeArr.push(label); label.isInitial = true;
label.addComponent(cc.Button); label.zoomIn = true;
label.on('click', () => { wordNodeArr.push(label);
play(); label.addComponent(cc.Button);
}); label.on('click', () => {
play();
});
//其余字母
let last = wordArr[i].val.substr(1);
let lastLabel = this.getWord(last, 80, false);
lastLabel.isInitial = false;
wordNodeArr.push(lastLabel);
lastLabel.addComponent(cc.Button);
lastLabel.on('click', () => {
play();
});
}
else{
let len = wordArr[i].val.length;
//其余字母
let initial = wordArr[i].val.substr(0, len - 1);
let label = this.getWord(initial, 80, true);
label.isInitial = true;
wordNodeArr.push(label);
label.addComponent(cc.Button);
label.on('click', () => {
play();
});
//尾字母
let last = wordArr[i].val.substr(len - 1);
let lastLabel = this.getWord(last, 80, false);
lastLabel.isInitial = false;
lastLabel.zoomIn = true;
wordNodeArr.push(lastLabel);
lastLabel.addComponent(cc.Button);
lastLabel.on('click', () => {
play();
});
}
//其余字母
let last = wordArr[i].val.substr(1);
let lastLabel = this.getWord(last, 80, false);
wordNodeArr.push(lastLabel);
lastLabel.addComponent(cc.Button);
lastLabel.on('click', () => {
play();
});
} }
...@@ -631,7 +661,18 @@ cc.Class({ ...@@ -631,7 +661,18 @@ cc.Class({
let wordNodeArr = textNode.wordNodeArr let wordNodeArr = textNode.wordNodeArr
let wordNode = wordNodeArr[2 * index]; let _index = 0;
//首字母
if(this.data.exercises.zoomIn == '0'){
_index = 2 * index;
}
else{
_index = 2 * index + 1;
}
let wordNode = wordNodeArr[_index];
if (!wordNode) { if (!wordNode) {
...@@ -876,9 +917,10 @@ cc.Class({ ...@@ -876,9 +917,10 @@ cc.Class({
for (let i = 0; i < wordNodeArr.length; ++i) { for (let i = 0; i < wordNodeArr.length; ++i) {
let wordNode = wordNodeArr[i]; let wordNode = wordNodeArr[i];
console.log(wordNode.zoomIn);
//如果是放大字母,则执行动画
if (wordNode.zoomIn) {
//如果是首字母,则执行动画
if (wordNode.isInitial) {
this.textTwinkle(wordNode); this.textTwinkle(wordNode);
} }
} }
......
export const defaultData = { export const defaultData = {
"exercises":{ "exercises":{
"zoomIn":"1",
"wordArr":[ "wordArr":[
{ {
"val":"A", "val":"A",
...@@ -14,10 +15,10 @@ export const defaultData = { ...@@ -14,10 +15,10 @@ export const defaultData = {
], ],
"word2Arr":[ "word2Arr":[
{ {
"val":"Angry" "val":"fox"
}, },
{ {
"val":"Apple" "val":"in a box"
} }
], ],
"picUrl":"http://staging-teach.cdn.ireadabc.com/101cdabba6404b73292d3b676f4683b1.png", "picUrl":"http://staging-teach.cdn.ireadabc.com/101cdabba6404b73292d3b676f4683b1.png",
......
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