Commit 2bbabd5a authored by 范雪寒's avatar 范雪寒

feat: 基本完成

parent 8371b586
......@@ -2,10 +2,11 @@ import {
Game,
TouchSprite,
MyLabel,
asyncTweenChange,
} from './Game';
import {
jelly,
jelly, tweenChange,
} from './../Unit';
import { defaultData } from './DefaultData';
......@@ -227,8 +228,7 @@ export class MyGame extends Game {
groupBg.addChild(letterLabel);
letterLabel.addTouchBeganListener(() => {
console.log(`groupIdx = ${idx}, lineIdx = ${lineIdx}`);
console.log('this.data.group[idx][lineIdx] = ' + JSON.stringify(this.data.group[idx][lineIdx]));
this.popUp(this.data.group[idx][lineIdx]);
});
width += letterLabel.width;
......@@ -302,19 +302,183 @@ export class MyGame extends Game {
initPopUp() {
const popUpBg = new TouchSprite();
popUpBg.init(this.images.get('img_grey_bg'));
popUpBg.setName('popUpBg');
popUpBg.x = this._parent.canvasWidth / 2;
popUpBg.y = this._parent.canvasHeight / 2;
popUpBg.setScaleXY(this._parent.mapScaleBig);
popUpBg.alpha = 0;
popUpBg.childDepandAlpha = true;
popUpBg.addTouchBeganListener(() => {
console.log('汪汪汪');
});
this.addChild(popUpBg);
const popUpWinBg = new TouchSprite();
popUpWinBg.init(this.images.get('img_win_bg'));
popUpWinBg.setName('popUpWinBg');
popUpWinBg.x = this._parent.canvasWidth / 2;
popUpWinBg.y = this._parent.canvasHeight / 2;
popUpWinBg.setScaleXY(this.mapScale);
popUpWinBg.alpha = 0;
popUpWinBg.childDepandAlpha = true;
this.addChild(popUpWinBg);
const btnClose = new TouchSprite();
btnClose.init(this.images.get('btn_close'));
btnClose.setName('btnClose');
btnClose.x = (popUpWinBg.width / 2 - btnClose.width / 3);
btnClose.y = -(popUpWinBg.height / 2 - btnClose.height / 3);
btnClose.addTouchBeganListener(() => {
jelly(btnClose);
this.hidePopUp();
});
popUpWinBg.addChild(btnClose);
const wordMiddle = new MyLabel();
wordMiddle.fontSize = 72;
wordMiddle.fontColor = "#680099";
wordMiddle.fontName = 'GOTHICB';
wordMiddle.text = '';
wordMiddle.refreshSize();
wordMiddle.setName('wordMiddle');
popUpWinBg.addChild(wordMiddle);
const changeBtn = new TouchSprite();
changeBtn.init(this.images.get('btn_switch'));
changeBtn.x = (popUpWinBg.width / 2 - 100);
changeBtn.y = (popUpWinBg.height / 2 - 100);
changeBtn.setName('changeBtn');
changeBtn.addTouchBeganListener(async () => {
jelly(changeBtn);
await this.changePopUp();
changeBtn.visible = false;
});
popUpWinBg.addChild(changeBtn);
}
popUpData;
popUp(popUpData) {
this.popUpData = popUpData;
const popUpBg = this.getChildByName('popUpBg');
tweenChange(popUpBg, { alpha: 1 }, 0.2);
const popUpWinBg = this.getChildByName('popUpWinBg');
tweenChange(popUpWinBg, { alpha: 1 }, 0.2);
const wordMiddle = this.seekChildByName('wordMiddle');
wordMiddle.text = popUpData.word;
wordMiddle.refreshSize();
wordMiddle.x = 0;
wordMiddle.y = -150;
const nodePosBaseOld = popUpWinBg.seekChildByName('nodePosBase');
if (nodePosBaseOld) {
popUpWinBg.removeChild(nodePosBaseOld);
}
const nodePosBase = new TouchSprite();
nodePosBase.setName('nodePosBase');
nodePosBase.childDepandAlpha = true;
popUpWinBg.addChild(nodePosBase);
let blankWidth = 0;
let width = 0;
popUpData.letterDataList.forEach((letterData, idx) => {
const wordMiddle = new MyLabel();
wordMiddle.fontSize = 72;
wordMiddle.fontColor = "#363333";
wordMiddle.fontName = 'GOTHICB';
wordMiddle.text = letterData.letter;
wordMiddle.setName(`wordMiddle_${idx}`);
wordMiddle.refreshSize();
wordMiddle.anchorX = 0;
wordMiddle.anchorY = 0.5;
wordMiddle.x = width + letterData.group * 20;
wordMiddle.y = 120;
nodePosBase.addChild(wordMiddle);
blankWidth = letterData.group * 20;
width += wordMiddle.width;
const line = new TouchSprite();
line.init(this.images.get('img_line_purple'));
line.anchorX = 0;
line.anchorY = 0.5;
line.x = wordMiddle.x;
line.y = 170;
line.scaleX = wordMiddle.width / line.width;
line.setName(`line_${idx}`);
nodePosBase.addChild(line);
});
const changeBtn = this.seekChildByName('changeBtn');
changeBtn.visible = true;
nodePosBase.x = -(width + blankWidth) / 2;
}
hidePopUp() {
const popUpBg = this.getChildByName('popUpBg');
tweenChange(popUpBg, { alpha: 0 }, 0.2);
const popUpWinBg = this.getChildByName('popUpWinBg');
tweenChange(popUpWinBg, { alpha: 0 }, 0.2);
}
async changePopUp() {
const nodePosBaseOld = this.seekChildByName('nodePosBase');
await asyncTweenChange(nodePosBaseOld, { alpha: 0 }, 0.2);
const popUpWinBg = this.getChildByName('popUpWinBg');
const nodePosBaseOld2 = popUpWinBg.seekChildByName('nodePosBase');
if (nodePosBaseOld2) {
popUpWinBg.removeChild(nodePosBaseOld2);
}
const nodePosBase = new TouchSprite();
nodePosBase.setName('nodePosBase');
nodePosBase.childDepandAlpha = true;
popUpWinBg.addChild(nodePosBase);
let blankWidth = 0;
let width = 0;
this.popUpData.letterDataList.forEach((letterData, idx) => {
const wordMiddle = new MyLabel();
wordMiddle.fontSize = 72;
wordMiddle.fontColor = letterData.color;
wordMiddle.fontName = 'GOTHICB';
wordMiddle.text = letterData.letter;
wordMiddle.setName(`wordMiddle_${idx}`);
wordMiddle.refreshSize();
wordMiddle.anchorX = 0;
wordMiddle.anchorY = 0.5;
wordMiddle.alpha = 0;
wordMiddle.x = width + letterData.group * 20;
wordMiddle.y = 120;
nodePosBase.addChild(wordMiddle);
tweenChange(wordMiddle, { alpha: 1 }, 0.2);
blankWidth = letterData.group * 20;
width += wordMiddle.width;
const line = new TouchSprite();
line.init(this.images.get('img_line_purple'));
line.anchorX = 0;
line.anchorY = 0.5;
line.x = wordMiddle.x;
line.y = 170;
line.scaleX = wordMiddle.width / line.width;
line.setName(`line_${idx}`);
nodePosBase.addChild(line);
if (letterData.point) {
const point = new TouchSprite();
point.init(this.images.get('Img_point'));
point.x = wordMiddle.x + 10;
point.y = wordMiddle.y - 50;
nodePosBase.addChild(point);
}
});
nodePosBase.x = -(width + blankWidth) / 2;
}
}
......@@ -14,6 +14,7 @@ const res = [
['btn_switch', 'assets/play/btn_switch.png'],
['img_line_black', 'assets/play/img_line_black.png'],
['img_oval_bg', 'assets/play/img_oval_bg.png '],
['Img_point', 'assets/play/Img_point.png '],
];
const resAudio = [
......
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