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

feat:支持缩放位置调整

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