Commit 87641bc8 authored by Tt's avatar Tt

处理数据

parent dc1f732b
This diff is collapsed.
......@@ -12,8 +12,8 @@ enum WORD_TYPE {
LINE
}
const DefaultPos = {
Word: cc.v2(0, -430),
WordBg: cc.v2(0, -160)
Word: cc.v2(0, -410),
WordBg: cc.v2(0, -150)
}
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
......@@ -25,18 +25,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源
let audios = [];
function checkAudio(obj) {
for (let idx in obj) {
if (typeof obj[idx] == "object") {
checkAudio(obj[idx]);
} else if (typeof obj[idx] == "string") {
if (obj[idx].indexOf(".mp3") > -1) audios.push(obj[idx]);
}
}
}
checkAudio(this.data)
this._audioResList = audios;
// let audios = [];
// function checkAudio(obj) {
// for (let idx in obj) {
// if (typeof obj[idx] == "object") {
// checkAudio(obj[idx]);
// } else if (typeof obj[idx] == "string") {
// if (obj[idx].indexOf(".mp3") > -1) audios.push(obj[idx]);
// }
// }
// }
// checkAudio(this.data)
// this._audioResList = audios;
}
addPreloadAnima() {
......@@ -77,10 +77,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
private wordDataList: Array<any>;
// 当前第几个
private curIndex: number;
private showKuang: boolean;
initData() {
// 所有全局变量 默认都是null
this._cantouch = true;
let data = this.data;
this.showKuang = this.data.showKuang == 1;
this.recordFlag = data.recordFlag;
this.list = data.questions[0].options;
this.layers = [];
......@@ -164,8 +167,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
private wordList: Array<cc.Node>;
private get CurrentWord(): any {
// 默认播放当前音频
// let audio_url = this.wordDataList[this.curIndex].audio
// if (audio_url) pg.audio.playAudioByUrl(audio_url)
return this.wordDataList[this.curIndex];
}
nextWord() {
......@@ -175,8 +176,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
if (!success) return;
this.scheduleOnce(() => {
pg.event.once('layer_right_show_excellent_end', () => {
pg.event.once('layer_coin_show_coin_end', () => {
this.curIndex++;
if (!this.CurrentWord) {
// alert("游戏结束画面暂无")
......@@ -184,11 +183,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
} else {
this.showWord();
}
}) // 动画回调
pg.event.emit('layer_coin_show_coin', 3) //1 2 3硬币数量
})
pg.event.emit('layer_right_show_excellent')
}, 0.2)
// pg.event.once('layer_right_show_excellent_end', () => {
// pg.event.once('layer_coin_show_coin_end', () => {
// this.curIndex++;
// if (!this.CurrentWord) {
// // alert("游戏结束画面暂无")
// this.gameOver();
// } else {
// this.showWord();
// }
// }) // 动画回调
// pg.event.emit('layer_coin_show_coin', 3) //1 2 3硬币数量
// })
// pg.event.emit('layer_right_show_excellent')
}, 0.6)
}
//单词的展示
showWord() {
......@@ -262,7 +270,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
let ansStrArr = ans.split('');
ansStrArr.forEach((str, m) => {
count++;
let child = this.getWordBgNodeByStr(str, scale);
let child = this.getWordBgNodeByStr(str);
child.data = { count: count, group: group, index: m, value: str }
this.successGroupIds[`${i}`] = !str.trim();
let pos = this.getWordBgPosByAns(ansArr.map(ans => ans.text), [str], child.data)
......@@ -316,7 +324,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
let arr = [];
ansStrArr.forEach((str, m) => {
count++;
let child = this.getWordNodeByStr(str, 1);
let child = this.getWordNodeByStr(str);
child.data = { group: group, index: m, count: count, value: str };
let pos = this.getWordPosByAns(ansArr.map(ans => ans.text), [str], child.data);
child.x = pos.x;
......@@ -406,55 +414,51 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
getWordNodeWidth(type, str) {
// str = str.trim();
// // if (!str) return 0;
// const reg = /^[A-Z]+$/;
// const lower = str;//str.toLowerCase()
// if (type === WORD_TYPE.TOUCH) {
// let prefabNode = reg.test(str) ? pg.view.find(this.upper_word, `${lower}`) : pg.view.find(this.lower_word, `${lower}`)
// return prefabNode.width + 20;
// } else {
// let prefabNode = reg.test(str) ? pg.view.find(this.upper_shadow, `${lower}`) : pg.view.find(this.lower_shadow, `${lower}`);
// return prefabNode.width + 30;
// }
return 170;
return 220;
}
getWordNodeByStr(str, scale) {
getWordNodeByStr(str) {
str = str.trim();
const reg = /^[A-Z]+$/;
const lower = str;//str.toLowerCase()
const lower = str;
let wordNode = pg.view.find(this.layer_word, 'word');
let item = pg.view.clone(wordNode);
let prefabNode = reg.test(str) ? pg.view.find(this.upper_word, `${lower}`) : pg.view.find(this.lower_word, `${lower}`)
let child = pg.view.clone(prefabNode)
pg.view.visible(pg.view.find(item, 'kuang'), false)
child.x = 0;
child.y = 0;
child.width *= scale;
child.height *= scale;
child.active = true;
let width = this.getItemWordWidth(WORD_TYPE.TOUCH, [str])
item.x = 0;
item.y = 0;
item.width = width;
item.width *= scale;
item.height *= scale;
item.active = true;
item.getChildByName("icon").addChild(child);
return item;
}
getWordBgNodeByStr(str, scale) {
getWordBgNodeByStr(str) {
str = str.trim();
const reg = /^[A-Z]+$/;
const lower = str;//str.toLowerCase()
let prefabNode = reg.test(str) ? pg.view.find(this.upper_shadow, `${lower}`) : pg.view.find(this.lower_shadow, `${lower}`);
const lower = str;
let wordNode = pg.view.find(this.layer_word, 'word');
let item = pg.view.clone(wordNode);
let prefabNode = reg.test(str) ? pg.view.find(this.upper_shadow, `${lower}`) : pg.view.find(this.lower_shadow, `${lower}`)
let child = pg.view.clone(prefabNode)
child.opacity = 100;
child.active = true
child.x = 0;
child.y = 0;
child.width *= scale;
child.height *= scale;
return child;
child.active = true;
let width = this.getItemWordWidth(WORD_TYPE.TOUCH, [str])
item.x = 0;
item.y = 0;
item.width = width;
item.active = true;
item.getChildByName("icon").addChild(child);
if (this.showKuang) {
pg.view.visible(child, false)
} else {
pg.view.visible(pg.view.find(item, 'kuang'), this.showKuang)
}
return item;
}
getWordBgByGroup(group) {
return this.wordBgList.filter(item => {
......@@ -540,7 +544,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
let nodes = node.data;
let targets = this.getWordBgByGroup(groupId);
nodes.forEach(item => {
let dt = item.data;
let target = targets.find(tr => tr.data.index == item.data.index);
this.wordToWordBg(item, target);
})
......@@ -568,9 +571,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
candys.getComponent(Candy).showAni().then(() => {
cc.tween(light).to(1, { opacity: 0 }).start();
})
cc.tween(node).to(0.2, { x: target.x, y: target.y, scale: 0.85 })
cc.tween(node)
.to(0.2, { x: target.x, y: target.y, scale: 1 })
.call(() => {
target.active = false;
// target.active = false;
}).start();
}
startCurrentItemAni() {
......
......@@ -5,13 +5,14 @@ export const defaultData =
"title": "",
"questionText": "",
"questionTextAudio": "",
"showKuang": 1,
"questions": [
{
"questionAudio": "",
"duration": 120,
"type": "img",
"type": "imgVideo",
"image": "http://staging-teach.cdn.ireadabc.com/e184e067fc931d55fce93c9937a26c51.png",//
"audio": "",
"audio": "http://staging-teach.cdn.ireadabc.com/172fad3743476ac9c668eb8a82d5eca1_l.mp3",
"text": "",
"right": false,
//magical golden stick
......
......@@ -99,6 +99,18 @@
<span style="font-size: 20px;">掌握字数: </span>
<input type="text" nz-input [(ngModel)]="item.zi_count" (blur)="save()">
<div>
<nz-radio-group [(ngModel)]="item.showKuang" (ngModelChange)="ngChange()">
<label nz-radio nzValue="img">
<span [style]="{color:item.showKuang=='1' ? '#169BD5':'#000'}">不显示字母</span>
</label>
<label nz-radio nzValue="imgVideo">
<span [style]="{color:item.showKuang=='2' ? '#169BD5':'#000'}">显示字母</span>
</label>
</nz-radio-group>
</div>
</div>
<div style="margin: 20px;width: 1000px;">
......
......@@ -25,6 +25,7 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
word_count: '0',
sentence_count: '0',
zi_count: '0',
showKuang: '1',
audioName: ""
};
isVisible = false;
......
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