Commit f33b7255 authored by 范雪寒's avatar 范雪寒

refactor: 把let改成const

parent 3e3a9e4d
...@@ -46,8 +46,8 @@ export class MyGame extends Game { ...@@ -46,8 +46,8 @@ export class MyGame extends Game {
} else { } else {
this.data = data.data; this.data = data.data;
let imgUrlList = []; const imgUrlList = [];
let audioUrlList = []; const audioUrlList = [];
this.data.audios.forEach((cube) => { this.data.audios.forEach((cube) => {
audioUrlList.push(cube); audioUrlList.push(cube);
}); });
...@@ -59,12 +59,12 @@ export class MyGame extends Game { ...@@ -59,12 +59,12 @@ export class MyGame extends Game {
} }
preLoadData(imgUrlList, audioUrlList) { preLoadData(imgUrlList, audioUrlList) {
for (var i = 0; i < imgUrlList.length; ++i) { imgUrlList.forEach((imgUrl)=>{
this._parent.addUrlToImages(imgUrlList[i]); this._parent.addUrlToImages(imgUrl);
} });
for (var i = 0; i < audioUrlList.length; ++i) { audioUrlList.forEach((audioUrl)=>{
this._parent.addUrlToAudioObj(audioUrlList[i]); this._parent.addUrlToAudioObj(audioUrl);
} });
} }
initView() { initView() {
...@@ -87,10 +87,7 @@ export class MyGame extends Game { ...@@ -87,10 +87,7 @@ export class MyGame extends Game {
this.getFullScaleXY(); this.getFullScaleXY();
let screenSize = this.getScreenSize(); const bgSized = new TouchSprite();
let defaultSize = this.getDefaultScreenSize();
let bgSized = new TouchSprite();
bgSized.init(this.images.get('Img_bg')); bgSized.init(this.images.get('Img_bg'));
bgSized.anchorX = 0.5; bgSized.anchorX = 0.5;
bgSized.anchorY = 1; bgSized.anchorY = 1;
...@@ -99,7 +96,7 @@ export class MyGame extends Game { ...@@ -99,7 +96,7 @@ export class MyGame extends Game {
this.addChild(bgSized); this.addChild(bgSized);
// 背景 // 背景
let bg = new TouchSprite(); const bg = new TouchSprite();
bg.init(this.images.get('Img_bg')) bg.init(this.images.get('Img_bg'))
bg.setPosition(this._parent.canvasWidth / 2, this._parent.canvasHeight / 2); bg.setPosition(this._parent.canvasWidth / 2, this._parent.canvasHeight / 2);
bg.setScaleXY(this._parent.mapScale); bg.setScaleXY(this._parent.mapScale);
...@@ -127,14 +124,14 @@ export class MyGame extends Game { ...@@ -127,14 +124,14 @@ export class MyGame extends Game {
initTittle() { initTittle() {
// 标题字母背景 // 标题字母背景
let tittleWordBg = new TouchSprite(); const tittleWordBg = new TouchSprite();
tittleWordBg.init(this.images.get('Img_tittleBg')); tittleWordBg.init(this.images.get('Img_tittleBg'));
tittleWordBg.setScaleXY(this._parent.mapScale); tittleWordBg.setScaleXY(this._parent.mapScale);
tittleWordBg.setPosition(this.getTittleBlockPositionX(), 31 * this._parent.mapScale); tittleWordBg.setPosition(this.getTittleBlockPositionX(), 31 * this._parent.mapScale);
this.addChild(tittleWordBg); this.addChild(tittleWordBg);
// 标题字母 // 标题字母
let tittleWord = new MyLabel(); const tittleWord = new MyLabel();
tittleWord.fontSize = 48; tittleWord.fontSize = 48;
tittleWord.fontName = 'BerlinSansFBDemi-Bold'; tittleWord.fontName = 'BerlinSansFBDemi-Bold';
tittleWord.fontColor = '#ab5b22'; tittleWord.fontColor = '#ab5b22';
...@@ -147,7 +144,7 @@ export class MyGame extends Game { ...@@ -147,7 +144,7 @@ export class MyGame extends Game {
tittleWord.refreshSize(); tittleWord.refreshSize();
// 标题文字 // 标题文字
let questionLabel = new MyLabel(); const questionLabel = new MyLabel();
questionLabel.fontSize = 36; questionLabel.fontSize = 36;
questionLabel.fontName = 'FuturaBT-Bold'; questionLabel.fontName = 'FuturaBT-Bold';
questionLabel.fontColor = '#000000'; questionLabel.fontColor = '#000000';
...@@ -283,15 +280,15 @@ export class MyGame extends Game { ...@@ -283,15 +280,15 @@ export class MyGame extends Game {
} }
onClickWords(idx) { onClickWords(idx) {
let label = this.bg.getChildByName('label_' + idx); const label = this.bg.getChildByName('label_' + idx);
this.showWindow(this.data.words[idx], this.data.audios[idx], label); this.showWindow(this.data.words[idx], this.data.audios[idx], label);
} }
hideWindow() { hideWindow() {
let mask = this.bg.getChildByName('mask'); const mask = this.bg.getChildByName('mask');
let winBg = this.bg.getChildByName('winBg'); const winBg = this.bg.getChildByName('winBg');
let btnClose = this.bg.getChildByName('btnClose'); const btnClose = this.bg.getChildByName('btnClose');
let wordLabel = winBg.getChildByName('wordLabel'); const wordLabel = winBg.getChildByName('wordLabel');
tweenChange(mask, { alpha: 0 }, 0.5); tweenChange(mask, { alpha: 0 }, 0.5);
tweenChange(winBg, { alpha: 0 }, 0.5); tweenChange(winBg, { alpha: 0 }, 0.5);
...@@ -300,10 +297,10 @@ export class MyGame extends Game { ...@@ -300,10 +297,10 @@ export class MyGame extends Game {
} }
async showWindow(word, audio, pos = { x: 0, y: 0 }) { async showWindow(word, audio, pos = { x: 0, y: 0 }) {
let mask = this.bg.getChildByName('mask'); const mask = this.bg.getChildByName('mask');
let winBg = this.bg.getChildByName('winBg'); const winBg = this.bg.getChildByName('winBg');
let btnClose = this.bg.getChildByName('btnClose'); const btnClose = this.bg.getChildByName('btnClose');
let wordLabel = winBg.getChildByName('wordLabel'); const wordLabel = winBg.getChildByName('wordLabel');
wordLabel.text = word; wordLabel.text = word;
wordLabel.refreshSize(); wordLabel.refreshSize();
...@@ -325,7 +322,7 @@ export class MyGame extends Game { ...@@ -325,7 +322,7 @@ export class MyGame extends Game {
} }
onClickWinWords() { onClickWinWords() {
let wordLabel = this.bg.seekChildByName('wordLabel'); const wordLabel = this.bg.seekChildByName('wordLabel');
this._parent.playAudio(wordLabel.get('audio')); this._parent.playAudio(wordLabel.get('audio'));
} }
......
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