Commit 3f987fa6 authored by 王勇霞's avatar 王勇霞

翻牌游戏-配置图片

parent 732e0a95
......@@ -28,7 +28,27 @@ 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",
serviceBtn:
"https://yun.duiba.com.cn/aurora/assets/307a139dd1ec7a7e6b552faf17fd35c9e7032b10.png",
mainBtn:
"https://yun.duiba.com.cn/aurora/assets/5c56beda337c4513d7d6eeaee4da377a7090b3d2.png",
}
}) {
Tools.gameData = data
var sysInfo;
......
......@@ -892,5 +892,5 @@ export const ResJson = {
}
}
],
"path": "https://yun.duiba.com.cn/db_games/activity/template/1667353664/resource/"
"path": "https://yun.duiba.com.cn/db_games/activity/template/1669024227/resource/"
}
\ No newline at end of file
......@@ -4,7 +4,7 @@ import { Scene } from "../../module/views/Scene";
import { GDispatcher } from "../Main";
import { Tools } from "../Tools";
import UI from "../UI";
import { guideList, list } from "./GameConfig";
import { guideList, list, defaultUI } from "./GameConfig";
let lastIndex = -1; // 最后一次点击的下标
export class Game extends Scene {
......@@ -12,6 +12,7 @@ export class Game extends Scene {
return ["game"];
}
needGuide = false;
uiConfig = defaultUI;
backBtn: FYGE.Sprite;
ruleBtn: FYGE.Sprite;
......@@ -32,16 +33,17 @@ export class Game extends Scene {
guideStep = 1; // 引导步数
initUi() {
this.needGuide = Tools.gameData.needGuide; // 模板中传过来的
this.uiConfig = Tools.gameData.uiConfig; // 模板中传过来的UI
UI.Sp(this, "cardBg.jpg", 0, 0);
this.backBtn = UI.Sp(this, "返回.png", 0, 274);
this.ruleBtn = UI.Sp(this, "规则.png", 663, 274);
this.startBtn = UI.Sp(this, "按钮.png", 198, 1231);
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);
// 遍历生成底图
for (let i = 0; i < 8; i++) {
UI.Sp(
this,
"back.png",
this.uiConfig.cardBackBg,
Math.floor(i % 4) * 168 + 50,
Math.floor(i / 4) * 360 - 15 + 538
);
......@@ -56,8 +58,7 @@ export class Game extends Scene {
this.backBtn.addEventListener(
FYGE.MouseEvent.CLICK,
function () {
// 返回-wyx
GDispatcher.dispatchEvent("backIndex");
GDispatcher.dispatchEvent("service");
},
this
);
......@@ -91,7 +92,7 @@ export class Game extends Scene {
Tools.getRect(layers.stageWidth, 1624, 0x0000000, 0.6)
);
this.guideWrap = UI.Ctn(this.guidelayer, 50, 530);
UI.Sp(this.guideWrap, "tips.png", 56,720);
UI.Sp(this.guideWrap, "tips.png", 56, 720);
this.list = JSON.parse(JSON.stringify(guideList));
this.cardList = [];
this.list.map((item, i) => {
......@@ -126,15 +127,15 @@ export class Game extends Scene {
);
}
gameUIRender() {
this.gamelayer = UI.Sp(this, "cardBg.jpg", 0, 0);
this.gameBack = UI.Sp(this.gamelayer, "返回.png", 0, 274);
this.gameBack.addEventListener(
FYGE.MouseEvent.CLICK,
function () {
this.removeChild(this.gamelayer)
},
this
);
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
......@@ -194,8 +195,8 @@ export class Game extends Scene {
super.start();
}
closeGame() {
// e.data.isGuide;
this.removeChild(this.gamelayer)
// e.data.isGuide;
this.removeChild(this.gamelayer);
}
initEvents() {
......@@ -210,6 +211,7 @@ export class Game extends Scene {
class Card extends FYGE.Container {
img;
uiConfig = Tools.gameData.uiConfig;
public isFront = false; // 是否正面
public match = false; // 是否匹配
public type; // 类型
......@@ -220,7 +222,7 @@ class Card extends FYGE.Container {
initUi(data) {
this.type = data.type;
this.img = UI.Sp(this, "back.png", 0, 0);
this.img = UI.Sp(this, this.uiConfig.cardBackBg, 0, 0);
this.img.anchorX = 70;
this.img.anchorY = 133;
this.addEventListener(
......@@ -237,7 +239,7 @@ class Card extends FYGE.Container {
this.isFront = true;
this.onOverTurn(this, () => {
if (lastIndex > -1) {
console.log(data.list[lastIndex].type, data.type)
console.log(data.list[lastIndex].type, data.type);
if (data.list[lastIndex].type === data.type) {
const tempIndex = lastIndex;
lastIndex = -1;
......@@ -283,10 +285,12 @@ class Card extends FYGE.Container {
)
.call(() => {
if (that.match) {
that.img.texture = FYGE.Texture.fromUrl("back.png");
that.img.texture = FYGE.Texture.fromUrl(this.uiConfig.cardBackBg);
that.match = false;
} else {
that.img.texture = FYGE.Texture.fromUrl(that.type + ".png");
that.img.texture = FYGE.Texture.fromUrl(
this.uiConfig["cardFontBg" + that.type]
);
that.match = true;
}
FYGE.Tween.get(that.img)
......@@ -348,6 +352,7 @@ class Card extends FYGE.Container {
class GuideCard extends FYGE.Container {
img;
uiConfig = Tools.gameData.uiConfig;
public isFront = false; // 是否正面
public match = false; // 是否匹配
public type; // 类型
......@@ -362,7 +367,7 @@ class GuideCard extends FYGE.Container {
}
initUi(data) {
this.type = data.type;
this.img = UI.Sp(this, "back.png", 0, 0);
this.img = UI.Sp(this, this.uiConfig.cardBackBg, 0, 0);
this.img.anchorX = 70;
this.img.anchorY = 133;
if (data.index == 2) {
......@@ -379,10 +384,12 @@ class GuideCard extends FYGE.Container {
)
.call(() => {
if (that.match) {
that.img.texture = FYGE.Texture.fromUrl("back.png");
that.img.texture = FYGE.Texture.fromUrl(this.uiConfig.cardBackBg);
that.match = false;
} else {
that.img.texture = FYGE.Texture.fromUrl(that.type + ".png");
that.img.texture = FYGE.Texture.fromUrl(
this.uiConfig["cardFontBg" + that.type]
);
that.match = true;
}
FYGE.Tween.get(that.img)
......
......@@ -20,28 +20,28 @@ export const cardTypeList = {
// 游戏列表
export const list = [
{
type: 1
type: 1,
},
{
type: 2
type: 2,
},
{
type: 1
type: 1,
},
{
type: 2
type: 2,
},
{
type: 3
type: 3,
},
{
type: 3
type: 3,
},
{
type: 4
type: 4,
},
{
type: 4
type: 4,
},
];
// 新手引导列表
......@@ -95,3 +95,23 @@ export const guideList = [
match: false,
},
];
export const defaultUI = {
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",
serviceBtn:
"https://yun.duiba.com.cn/aurora/assets/307a139dd1ec7a7e6b552faf17fd35c9e7032b10.png",
mainBtn:
"https://yun.duiba.com.cn/aurora/assets/5c56beda337c4513d7d6eeaee4da377a7090b3d2.png",
};
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