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

refactor: 把let改成const

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