Commit abf88f4b authored by 王勇霞's avatar 王勇霞

拼图小游戏

parent 3f987fa6
resource/game/tips.png

27.4 KB | W: | H:

resource/game/tips.png

4.3 KB | W: | H:

resource/game/tips.png
resource/game/tips.png
resource/game/tips.png
resource/game/tips.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -33,7 +33,7 @@
"name": "common"
},
{
"keys": "1.png,2.png,3.png,4.png,back.png,cardBg.jpg,hand.png,tips.png,按钮.png,规则.png,返回.png",
"keys": "hand.png,tips.png,底图背景.png,指向.png",
"name": "game"
},
{
......
......@@ -28,26 +28,24 @@ export class Main {
private _pause: boolean;
private canvas: HTMLCanvasElement
constructor(canvas: HTMLCanvasElement, data = {
needGuide: true,
needGuide: true,
uiConfig: {
cardBackBg:
"https://yun.duiba.com.cn/aurora/assets/3ddcd8fae8c5f382c6a54a93a343b0f297f68d4e.png",
cardFontBg1:
"https://yun.duiba.com.cn/aurora/assets/4a1cb2affeb9024ada20078108cdd05737ba9168.png",
cardFontBg2:
"https://yun.duiba.com.cn/aurora/assets/96f167f23e8691e50e65dc79bb5b709272a447ee.png",
cardFontBg3:
"https://yun.duiba.com.cn/aurora/assets/1f4da40a6bd75817b2f3cc1d35ee2a436b4db39c.png",
cardFontBg4:
"https://yun.duiba.com.cn/aurora/assets/3fe99f439878e90979a779c12cbb25cfce48f725.png",
mainBg:
"https://yun.duiba.com.cn/aurora/assets/cee253d9388f52840d17c05686200e631a2d826b.png",
ruleBtn:
"https://yun.duiba.com.cn/aurora/assets/aa3c770ff5f844351a7bb4d2a2ee3f1574fb9a51.png",
"https://yun.duiba.com.cn/aurora/assets/b76307c3830811177a4bce87a7d07fd04a9646de.png",
serviceBtn:
"https://yun.duiba.com.cn/aurora/assets/307a139dd1ec7a7e6b552faf17fd35c9e7032b10.png",
"https://yun.duiba.com.cn/aurora/assets/925b347e43fde06f793ae313d3e67d06e17cec38.png",
ruleBtn:
"https://yun.duiba.com.cn/aurora/assets/fc23c1787f39e8ba169153daf0513448729133ef.png",
mainBtn:
"https://yun.duiba.com.cn/aurora/assets/5c56beda337c4513d7d6eeaee4da377a7090b3d2.png",
"https://yun.duiba.com.cn/aurora/assets/b890b2c45802e5112b256db7594d4244901b0044.png",
cardBg1:
"https://yun.duiba.com.cn/aurora/assets/035c6e18dfed4edf140dc21d4a32e2ee2754079e.png",
cardBg2:
"https://yun.duiba.com.cn/aurora/assets/e2fa2ceef3208e261a752014433b4274dc6a4533.png",
cardBg3:
"https://yun.duiba.com.cn/aurora/assets/2d9cbb2af52668b1dd962aad03e0f833c7d0dc9d.png",
cardBg4:
"https://yun.duiba.com.cn/aurora/assets/40f7165b41c37956ee2c39c65b6b0be6b661a024.png",
}
}) {
Tools.gameData = data
......
......@@ -533,89 +533,45 @@ export const ResJson = {
}
},
{
"keys": "1.png,2.png,3.png,4.png,back.png,cardBg.jpg,hand.png,tips.png,按钮.png,规则.png,返回.png",
"keys": "hand.png,tips.png,底图背景.png,指向.png",
"name": "game",
"atlas": {
"tips.png": {
"底图背景.png": {
"x": 2,
"y": 2,
"w": 523,
"h": 72,
"w": 620,
"h": 620,
"ox": 0,
"oy": 0,
"sw": 523,
"sh": 72,
"sw": 620,
"sh": 620,
"ro": false
},
"按钮.png": {
"x": 2,
"y": 76,
"w": 348,
"h": 101,
"ox": 0,
"oy": 0,
"sw": 348,
"sh": 101,
"ro": false
},
"3.png": {
"x": 2,
"y": 179,
"w": 140,
"h": 265,
"ox": 0,
"oy": 0,
"sw": 140,
"sh": 265,
"ro": true
},
"back.png": {
"x": 2,
"y": 321,
"w": 140,
"h": 265,
"tips.png": {
"x": 624,
"y": 2,
"w": 414,
"h": 29,
"ox": 0,
"oy": 0,
"sw": 140,
"sh": 265,
"sw": 414,
"sh": 29,
"ro": true
},
"1.png": {
"x": 269,
"y": 179,
"w": 140,
"h": 264,
"ox": 0,
"oy": 0,
"sw": 140,
"sh": 264,
"ro": false
},
"2.png": {
"指向.png": {
"x": 2,
"y": 463,
"w": 141,
"h": 264,
"y": 624,
"w": 151,
"h": 147,
"ox": 0,
"oy": 0,
"sw": 141,
"sh": 264,
"ro": true
},
"4.png": {
"x": 527,
"y": 2,
"w": 140,
"h": 264,
"ox": 0,
"oy": 0,
"sw": 140,
"sh": 264,
"sw": 151,
"sh": 147,
"ro": false
},
"hand.png": {
"x": 268,
"y": 463,
"x": 155,
"y": 624,
"w": 119,
"h": 120,
"ox": 0,
......@@ -623,28 +579,6 @@ export const ResJson = {
"sw": 119,
"sh": 120,
"ro": false
},
"规则.png": {
"x": 352,
"y": 76,
"w": 91,
"h": 50,
"ox": 0,
"oy": 0,
"sw": 91,
"sh": 50,
"ro": true
},
"返回.png": {
"x": 404,
"y": 76,
"w": 91,
"h": 53,
"ox": 0,
"oy": 0,
"sw": 91,
"sh": 53,
"ro": true
}
}
},
......@@ -892,5 +826,5 @@ export const ResJson = {
}
}
],
"path": "https://yun.duiba.com.cn/db_games/activity/template/1669024227/resource/"
"path": "https://yun.duiba.com.cn/db_games/activity/template/1669103592/resource/"
}
\ No newline at end of file
......@@ -4,56 +4,67 @@ import { Scene } from "../../module/views/Scene";
import { GDispatcher } from "../Main";
import { Tools } from "../Tools";
import UI from "../UI";
import { guideList, list, defaultUI } from "./GameConfig";
let lastIndex = -1; // 最后一次点击的下标
import { defaultUI } from "./GameConfig";
export class Game extends Scene {
get groupNames() {
return ["game"];
}
// 传输数据
needGuide = false;
uiConfig = defaultUI;
differValue = 0;
mainBg: FYGE.Sprite;
backBtn: FYGE.Sprite;
ruleBtn: FYGE.Sprite;
startBtn: FYGE.Sprite;
handSvga: Hand;
// 引导部分
guidelayer;
guideWrap: FYGE.Container;
puzzleBox: FYGE.Sprite;
// 游戏部分
gamelayer;
gameWrap: FYGE.Container;
gameBack: FYGE.Sprite;
textureList: Chip[] = []; //未打乱的图片数组
textureContanier: FYGE.Container;
sortArr = [];
startPositionX: number = 0;
startPositionY: number = 0;
currentPositionX: number = 0;
currentPositionY: number = 0;
startTarget;
currentTarget;
direction: -1 | 0 | 1 | 2;
correctNumber: number = 0;
canMove: boolean = false;
isPause: boolean = true;
tween1: FYGE.Tween;
tween2: FYGE.Tween;
isFinish: number = 0;
puzzleIndex: number = 2;
list = []; // 数组
guideCardList = []; // 新手引导中的卡片列表
cardList = []; // 游戏中的卡片列表
guideStep = 1; // 引导步数
initUi() {
this.needGuide = Tools.gameData.needGuide; // 模板中传过来的
this.uiConfig = Tools.gameData.uiConfig; // 模板中传过来的UI
// 模板中传过来的
this.needGuide = Tools.gameData.needGuide;
this.uiConfig = Tools.gameData.uiConfig; // UI配置
if (document.body.clientHeight <= 667) {
this.differValue = 80;
}
UI.Sp(this, this.uiConfig.mainBg, 0, 0);
this.backBtn = UI.Sp(this, this.uiConfig.serviceBtn, 0, 274);
this.ruleBtn = UI.Sp(this, this.uiConfig.ruleBtn, 608, 274);
this.startBtn = UI.Sp(this, this.uiConfig.mainBtn, 224, 1231);
this.mainBg = UI.Sp(this, this.uiConfig.mainBg, 0, this.differValue);
this.backBtn = UI.Sp(this.mainBg, this.uiConfig.serviceBtn, 0, 229);
this.ruleBtn = UI.Sp(this.mainBg, this.uiConfig.ruleBtn, 586, 229);
this.startBtn = UI.Sp(this.mainBg, this.uiConfig.mainBtn, 224, 1141);
this.textureContanier = UI.Ctn(this.mainBg, 75, 496);
// 遍历生成底图
for (let i = 0; i < 8; i++) {
UI.Sp(
this,
this.uiConfig.cardBackBg,
Math.floor(i % 4) * 168 + 50,
Math.floor(i / 4) * 360 - 15 + 538
);
}
// 如果是新手引导阶段, 有手势引导
if (this.needGuide) {
this.handSvga = this.startBtn.addChild(new Hand());
this.handSvga.position.set(200, -120);
this.textureList = [];
for (var i = 0; i < 4; i++) {
const chip = new Chip();
chip.init(this.uiConfig["cardBg" + (i + 1)], i);
this.textureList.push(chip);
this.textureContanier
.addChild(chip)
.position.set(Math.floor(i % 2) * 302, Math.floor(i / 2) * 302);
}
// 添加点击事件
this.backBtn.addEventListener(
FYGE.MouseEvent.CLICK,
......@@ -65,7 +76,6 @@ export class Game extends Scene {
this.ruleBtn.addEventListener(
FYGE.MouseEvent.CLICK,
function () {
// 活动规则-wyx
GDispatcher.dispatchEvent("openRule");
},
this
......@@ -73,51 +83,59 @@ export class Game extends Scene {
this.startBtn.addEventListener(
FYGE.MouseEvent.CLICK,
function () {
// 开始游戏-wyx
Tools.btnDelay(this.startBtn);
if (this.needGuide) {
this.needGuide = false;
this.onEnterGuide();
} else {
GDispatcher.dispatchEvent("startId");
Tools.btnDelay(this.startBtn);
this.gameUIRender();
}
},
this
);
// 移动事件
this.textureContanier.addEventListener(
FYGE.MouseEvent.MOUSE_DOWN,
this.mouseDownEvent,
this
);
this.textureContanier.addEventListener(
FYGE.MouseEvent.MOUSE_MOVE,
this.mouseMoveEvent,
this
);
this.textureContanier.addEventListener(
FYGE.MouseEvent.MOUSE_UP,
this.mouseUpEvent,
this
);
}
start(data) {
super.start();
}
// 新手引导
onEnterGuide() {
this.needGuide = false;
this.guideUIRender();
}
guideUIRender() {
this.guidelayer = UI.Ctn(this, 0, 0);
this.guidelayer.addChild(
Tools.getRect(layers.stageWidth, 1624, 0x0000000, 0.6)
Tools.getRect(layers.stageWidth, 1624, 0x0000000, 0.8)
);
this.guideWrap = UI.Ctn(this.guidelayer, 50, 530);
UI.Sp(this.guideWrap, "tips.png", 56, 720);
this.list = JSON.parse(JSON.stringify(guideList));
this.cardList = [];
this.list.map((item, i) => {
const card = new GuideCard({
...item,
index: i,
list: this.list,
cardList: this.guideCardList,
});
this.guideCardList.push(card);
this.guideWrap
.addChild(card)
.position.set(Math.floor(i % 4) * 168, Math.floor(i / 4) * 360 - 15);
this.guideCardList[i].alpha = 0;
FYGE.Tween.get(this.guideCardList[i])
.wait(i * 200)
.to(
{
y: Math.floor(i / 4) * 360,
alpha: 1,
},
500
);
});
this.guideWrap = UI.Ctn(this.guidelayer, 0, 487);
this.puzzleBox = UI.Sp(this.guideWrap, "底图背景.png", 64, 0);
UI.Sp(this.guideWrap, "指向.png", 341, 643);
UI.Sp(this.guideWrap, "tips.png", 168, 826);
for (var i = 0; i < 4; i++) {
UI.Sp(
this.puzzleBox,
this.uiConfig["cardBg" + (i + 1)],
Math.floor(i % 2) * 302 + 9,
Math.floor(i / 2) * 302 + 9
);
}
this.guidelayer.addEventListener(
FYGE.MouseEvent.CLICK,
function () {
......@@ -126,349 +144,228 @@ export class Game extends Scene {
this
);
}
gameUIRender() {
this.gamelayer = UI.Sp(this, this.uiConfig.mainBg, 0, 0);
// this.gameBack = UI.Sp(this.gamelayer, "返回.png", 0, 274);
// this.gameBack.addEventListener(
// FYGE.MouseEvent.CLICK,
// function () {
// this.removeChild(this.gamelayer);
// },
// this
// );
this.gameWrap = UI.Ctn(this.gamelayer, 50, 530);
this.list = JSON.parse(JSON.stringify(list)).sort(
() => Math.random() - 0.5
);
this.cardList = [];
this.list.map((item, i) => {
const card = new Card({
...item,
index: i,
list: this.list,
cardList: this.cardList,
});
this.cardList.push(card);
clickGuideCard() {
this.removeChild(this.guidelayer);
}
this.gameWrap
.addChild(card)
.position.set(Math.floor(i % 4) * 168, Math.floor(i / 4) * 360 - 15);
this.cardList[i].alpha = 0;
FYGE.Tween.get(this.cardList[i])
.wait(i * 200)
.to(
{
y: Math.floor(i / 4) * 360,
alpha: 1,
},
500
);
});
gameUIRender() {
this.isPause = false;
this.canMove = true;
console.log("开始游戏");
this.startBtnHandle(false);
GDispatcher.dispatchEvent("startId");
this.onUpsetOrder();
}
onEnterGuide() {
this.startBtn.removeChild(this.handSvga);
this.guideUIRender();
/**
* @param canClick 能否点击
*/
startBtnHandle(canClick) {
if (canClick) {
this.startBtn.visible = true;
} else {
this.startBtn.visible = false;
}
}
clickGuideCard() {
console.log("点击卡片");
if (this.guideStep == 1) {
this.guideCardList[2].removeHand();
this.guideCardList[5].handSvga = this.guideCardList[5].addChild(
new Hand()
);
this.guideCardList[2].onOverTurn(this.guideCardList[2]);
} else if (this.guideStep == 2) {
this.guideCardList[5].removeHand();
this.guideCardList[5].onOverTurn(this.guideCardList[5], () => {
setTimeout(() => {
this.guideCardList[2].onZoomCard(this.guideCardList[2]);
this.guideCardList[5].onZoomCard(this.guideCardList[5]);
// 打乱顺序
onUpsetOrder() {
// 因为默认顺序是1234
this.sortArr = Array.from(Array(4), (_, index) => index);
this.sortArr.sort(() => {
return 0.5 - Math.random();
});
const oldArr = Array.from(Array(4), (_, index) => index);
if (this.sortArr.join() == oldArr.join()) {
// console.info("相等");
this.onUpsetOrder();
return;
}
let tempArr = [];
for (let i = 0; i < this.sortArr.length; i++) {
tempArr[this.sortArr[i]] = this.textureList[i];
}
for (let i = 0; i < 4; i++) {
let x = Math.floor(this.sortArr[0] % 2) * 302;
let y = Math.floor(this.sortArr[0] / 2) * 302;
this.sortArr.splice(0, 1);
FYGE.Tween.get(this.textureList[i])
.to({ x: x, y: y }, 1000)
.call(() => {
this.isFinish++;
if (this.isFinish >= 4) {
GDispatcher.dispatchEvent("finish");
}
});
});
} else if (this.guideStep == 3) {
// 回到游戏
this.removeChild(this.guidelayer);
}
this.guideStep += 1;
}
start(data) {
super.start();
this.textureList = tempArr;
}
closeGame() {
// e.data.isGuide;
this.removeChild(this.gamelayer);
mouseDownEvent(e: FYGE.MouseEvent) {
if (this.isPause) return;
if (!this.canMove) return;
this.startPositionX = e.stageX;
this.startPositionY = e.stageY;
this.startTarget = e.currentTarget.parent.parent;
}
mouseMoveEvent(e: FYGE.MouseEvent) {
if (this.isPause) return;
if (!this.canMove) return;
this.currentPositionX = e.stageX;
this.currentPositionY = e.stageY;
let X = this.currentPositionX - this.startPositionX;
let Y = this.currentPositionY - this.startPositionY;
initEvents() {
super.initEvents();
GDispatcher.addEventListener("closeGame", this.closeGame, this);
}
removeEvents() {
super.removeEvents();
GDispatcher.removeEventListener("closeGame", this.closeGame, this);
if (Math.abs(X) > Math.abs(Y) && X > 0) {
if (this.startTarget.x >= 425) return;
// console.log("向右划")
this.direction = 2;
} else if (Math.abs(X) > Math.abs(Y) && X < 0) {
if (this.startTarget.x === 0) return;
// console.log("向左划")
this.direction = 1;
} else if (Math.abs(X) < Math.abs(Y) && Y > 0) {
if (this.startTarget.y === 430) return;
// console.log("向下划")
this.direction = 0;
} else if (Math.abs(X) < Math.abs(Y) && Y < 0) {
if (this.startTarget.y === 0) return;
// console.log("向上划");
this.direction = -1;
} else {
// console.log('只是点击了而已')
}
}
}
mouseUpEvent(e: FYGE.MouseEvent) {
if (this.isPause) return;
if (!this.canMove) return;
class Card extends FYGE.Container {
img;
uiConfig = Tools.gameData.uiConfig;
public isFront = false; // 是否正面
public match = false; // 是否匹配
public type; // 类型
constructor(data?) {
super();
this.initUi(data);
}
let num = this.startTarget.x / 302 + (this.startTarget.y / 302) * 2;
console.log("mouseUpEvent---num", num);
initUi(data) {
this.type = data.type;
this.img = UI.Sp(this, this.uiConfig.cardBackBg, 0, 0);
this.img.anchorX = 70;
this.img.anchorY = 133;
this.addEventListener(
FYGE.MouseEvent.CLICK,
function () {
Tools.btnDelay(this);
this.clickCard(data);
},
this
);
switch (this.direction) {
case -1:
this.queryChange(num - 2);
break;
case 0:
this.queryChange(num + 2);
break;
case 1:
this.queryChange(num - 1);
break;
case 2:
this.queryChange(num + 1);
break;
default:
break;
}
}
clickCard(data) {
if (this.isFront) return;
this.isFront = true;
this.onOverTurn(this, () => {
if (lastIndex > -1) {
console.log(data.list[lastIndex].type, data.type);
if (data.list[lastIndex].type === data.type) {
const tempIndex = lastIndex;
lastIndex = -1;
// 匹配成功, 进行动画缩放
// 当前卡片缩放
this.onZoomCard(data.cardList[data.index]);
// 上一个卡片缩放
this.onZoomCard(data.cardList[tempIndex], () => {
// 检测是否完成, 提交游戏
if (this.checkIsAllMatch(data.cardList)) {
console.log("提交游戏");
GDispatcher.dispatchEvent("submit");
}
});
} else {
const tempIndex = lastIndex;
lastIndex = -1;
// 等待一段时间翻转
setTimeout(() => {
// 当前卡片翻转
this.onOverTurn(data.cardList[data.index], () => {
data.cardList[data.index].isFront = false;
});
// 上一个卡片翻转
this.onOverTurn(data.cardList[tempIndex], () => {
data.cardList[tempIndex].isFront = false;
});
}, 500);
}
queryChange(num: number) {
if (this.isPause) return;
if (num >= 0 && num <= 3) {
this.currentTarget = this.textureList[num];
if (this.countRowCol()) {
this.exchangeTarget(this.startTarget, this.currentTarget);
} else {
lastIndex = data.index;
console.log("在数组中但不是同一行");
}
});
}
}
onOverTurn(that, callback = () => {}) {
FYGE.Tween.get(that.img)
.to(
{
scaleX: 0,
},
200
)
.call(() => {
if (that.match) {
that.img.texture = FYGE.Texture.fromUrl(this.uiConfig.cardBackBg);
that.match = false;
} else {
that.img.texture = FYGE.Texture.fromUrl(
this.uiConfig["cardFontBg" + that.type]
);
that.match = true;
}
FYGE.Tween.get(that.img)
.to(
{
scaleX: 1,
},
200
)
.call(() => {
console.log("翻转结束");
if (callback) {
callback();
}
});
});
countRowCol() {
if (this.isPause) return;
return (
this.textureList.indexOf(this.startTarget) % 2 ===
this.textureList.indexOf(this.currentTarget) % 2 ||
Math.floor(this.textureList.indexOf(this.startTarget) / 2) ===
Math.floor(this.textureList.indexOf(this.currentTarget) / 2)
);
}
onZoomCard(that, callback = () => {}) {
FYGE.Tween.get(that.img)
.to(
{
scaleX: 1.2,
scaleY: 1.2,
},
300
)
exchangeTarget(target: Chip, currentTarget: Chip) {
if (this.isPause) return;
let tempX = currentTarget.x;
let tempY = currentTarget.y;
this.canMove = false;
this.tween1 = FYGE.Tween.get(currentTarget)
.to({ x: target.x, y: target.y }, 200)
.call(() => {});
this.tween2 = FYGE.Tween.get(target)
.to({ x: tempX, y: tempY }, 200)
.call(() => {
FYGE.Tween.get(that.img)
.to(
{
scaleX: 1,
scaleY: 1,
},
300
)
.call(() => {
console.log("缩放结束");
that.match = true;
if (callback) {
callback();
}
});
this.isWin();
});
let index1 = this.textureList.indexOf(currentTarget);
let index2 = this.textureList.indexOf(target);
let temp = target;
this.textureList[index2] = currentTarget;
this.textureList[index1] = temp;
}
// 检测是否全部翻完
checkIsAllMatch(list) {
for (const item of list) {
if (!item.match) {
return false;
isWin() {
this.textureList.map((item, index) => {
if (index === item.correctNum) {
this.correctNumber++;
}
});
this.canMove = true;
if (this.correctNumber >= 4) {
this.gameOver();
} else {
this.correctNumber = 0;
}
return true;
}
destroy() {
super.destroy();
FYGE.Tween.removeTweens(this.img);
}
}
class GuideCard extends FYGE.Container {
img;
uiConfig = Tools.gameData.uiConfig;
public isFront = false; // 是否正面
public match = false; // 是否匹配
public type; // 类型
handSvga: Hand; // 手指引导
constructor(data?) {
super();
this.initUi(data);
}
removeHand() {
this.removeChild(this.handSvga);
}
initUi(data) {
this.type = data.type;
this.img = UI.Sp(this, this.uiConfig.cardBackBg, 0, 0);
this.img.anchorX = 70;
this.img.anchorY = 133;
if (data.index == 2) {
this.handSvga = this.addChild(new Hand());
gameOver() {
console.log("游戏结束");
this.isPause = true;
this.canMove = true;
this.isFinish = 0;
this.startBtnHandle(true);
if (this.correctNumber >= 4) {
console.log("win");
GDispatcher.dispatchEvent("win");
} else {
console.log("over");
GDispatcher.dispatchEvent("over");
}
this.correctNumber = 0;
if (this.tween1 && this.tween2) {
setTimeout(() => {
FYGE.Tween.removeTweenSelf(this.tween1);
FYGE.Tween.removeTweenSelf(this.tween2);
}, 200);
}
this.textureList.sort((a, b) => {
return a.correctNum - b.correctNum;
});
}
onOverTurn(that, callback = () => {}) {
FYGE.Tween.get(that.img)
.to(
{
scaleX: 0,
},
200
)
.call(() => {
if (that.match) {
that.img.texture = FYGE.Texture.fromUrl(this.uiConfig.cardBackBg);
that.match = false;
} else {
that.img.texture = FYGE.Texture.fromUrl(
this.uiConfig["cardFontBg" + that.type]
);
that.match = true;
}
FYGE.Tween.get(that.img)
.to(
{
scaleX: 1,
},
200
)
.call(() => {
console.log("翻转结束");
if (callback) {
callback();
}
});
});
}
onZoomCard(that, callback = () => {}) {
FYGE.Tween.get(that.img)
.to(
{
scaleX: 1.2,
scaleY: 1.2,
},
300
)
.call(() => {
FYGE.Tween.get(that.img)
.to(
{
scaleX: 1,
scaleY: 1,
},
300
)
.call(() => {
console.log("缩放结束");
that.match = true;
if (callback) {
callback();
}
});
});
}
destroy() {
super.destroy();
FYGE.Tween.removeTweens(this.img);
}
}
class Hand extends FYGE.Container {
img;
constructor(data?) {
super();
this.initUi();
initEvents() {
super.initEvents();
// GDispatcher.addEventListener("closeGame", this.closeGame, this);
}
initUi() {
this.img = UI.Sp(this, "hand.png", 56, 166);
FYGE.Tween.get(this.img, {
loop: true,
})
.to(
{
x: 70,
y: 185,
},
500
)
.to(
{
x: 56,
y: 166,
},
400
);
removeEvents() {
super.removeEvents();
// GDispatcher.removeEventListener("closeGame", this.closeGame, this);
this.textureContanier.removeEventListener(
FYGE.MouseEvent.MOUSE_DOWN,
this.mouseDownEvent,
this
);
this.textureContanier.removeEventListener(
FYGE.MouseEvent.MOUSE_MOVE,
this.mouseMoveEvent,
this
);
this.textureContanier.removeEventListener(
FYGE.MouseEvent.MOUSE_UP,
this.mouseUpEvent,
this
);
}
}
class Chip extends FYGE.Sprite {
public ct: FYGE.Container;
private chip: FYGE.Sprite;
public correctNum: number;
destroy() {
super.destroy();
FYGE.Tween.removeTweens(this.img);
init(res, correctNum) {
this.correctNum = correctNum;
this.ct = UI.Ctn(this, 0, 0);
UI.Sp(this.ct, res, 0, 0);
}
}
// 翻牌游戏卡片种类
export const cardTypeList = {
1: {
name: "香韵",
img: "https://yun.duiba.com.cn/aurora/assets/1f4da40a6bd75817b2f3cc1d35ee2a436b4db39c.png",
},
2: {
name: "七彩",
img: "https://yun.duiba.com.cn/aurora/assets/3fe99f439878e90979a779c12cbb25cfce48f725.png",
},
3: {
name: "阳光",
img: "https://yun.duiba.com.cn/aurora/assets/4a1cb2affeb9024ada20078108cdd05737ba9168.png",
},
4: {
name: "清甜",
img: "https://yun.duiba.com.cn/aurora/assets/96f167f23e8691e50e65dc79bb5b709272a447ee.png",
},
};
// 游戏列表
export const list = [
{
type: 1,
},
{
type: 2,
},
{
type: 1,
},
{
type: 2,
},
{
type: 3,
},
{
type: 3,
},
{
type: 4,
},
{
type: 4,
},
];
// 新手引导列表
export const guideList = [
{
type: 1,
isFront: false,
hand: false,
match: false, // 是否匹配
},
{
type: 2,
isFront: false,
hand: false,
match: false,
},
{
type: 3,
isFront: false,
hand: true,
match: false,
},
{
type: 2,
isFront: false,
hand: false,
match: false,
},
{
type: 1,
isFront: false,
hand: false,
match: false,
},
{
type: 3,
isFront: false,
hand: false,
match: false,
},
{
type: 4,
isFront: false,
hand: false,
match: false,
},
{
type: 4,
isFront: false,
hand: false,
match: false,
},
];
export const defaultUI = {
mainBg:
"https://yun.duiba.com.cn/aurora/assets/b76307c3830811177a4bce87a7d07fd04a9646de.png",
cardBackBg:
"https://yun.duiba.com.cn/aurora/assets/3ddcd8fae8c5f382c6a54a93a343b0f297f68d4e.png",
cardFontBg1:
......@@ -106,8 +11,6 @@ export const defaultUI = {
"https://yun.duiba.com.cn/aurora/assets/1f4da40a6bd75817b2f3cc1d35ee2a436b4db39c.png",
cardFontBg4:
"https://yun.duiba.com.cn/aurora/assets/3fe99f439878e90979a779c12cbb25cfce48f725.png",
mainBg:
"https://yun.duiba.com.cn/aurora/assets/cee253d9388f52840d17c05686200e631a2d826b.png",
ruleBtn:
"https://yun.duiba.com.cn/aurora/assets/aa3c770ff5f844351a7bb4d2a2ee3f1574fb9a51.png",
serviceBtn:
......
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