Commit b4122601 authored by Master Q's avatar Master Q

就这样吧

parent 90ced5ad
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
"@babel/preset-typescript" "@babel/preset-typescript"
], ],
"plugins": [ "plugins": [
["@babel/plugin-transform-runtime", { // ["@babel/plugin-transform-runtime", {
// "corejs": 3 // // "corejs": 3
}], // }],
["@babel/plugin-proposal-decorators", { "legacy": true }], ["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-optional-chaining", "@babel/plugin-proposal-optional-chaining",
"./babel-plugins/babel-plugins-test.js" "./babel-plugins/babel-plugins-test.js"
......
...@@ -52,6 +52,15 @@ ...@@ -52,6 +52,15 @@
<!-- 这里的 bundle 就是 webpack 临时打包出来 --> <!-- 这里的 bundle 就是 webpack 临时打包出来 -->
<script src="output.js"></script> <script src="output.js"></script>
<script type="module"> <script type="module">
const app = {
checkMember: () => {
return false;
}
};
function getApp() {
return app;
}
window.addEventListener("load", function () { window.addEventListener("load", function () {
const canvas = document.getElementById('stage') const canvas = document.getElementById('stage')
canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1) canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1)
......
...@@ -6027,6 +6027,7 @@ export class Container extends DisplayObject { ...@@ -6027,6 +6027,7 @@ export class Container extends DisplayObject {
isInDisplay: any; isInDisplay: any;
sw: number; sw: number;
sh: number; sh: number;
_index: number;
constructor(); constructor();
/** /**
* children改变时触发,暂时没地方用到,考虑废弃 * children改变时触发,暂时没地方用到,考虑废弃
......
This diff is collapsed.
This diff is collapsed.
{
"success": true,
"data": {
"name": "123123",
"image": "http://qnpic.top/yoona2.jpg",
"type": 2
}
}
\ No newline at end of file
{
"success": true
}
\ No newline at end of file
...@@ -10,13 +10,13 @@ ...@@ -10,13 +10,13 @@
"dev": "node ./scripts/devServer.js", "dev": "node ./scripts/devServer.js",
"flushRes": "node scripts/flushRes", "flushRes": "node scripts/flushRes",
"handleLotS": "node scripts/handleLotS", "handleLotS": "node scripts/handleLotS",
"handleRes": "node scripts/delRel && node scripts/copyRes && node scripts/imageMin.js", "handleRes": "node scripts/delRel && node scripts/copyRes && node scripts/createTm && node scripts/textureMerge && node scripts/delTm && node scripts/imageMin",
"upload": "node scripts/upload", "upload": "node scripts/upload",
"prod": "npm run handleRes && npm run upload && npm run buildTS", "prod": "npm run handleRes && npm run upload && npm run buildTS",
"buildWeb": "npm run handleRes && node scripts/upload 1", "buildWeb": "npm run handleRes && node scripts/upload 1",
"buildTS": "webpack --config webpack.prod.js && node scripts/mergeJs", "buildTS": "webpack --config webpack.prod.js && node scripts/mergeJs",
"babelbuild": "babel src --out-dir dist --extensions .ts,.tsx", "babelbuild": "babel src --out-dir dist --extensions .ts,.tsx",
"build": "webpack --config webpack.prod.js", "build": "npm run handleRes && node scripts/mergeJson && node scripts/upload && npm run buildTS",
"check-type": "tsc --watch" "check-type": "tsc --watch"
}, },
"author": "", "author": "",
......
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
"keys": "DSM1.png,DSMB.png", "keys": "DSM1.png,DSMB.png",
"name": "DrawSucModal" "name": "DrawSucModal"
}, },
{
"keys": "FGM1.png,FGMB.png",
"name": "FinalGiftModal"
},
{ {
"keys": "2b727ace1b5c959dbc6274cacb5b4e5f.png,3ed4431aad269ef7059929043bd45597.png,60377934f7cf618b52457273db65aace.png,9074d1305c0e7feb16037261986c7f4b.png,f3bde4659477f82338fcb2b134272321.png", "keys": "2b727ace1b5c959dbc6274cacb5b4e5f.png,3ed4431aad269ef7059929043bd45597.png,60377934f7cf618b52457273db65aace.png,9074d1305c0e7feb16037261986c7f4b.png,f3bde4659477f82338fcb2b134272321.png",
"name": "GameAtom" "name": "GameAtom"
...@@ -32,12 +36,20 @@ ...@@ -32,12 +36,20 @@
"keys": "back.png,bottomAtom.png,gele1.png,goBackBtn.png,player.png,scoreboard-t.png", "keys": "back.png,bottomAtom.png,gele1.png,goBackBtn.png,player.png,scoreboard-t.png",
"name": "GameScene" "name": "GameScene"
}, },
{
"keys": "2120075482341d7d94d8164b1a0f6d43.png,3ed4431aad269ef7059929043bd45597.png,4f4612689c9fde32a8c28c129e9f6e7d.png,60377934f7cf618b52457273db65aace.png,63b0a84f0f9b10842b5f83fa5e923534.png,f3bde4659477f82338fcb2b134272321.png",
"name": "JumpEnd"
},
{ {
"keys": "Guide1.png,NGSB.jpg,nextStep.png,startGameBtn.png", "keys": "Guide1.png,NGSB.jpg,nextStep.png,startGameBtn.png",
"name": "NewGuyScene" "name": "NewGuyScene"
}, },
{ {
"keys": "closebtn.png,giftBoxIcon.png", "keys": "2120075482341d7d94d8164b1a0f6d43.png",
"name": "PerfectJumpEnd"
},
{
"keys": "closebtn.png,giftBoxIcon.png,waitingBg.png,waitingRot.png",
"name": "common" "name": "common"
}, },
{ {
......
var fs = require("fs");
var iconv = require('iconv-lite');
var del = require('del');
var readPath = "./released/resource/";
//读取json文件
var data = iconv.decode(fs.readFileSync(readPath + "res.json"), "utf-8");//GBK
//反序列化
data = JSON.parse(data); //eval(data)
//取出里面的图片,暂存到tm文件夹中,同时删除文件夹里的,和本身json里的
if (!fs.existsSync("./released/tm"))
fs.mkdirSync("./released/tm");
for (var i = 0; i < data.groups.length; i++) {
var name = data.groups[i].name;
var path = readPath + name + "/";
var arr = data.groups[i].keys.split(",");
//取出图片的,注意已排除jpg
var images = arr.filter((f) => { return (f.substr(-4) == ".png" /*|| f.substr(-4) == ".jpg"*/) })
//没有图片,
if (!images.length) continue;
//去掉原先数据里的
// data.groups[i].keys = arr.filter((f) => { return (f.substr(-4) != ".png" && f.substr(-4) != ".jpg") }).join(",");
//添加新的json,加到atlas里
// if (data.groups[i].keys) data.groups[i].keys += ","
data.groups[i].atlas = name + ".json"
//读取原先路径里的图片,写到tm的文件夹里,并删除原文件夹里的图片
fs.mkdirSync("./released/tm/" + name);
for (var m = 0; m < images.length; m++) {
fs.writeFileSync(
"./released/tm/" + name + "/" + images[m],
fs.readFileSync(path + images[m])
)
del(path + images[m])
}
}
//序列化
fs.writeFileSync(readPath + "res.json", JSON.stringify(data, "", "\t"));
var del = require('del');
del("./released/tm")
\ No newline at end of file
var fs = require("fs");
var path = require('path');
var del = require('del');
var iconv = require('iconv-lite');
const join = require('path').join;
//写入图集的文件夹,将文件夹内所有的json合并,并删除原先json
var readPath = "./released/resource/";
//读取json文件
var data = iconv.decode(fs.readFileSync(readPath + "res.json"), "utf-8");//GBK
//反序列化
data = JSON.parse(data);
var files = fs.readdirSync(readPath);
// let obj = {};
let count = 0;
let countAll = files.length
files.forEach(function (file) {
//路径
let fPath = join(readPath, file);
//只处理文件夹
if (fs.statSync(fPath).isDirectory()) {
//读文件夹fPath里的json文件
fs.readdir(fPath, function (err, files) {
if (err) {
console.warn(err)
} else {
var hasJson
//遍历
for (var i = 0; i < files.length; i++) {
let filename = files[i];
if (filename.indexOf(".json") == -1) continue
hasJson = true;
//获取当前文件的绝对路径
let filedir = path.join(fPath, filename);
let content = fs.readFileSync(filedir, 'utf-8');
let group = getGroupByName(filename.replace(".json", ""), data.groups)
group.atlas = JSON.parse(content);
//删除原先json
del(filedir)
if (++count == countAll) endFun();
}
if(!hasJson)if (++count == countAll) endFun();
//序列化,不格式化,节省内存
}
})
} else {
if (++count == countAll) endFun();
}
})
function endFun() {
console.log("资源配置js生成完毕")
// del(join(readPath, "res.json"))
fs.writeFileSync(readPath + "res.json", JSON.stringify(data, "", "\t"));
}
function getGroupByName(name, groups) {
var group;
for (var i = 0; i < groups.length; i++) {
if (groups[i].name === name) {
group = groups[i];
break;
}
}
return group
}
This source diff could not be displayed because it is too large. You can view the blob instead.
const fs = require("fs");
const exec = require('child_process').exec;
const del = require('del');
const join = require('path').join;
// const packTextures = require("pack_textures");
//写入图集的文件夹
const outPath = "./released/resource/";
//读取散图的文件夹
const readPath = "./released/tm/";
const files = fs.readdirSync(readPath);
files.forEach(function (file) {
//路径
let fPath = join(readPath, file);
//只处理文件夹
if (fs.statSync(fPath).isDirectory()) {
//判断文件夹内是否有图片
if (!judgeHasImage(fPath)) return;
//如果文件夹不存在
if (!fs.existsSync(outPath + file)) {
fs.mkdirSync(outPath + file);
} else {
//图集文件存在就删除
if (fs.existsSync(outPath + file + "/" + file + ".json")) {
del(outPath + file + "/" + file + ".json")
}
if (fs.existsSync(outPath + file + "/" + file + ".png")) {
del(outPath + file + "/" + file + ".png")
}
}
// packTextures(
// fPath,
// outPath + file + "/" + file,
// 4096,
// 4096,
// false,
// 2,
// 2,
// true,
// true
// )
//全局命令装过,就直接用命令行
exec(
'packTextures' + //基础指令
' -i ' + fPath + //要合图集的文件夹路径
' -o ' + outPath + file + "/" + file + //输出路径及名字
' --mw ' + 4096 + //最大宽度
' --mh ' + 4096 +//最大高度
' -p ' + false + //长宽是否2的指数,canvas下没必要,false
' --sp ' + 2 + //图片间隔
' --bp ' + 2 + //边界间隔
' -r ' + true + //是否允许图片旋转
' -t ' + true //是否允许裁切图片边缘透明像素
,
{ encoding: 'utf8' },
(e) => {
if (e) return console.log(e);
console.log("生成图集:" + file);
}
)
}
})
/**
* 判断文件夹内是否有图片
* @param {*} path
*/
function judgeHasImage(path) {
const files = fs.readdirSync(path);
for (let i = 0; i < files.length; i++) {
const itm = files[i];
const stat = fs.statSync(path + "/" + itm);
if (stat.isDirectory()) {
//递归读取文件
if (judgeHasImage(path + "/" + itm + "/")) return true;
} else {
if (itm.substr(-4) === ".jpg" || itm.substr(-4) === ".png") return true;
}
}
return false;
}
...@@ -24,8 +24,8 @@ class TuiaAutoUpload { ...@@ -24,8 +24,8 @@ class TuiaAutoUpload {
var _this = this; var _this = this;
this.client = new OSS({ this.client = new OSS({
region: 'oss-cn-hangzhou', region: 'oss-cn-hangzhou',
accessKeyId: 'LTAI4Fw25WcfcGv7FvcHoiHK', accessKeyId: 'LTAI5tAEU43ff2kFkrKRLnxG',
accessKeySecret: 'NZk1NtT9J5HFaAolNbtQdzTzLLvLYm', accessKeySecret: '2qQIPVT3Lgp72s8RShDlE4uVNqZWgy',
bucket: _this.type === 'prod' ? 'duiba' : 'daily-duiba' bucket: _this.type === 'prod' ? 'duiba' : 'daily-duiba'
}); });
this.bar = new ProgressBar(chalk.yellow(` 文件上传中 [:bar] :current/${this.files().length} :percent :elapseds`), { this.bar = new ProgressBar(chalk.yellow(` 文件上传中 [:bar] :current/${this.files().length} :percent :elapseds`), {
......
...@@ -39,8 +39,8 @@ function uploadSingleJs(url) { ...@@ -39,8 +39,8 @@ function uploadSingleJs(url) {
const originPath = `/db_games/${url}/output.js`; const originPath = `/db_games/${url}/output.js`;
var client = new OSS({ var client = new OSS({
region: 'oss-cn-hangzhou', region: 'oss-cn-hangzhou',
accessKeyId: 'LTAI4Fw25WcfcGv7FvcHoiHK', accessKeyId: 'LTAI5tAEU43ff2kFkrKRLnxG',
accessKeySecret: 'NZk1NtT9J5HFaAolNbtQdzTzLLvLYm', accessKeySecret: '2qQIPVT3Lgp72s8RShDlE4uVNqZWgy',
bucket: 'duiba' bucket: 'duiba'
}) })
var originFile; var originFile;
......
...@@ -92,7 +92,7 @@ export function createElement<K extends new(p?: any) => ChildType, T extends Chi ...@@ -92,7 +92,7 @@ export function createElement<K extends new(p?: any) => ChildType, T extends Chi
// 简单点直接赋值 // 简单点直接赋值
for (let k in inlineProps) { for (let k in inlineProps) {
// @ts-ignore 里面是 getter 和 setter 写的 // @ts-ignore 里面是 getter 和 setter 写的
(eleins[k] = inlineProps[k]) inlineProps[k] !== undefined && (eleins[k] = inlineProps[k])
} }
} }
......
...@@ -3,6 +3,13 @@ import { RenderContainer } from "./renderContainer"; ...@@ -3,6 +3,13 @@ import { RenderContainer } from "./renderContainer";
import { EventsMap } from "./types"; import { EventsMap } from "./types";
import { nextTick } from "./utils"; import { nextTick } from "./utils";
export type DreamProps<T extends Record<string, any>, R = FYGE.Container> = {
ref?: (c: R) => void,
inlineProps?: Record<string, any>
className?: string
children?: FYGE.Container[], // 这样写的话,外面也能提示了 -。-
} & T
export type DreamFC<T extends Record<string, any> = {}, R extends any = FYGE.Container> = (props: { export type DreamFC<T extends Record<string, any> = {}, R extends any = FYGE.Container> = (props: {
ref?: (c: R) => void, ref?: (c: R) => void,
inlineProps?: Record<string, any> inlineProps?: Record<string, any>
......
This diff is collapsed.
...@@ -11,7 +11,7 @@ export const DreamSprite: OriginalElementWidthEvents<{ ...@@ -11,7 +11,7 @@ export const DreamSprite: OriginalElementWidthEvents<{
width?: number, width?: number,
height?: number, height?: number,
sizeType?: SpriteSizeType sizeType?: SpriteSizeType
}> = (props) => { }, FYGE.Sprite> = (props) => {
const { const {
src, src,
width, width,
......
import Dream from "../../Dream";
import { DreamContainer } from "../DreamContainer/DreamContainer";
import { DreamShape } from "../DreamShape/DreamShape";
import { DreamTextField } from "../DreamTextField/DreamTextField";
export class DreamToast extends Dream.RenderContainer {
render() {
return (
<DreamContainer>
<DreamShape drawData={[0, 0, 460, 130]} alpha={0.8} />
<DreamTextField
text={this.props.msg}
size={28}
color='#ffffff'
verticalAlign={FYGE.VERTICAL_ALIGN.MIDDLE}
textWidth={460}
textHeight={130}
/>
</DreamContainer>
)
}
}
\ No newline at end of file
import Dream from "../../Dream";
import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload";
import { DreamContainer } from "../DreamContainer/DreamContainer";
import { DreamSprite } from "../DreamSprite/DreamSprite";
import { DreamTextField } from "../DreamTextField/DreamTextField";
@UsePreload({
async preAction() {
await RES.loadGroup('common')
},
loadingComponent: null
})
export class DreamWaiting extends Dream.RenderContainer<{
msg?: string
}> {
render() {
const roleCont = RES.getRes('waitingBg.png')
const rotCont = RES.getRes('waitingRot.png')
let count = 0
const {
msg = '加载中...'
} = this.props
return (
<DreamContainer>
<DreamSprite src={roleCont} />
<DreamSprite src={rotCont} inlineProps={{
y: 55,
x: roleCont.width / 2 - rotCont.width / 2,
anchorX: rotCont.width / 2,
anchorY: rotCont.height / 2
}} onEnterFrame={(e) => {
count++
if (count % 30 == 0) {
(e.target as FYGE.Sprite).rotation += 45
}
}} />
<DreamTextField text={msg} color='#ffffff' size={26} textWidth={roleCont.width} inlineProps={{
y: 126
}} />
</DreamContainer>
)
}
}
\ No newline at end of file
...@@ -5,6 +5,7 @@ import { ResJson } from "./ResJson"; ...@@ -5,6 +5,7 @@ import { ResJson } from "./ResJson";
import { GameScene } from "./scenes/GameScene/GameScene"; import { GameScene } from "./scenes/GameScene/GameScene";
import { HomeScene } from "./scenes/home"; import { HomeScene } from "./scenes/home";
import { NewGuyScene } from "./scenes/NewGuyScene/NewGuyScene"; import { NewGuyScene } from "./scenes/NewGuyScene/NewGuyScene";
import { Tools } from "./tools/Tools";
import Tween = FYGE.Tween; import Tween = FYGE.Tween;
import EventDispatcher = FYGE.EventDispatcher; import EventDispatcher = FYGE.EventDispatcher;
import Stage = FYGE.Stage; import Stage = FYGE.Stage;
...@@ -12,6 +13,16 @@ import RENDERER_TYPE = FYGE.RENDERER_TYPE ...@@ -12,6 +13,16 @@ import RENDERER_TYPE = FYGE.RENDERER_TYPE
import Event = FYGE.Event import Event = FYGE.Event
import getEnv = FYGE.getEnv; import getEnv = FYGE.getEnv;
/**
* 全局事件,为了和小程序交互
* 有可能多处页面用到,所以单开
*/
export const GDispatcher = new EventDispatcher();
export const loadAllGroups = async function() {
await RES.loadAllGroup()
}
export class Main { export class Main {
//主舞台 //主舞台
stage: Stage; stage: Stage;
...@@ -21,6 +32,10 @@ export class Main { ...@@ -21,6 +32,10 @@ export class Main {
constructor( constructor(
canvas: HTMLCanvasElement, canvas: HTMLCanvasElement,
config: {
isFirstGame: boolean,
liveCard: number
},
desWidth = 750, desWidth = 750,
desHeight = 1624, desHeight = 1624,
divWidth?: number, divWidth?: number,
...@@ -31,6 +46,7 @@ export class Main { ...@@ -31,6 +46,7 @@ export class Main {
resolution?: any, resolution?: any,
) { ) {
let sysInfo; let sysInfo;
config && (Tools.PageData = config)
// 淘宝小程序环境就用canvas初始化 // 淘宝小程序环境就用canvas初始化
if (!window) { // 自行处理吧,这么判断也不保险,万一淘宝小程序加进了window if (!window) { // 自行处理吧,这么判断也不保险,万一淘宝小程序加进了window
FYGE.initedByCanvas(canvas); // 里面会设置env为tb,这个很重要 FYGE.initedByCanvas(canvas); // 里面会设置env为tb,这个很重要
...@@ -90,7 +106,7 @@ export class Main { ...@@ -90,7 +106,7 @@ export class Main {
RES.loadConfig(ResJson) RES.loadConfig(ResJson)
await RES.loadGroup('common') await RES.loadGroup('common')
SceneController.changeScene(GameScene) SceneController.changeScene(Tools.PageData.isFirstGame ? NewGuyScene : GameScene)
} }
initWebEvent(){ initWebEvent(){
...@@ -104,6 +120,8 @@ export class Main { ...@@ -104,6 +120,8 @@ export class Main {
this._pause = false; this._pause = false;
// @ts-ignore Tween计时清零 // @ts-ignore Tween计时清零
Tween._lastTime = null; Tween._lastTime = null;
// 触发onShow
// GDispatcher.dispatchEvent({ type: G_EVENT.ON_SHOW });
} }
/** /**
...@@ -111,6 +129,43 @@ export class Main { ...@@ -111,6 +129,43 @@ export class Main {
*/ */
pause() { pause() {
// this._pause = true;//先不暂停了 // this._pause = true;//先不暂停了
// GDispatcher.dispatchEvent({ type: G_EVENT.ON_HIDE });
}
/**
* 添加全局事件,用于小程序的交互调用
* 一直很犹豫要不要放在main的实例里,还是和Main同级导出,还有上面的pause,run,下面的事件等
* @param name
* @param fun
* @param thisObj
* @param once
*/
addGlobalEvent(name: string, fun: Function, thisObj?: any, once: boolean = false) {
if (once) {
GDispatcher.once(name, fun, thisObj)
} else {
GDispatcher.addEventListener(name, fun, thisObj)
}
}
/**
* 派发全局事件,用于小程序的交互调用
* @param name 可以是事件名,也可以是事件
* @param data
*/
dispatchGlobalEvent(name: string | any, data?: any) {
GDispatcher.dispatchEvent(name, data)
}
/**
* 移除全局事件,用于小程序交互调用
* @param name
* @param fun
* @param thisObj
*/
removeGlobalEvent(name: string, fun: Function, thisObj?: any) {
GDispatcher.removeEventListener(name, fun, thisObj)
} }
//在小程序页面卸载时调用onUnload,多次销毁后会有问题,再检查 //在小程序页面卸载时调用onUnload,多次销毁后会有问题,再检查
......
This diff is collapsed.
This diff is collapsed.
...@@ -69,8 +69,9 @@ function ModalWraper(ModalNode: any) { ...@@ -69,8 +69,9 @@ function ModalWraper(ModalNode: any) {
// 这里做了 适配,不知道为什么 有些拿不到宽高 // 这里做了 适配,不知道为什么 有些拿不到宽高
if (ModalConfig?.center) { if (ModalConfig?.center) {
const body = this.ModalBody const body = this.ModalBody
const sw = body.sw || getBoundsPropty(body, 'width') // TODO 这里好像算的有点问题多 20
const sh = body.sh || getBoundsPropty(body, 'height') const sw = body.sw || getBoundsPropty(body, 'width') - 20
const sh = body.sh || getBoundsPropty(body, 'height') - 20
this.ModalBody.position.set(layers.stageWidth / 2 - sw / 2, layers.stageHeight / 2 - sh / 2) this.ModalBody.position.set(layers.stageWidth / 2 - sw / 2, layers.stageHeight / 2 - sh / 2)
} }
} }
......
...@@ -25,6 +25,44 @@ export function fadeOutFactory(t: number) { ...@@ -25,6 +25,44 @@ export function fadeOutFactory(t: number) {
} }
} }
export function fadeOutUpFactory(t: number, upLen: number = 200) {
return function(cont: FYGE.Container) {
return new Promise<void>(r => {
FYGE.Tween.removeTweens(cont)
const oy = cont.y
FYGE.Tween.get(cont, {
onChange: () => {
cont.y = (oy - upLen * (1 - cont.alpha))
}
})
.set({alpha: 1})
.to({
alpha: 0
}, t, FYGE.Ease.quadIn)
.call(() => {
setTimeout(() => {
cont.y = oy
})
r()
})
})
}
}
export function BounceOutAni(t: number = 1000) {
return function (cont: FYGE.Container) {
return new Promise(r => {
const oy = cont.position.y
cont.position.y -= 100
FYGE.Tween.get(cont)
.to({
y: oy
}, t, FYGE.Ease.bounceOut)
})
}
}
/** /**
* 因为一些不可抗因素导致拿不到最后的 真是宽高 * 因为一些不可抗因素导致拿不到最后的 真是宽高
* @param Con * @param Con
......
...@@ -11,6 +11,12 @@ import { UsePreload } from "../../modules/UseDecorator/usePreload"; ...@@ -11,6 +11,12 @@ import { UsePreload } from "../../modules/UseDecorator/usePreload";
loadingComponent: null loadingComponent: null
}) })
export class DrawFailModal extends Dream.RenderContainer { export class DrawFailModal extends Dream.RenderContainer {
onConfirm = () => {
this.props.onConfirm()
this.props.closeModal()
}
render() { render() {
const roleCont = RES.getRes('DFMB.png') const roleCont = RES.getRes('DFMB.png')
const confirmbtn = RES.getRes('DFM1.png') const confirmbtn = RES.getRes('DFM1.png')
...@@ -19,14 +25,11 @@ export class DrawFailModal extends Dream.RenderContainer { ...@@ -19,14 +25,11 @@ export class DrawFailModal extends Dream.RenderContainer {
<DreamContainer> <DreamContainer>
<DreamSprite src={roleCont} /> <DreamSprite src={roleCont} />
<DreamSprite onClick={() => { <DreamSprite onClick={this.onConfirm} inlineProps={{
// TODO
this.props.closeModal()
}} inlineProps={{
x: roleCont.width - 50, x: roleCont.width - 50,
y: -50 y: -50
}} src={RES.getRes('closebtn.png')}/> }} src={RES.getRes('closebtn.png')}/>
<DreamSprite onClick={this.props.closeModal} inlineProps={{ <DreamSprite onClick={this.onConfirm} inlineProps={{
x: roleCont.width / 2 - confirmbtn.width / 2, x: roleCont.width / 2 - confirmbtn.width / 2,
y: 300 y: 300
}} src={confirmbtn}/> }} src={confirmbtn}/>
......
...@@ -4,6 +4,7 @@ import { DreamTextField } from "../../components/DreamTextField/DreamTextField"; ...@@ -4,6 +4,7 @@ import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
import Dream from "../../Dream"; import Dream from "../../Dream";
import { RES } from "../../modules/RES"; import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload"; import { UsePreload } from "../../modules/UseDecorator/usePreload";
import { sendTbNet, TbNetName } from "../../tools/TbNet";
@UsePreload({ @UsePreload({
resList: [], resList: [],
...@@ -14,15 +15,21 @@ import { UsePreload } from "../../modules/UseDecorator/usePreload"; ...@@ -14,15 +15,21 @@ import { UsePreload } from "../../modules/UseDecorator/usePreload";
}) })
export class DrawSucModal extends Dream.RenderContainer<{ export class DrawSucModal extends Dream.RenderContainer<{
closeModal: () => Promise<any>, closeModal: () => Promise<any>,
onConfirm: () => void
name: string, name: string,
img: string img: string
}> { }> {
onConfirm = () => { onClose2GameOver = () => {
// TODO 回到首页? this.props.onConfirm()
this.props.closeModal() this.props.closeModal()
} }
onConfirm = () => {
// sendTbNet(TbNetName.goMyPrize)
this.onClose2GameOver()
}
render() { render() {
const roleCont = RES.getRes('DSMB.png') const roleCont = RES.getRes('DSMB.png')
const confirmbtn = RES.getRes('DSM1.png') const confirmbtn = RES.getRes('DSM1.png')
...@@ -36,8 +43,7 @@ export class DrawSucModal extends Dream.RenderContainer<{ ...@@ -36,8 +43,7 @@ export class DrawSucModal extends Dream.RenderContainer<{
<DreamSprite src={roleCont}></DreamSprite> <DreamSprite src={roleCont}></DreamSprite>
<DreamSprite onClick={() => { <DreamSprite onClick={() => {
// TODO this.onClose2GameOver()
this.props.closeModal()
}} inlineProps={{ }} inlineProps={{
x: roleWidth - 50 x: roleWidth - 50
}} src={RES.getRes('closebtn.png')}/> }} src={RES.getRes('closebtn.png')}/>
......
import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import Dream from "../../Dream";
import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload";
@UsePreload({
preAction: async() => {
await RES.loadGroup('FinalGiftModal')
}
})
export class FinalGiftModal extends Dream.RenderContainer {
onConfirm() {
this.props.onConfirm()
}
render() {
const roleCont = RES.getRes('FGMB.png')
const confirmbtn = RES.getRes('FGM1.png')
return (
<DreamContainer>
<DreamSprite src={roleCont} />
<DreamSprite src={confirmbtn} onClick={this.onConfirm.bind(this)} inlineProps={{
x: roleCont.width / 2 - confirmbtn.width / 2,
y: 500
}} />
</DreamContainer>
)
}
}
\ No newline at end of file
...@@ -5,6 +5,7 @@ import { RES } from "../../modules/RES"; ...@@ -5,6 +5,7 @@ import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload"; import { UsePreload } from "../../modules/UseDecorator/usePreload";
import Dream from "../../Dream"; import Dream from "../../Dream";
import { DreamTextField } from "../../components/DreamTextField/DreamTextField"; import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
import { sendTbNet, TbNetName } from "../../tools/TbNet";
console.log(Dream) console.log(Dream)
@UsePreload({ @UsePreload({
...@@ -16,12 +17,12 @@ export class GameOverModal extends ModalComponent<{ ...@@ -16,12 +17,12 @@ export class GameOverModal extends ModalComponent<{
score: number score: number
}> { }> {
onCancel() { onCancel() {
// TODO 回到首页 sendTbNet(TbNetName.goBackHome)
this.props.closeModal() this.props.closeModal()
} }
onConfirm() { onConfirm() {
// TODO 显示复活卡弹窗 sendTbNet(TbNetName.openCardTask)
} }
......
...@@ -4,6 +4,7 @@ import { DreamTextField } from "../../components/DreamTextField/DreamTextField"; ...@@ -4,6 +4,7 @@ import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
import Dream from "../../Dream"; import Dream from "../../Dream";
import { RES } from "../../modules/RES"; import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload"; import { UsePreload } from "../../modules/UseDecorator/usePreload";
import { sendTbNet, TbNetName } from "../../tools/TbNet";
@UsePreload({ @UsePreload({
async preAction() { async preAction() {
...@@ -16,8 +17,8 @@ export class GameQuitModal extends Dream.RenderContainer<{ ...@@ -16,8 +17,8 @@ export class GameQuitModal extends Dream.RenderContainer<{
}> { }> {
onConfirm = () => { onConfirm = () => {
// TODO
this.props.closeModal() this.props.closeModal()
sendTbNet(TbNetName.goBackHome)
} }
render() { render() {
......
...@@ -5,6 +5,7 @@ import Dream from "../../Dream"; ...@@ -5,6 +5,7 @@ import Dream from "../../Dream";
import { DreamSpriteV2 } from "../../Dream/UI"; import { DreamSpriteV2 } from "../../Dream/UI";
import { RES } from "../../modules/RES"; import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload"; import { UsePreload } from "../../modules/UseDecorator/usePreload";
import { sendTbNet, TbNetName } from "../../tools/TbNet";
@UsePreload({ @UsePreload({
preAction: async function() { preAction: async function() {
...@@ -15,6 +16,8 @@ import { UsePreload } from "../../modules/UseDecorator/usePreload"; ...@@ -15,6 +16,8 @@ import { UsePreload } from "../../modules/UseDecorator/usePreload";
export class GameResumeModal extends Dream.RenderContainer<{ export class GameResumeModal extends Dream.RenderContainer<{
resumeNum: number, resumeNum: number,
closeModal: () => Promise<any> closeModal: () => Promise<any>
onConfirm: () => void
onCancel: () => Promise<void>
}> { }> {
countTextField: FYGE.TextField countTextField: FYGE.TextField
intervalId: any intervalId: any
...@@ -46,9 +49,17 @@ export class GameResumeModal extends Dream.RenderContainer<{ ...@@ -46,9 +49,17 @@ export class GameResumeModal extends Dream.RenderContainer<{
/** /**
* 确认走复活逻辑 * 确认走复活逻辑
*/ */
onConfirm = () => { onConfirm = async () => {
// TODO 走下接口 const {
success
} = await sendTbNet(TbNetName.reduceTools)
if (success) {
this.props.onConfirm()
this.props.closeModal() this.props.closeModal()
} else {
this.props.closeModal()
}
} }
render() { render() {
...@@ -77,7 +88,10 @@ export class GameResumeModal extends Dream.RenderContainer<{ ...@@ -77,7 +88,10 @@ export class GameResumeModal extends Dream.RenderContainer<{
x: RoleContWidth / 2 - cancelBtn.width / 2, x: RoleContWidth / 2 - cancelBtn.width / 2,
y: 320 + confirmBtn.height + 20 y: 320 + confirmBtn.height + 20
}} }}
onClick={this.props.closeModal} onClick={async () => {
this.props.onCancel()
this.props.closeModal()
}}
> >
<DreamTextField ref={el=> { <DreamTextField ref={el=> {
this.countTextField = el this.countTextField = el
......
...@@ -9,71 +9,142 @@ export enum BoxType { ...@@ -9,71 +9,142 @@ export enum BoxType {
Box8 = 'Box8', Box8 = 'Box8',
} }
export const BoxTypeList: BoxType[] = [
BoxType.Box1,
BoxType.Box2,
BoxType.Box3,
BoxType.Box4,
BoxType.Box5,
BoxType.Box6,
BoxType.Box7,
BoxType.Box8
]
export const GameConfig = { export const GameConfig = {
debugger: true,
GenerateSpace: [300, 400], // 生成间距
finalGiftPart: 0.1, // 最终奖励 概率 100%
maxLen: 550,
totoalPart: 0, // 全部概率
PartList: [] as {
preSumPart: number,
type: BoxType
}[], // 概率
GenerateConfig: {
angle: Math.PI * 40 / 180,
tanNum: Math.tan(Math.PI * 40 / 180)
},
CameraConfig: {
pos: {
x: 375,
y: 1100
},
},
GameStagePos: {
x: 160,
y: 1200
},
boxConfig: { boxConfig: {
[BoxType.Box1]: { [BoxType.Box1]: {
resName: 'box1.png', resName: 'box1.png',
addScore: 5, addScore: 5,
oc: { oc: {
x: 200, y: 100 // 判断中心点 x: 142, y: 230 // 判断中心点
}, },
oz: 60 // height oz: 90, // height
dt: [-60, 50],
part: 10
}, },
[BoxType.Box2]: { [BoxType.Box2]: {
resName: 'box2.png', resName: 'box2.png',
addScore: 5, addScore: 5,
oc: { oc: {
x: 200, y: 100 x: 142, y: 230
}, },
oz: 60 oz: 60,
dt: [-50, 50],
part: 10
}, },
[BoxType.Box3]: { [BoxType.Box3]: {
resName: 'box3.png', resName: 'box3.png',
addScore: 5, addScore: 5,
oc: { oc: {
x: 200, y: 100 x: 142, y: 230
}, },
oz: 60 oz: 140,
dt: [-50, 50],
part: 10
}, },
[BoxType.Box4]: { [BoxType.Box4]: {
resName: 'box4.png', resName: 'box4.png',
addScore: 5, addScore: 5,
oc: { oc: {
x: 200, y: 100 x: 142, y: 250
}, },
oz: 60 oz: 160,
dt: [-40, 40],
part: 10
}, },
[BoxType.Box5]: { [BoxType.Box5]: {
resName: 'box5.png', resName: 'box5.png',
addScore: 5, addScore: 5,
oc: { oc: {
x: 200, y: 100 x: 142, y: 260
}, },
oz: 60 oz: 60,
dt: [-40, 40],
part: 10
}, },
[BoxType.Box6]: { [BoxType.Box6]: {
resName: 'box6.png', resName: 'box6.png',
addScore: 5, addScore: 5,
oc: { oc: {
x: 200, y: 100 x: 142, y: 230
}, },
oz: 60 oz: 70,
dt: [-50, 50],
part: 10
}, },
[BoxType.Box7]: { [BoxType.Box7]: {
resName: 'box7.png', resName: 'box7.png',
addScore: 5, addScore: 5,
oc: { oc: {
x: 200, y: 100 x: 142, y: 360
}, },
oz: 60 oz: 300,
dt: [-50, 50],
part: 4
}, },
[BoxType.Box8]: { [BoxType.Box8]: {
resName: 'box8.png', resName: 'box8.png',
addScore: 5, addScore: 5,
oc: { oc: {
x: 200, y: 100 x: 142, y: 360
}, },
oz: 60 oz: 305,
dt: [-40, 40],
part: 4
} }
} }
} }
let temp = []
for (let k in GameConfig.boxConfig) {
let kType: BoxType = k as any
temp.push(kType)
}
const tp: {
preSumPart: number,
type: BoxType
}[] = []
GameConfig.totoalPart = temp.reduce((pre, cur) => {
const tt = pre + GameConfig.boxConfig[cur].part
tp.push({
preSumPart: tt,
type: cur
})
return tt
}, 0)
GameConfig.PartList = tp
import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamShape } from "../../components/DreamShape/DreamShape";
import { DreamSprite } from "../../components/DreamSprite/DreamSprite"; import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import { DreamTextField } from "../../components/DreamTextField/DreamTextField"; import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
import Dream from "../../Dream"; import Dream, {DreamProps } from "../../Dream";
import { fadeOutUpFactory } from "../../modules/animations";
import { RES } from "../../modules/RES"; import { RES } from "../../modules/RES";
import { BoxType, BoxTypeList, GameConfig } from "./GameConfig";
type GameEleType = DreamProps<{
type?: BoxType,
x?: number,
y?: number,
inlineProps?: Record<string, any>
isWithGift?: boolean
}, GameEle>
export class GameEle extends Dream.RenderContainer<GameEleType> {
GameBoxType: BoxType = BoxType.Box1
GiftIcon: FYGE.Sprite
constructor(props: GameEleType) {
super(props)
const {
type
} = this.props
if (type) {
this.GameBoxType = type
} else {
this.GameBoxType = BoxTypeList[Math.random() * BoxTypeList.length >> 0]
}
}
didRendered(): void {
}
onGetGift() {
if (this.GiftIcon) {
fadeOutUpFactory(500, 200)(this.GiftIcon)
}
}
export class GameEle extends Dream.RenderContainer {
render() { render() {
const currGameBoxConfig = GameConfig.boxConfig[this.GameBoxType]
const boxRes = RES.getRes(currGameBoxConfig.resName)
const {
x,
y,
inlineProps,
isWithGift
} = this.props
const {
dt = [0, 0],
oc: {
x: ocx,
y: ocy
},
oz
} = currGameBoxConfig
const tanNum = Math.tan(GameConfig.GenerateConfig.angle)
// const offsetY = * Math.abs(spaceNum)
// console.log(boxRes, this.GameBoxType, GameConfig.boxConfig, currGameBoxConfig)
return ( return (
<FYGE.Container> <DreamContainer inlineProps={{
<DreamTextField text="12123" color="#ffffff"></DreamTextField> ...inlineProps,
<DreamSprite src={RES.getRes('产品8.png')} inlineProps={{ x,y
x: 200, }}>
y: 1000 <DreamContainer inlineProps={{
}}></DreamSprite> x: -currGameBoxConfig.oc.x,
</FYGE.Container> y: -currGameBoxConfig.oc.y
}}>
<DreamSprite src={boxRes}></DreamSprite>
{
isWithGift && (
<DreamSprite ref={el => {
this.GiftIcon = el
}} src={RES.getRes('giftBoxIcon.png')} inlineProps={{
x: currGameBoxConfig.oc.x - 60,
y: currGameBoxConfig.oc.y - 80 - currGameBoxConfig.oz,
}} />
)
}
{
GameConfig.debugger && (
<DreamContainer>
<DreamShape type="circle" drawData={[0,0, 8]} fillColor="#f17368" inlineProps={{
x: currGameBoxConfig.oc.x,
y: currGameBoxConfig.oc.y
}} />
<DreamShape type="circle" drawData={[0,0, 8]} fillColor="#f17368" inlineProps={{
x: ocx,
y: ocy - oz
}} />
<DreamShape type="circle" drawData={[0,0, 8]} fillColor="#f17368" inlineProps={{
x: ocx + dt[0],
y: ocy - oz + tanNum * Math.abs(dt[0])
}} ></DreamShape>
<DreamShape type="circle" drawData={[0,0, 8]} fillColor="#f17368" inlineProps={{
x: ocx + dt[1],
y: ocy - oz - tanNum * dt[1]
}} ></DreamShape>
</DreamContainer>
)
}
</DreamContainer>
</DreamContainer>
) )
} }
} }
\ No newline at end of file
This diff is collapsed.
import { DreamSpine } from "../../components/DreamSpine/DreamSpine"; import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamLottie } from "../../components/DreamLottie/DreamLottie";
import { DreamSpine, setSpineAni } from "../../components/DreamSpine/DreamSpine";
import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
import Dream from "../../Dream"; import Dream from "../../Dream";
import { JumpEnd } from "../../lotties/JumpEnd";
import { PerfectJumpEnd } from "../../lotties/PerfectJumpEnd";
import { fadeOutUpFactory } from "../../modules/animations";
import { RES } from "../../modules/RES"; import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload"; import { UsePreload } from "../../modules/UseDecorator/usePreload";
export enum PlayAniEnum { export enum PlayAniEnum {
Stand = 'daiji', Stand = 'daiji',
Jump = 'zuizhong' StandBy = 'dunxia1',
Jump = 'tiaoyue2'
}
const PlayerAction = {
JUMP: 'tiaoyue2',
STANDBY: 'dunxia1',
STAND: 'daiji'
}
export type PlayerIns = {
turnRound: (dir: 1 | -1) => void
jump: () => Promise<void>
jumpPrepare: () => Promise<void>
showJumpEndAtom: (score: number) => Promise<void>
} }
@UsePreload({ @UsePreload({
...@@ -15,19 +35,45 @@ export enum PlayAniEnum { ...@@ -15,19 +35,45 @@ export enum PlayAniEnum {
loadingComponent: null loadingComponent: null
}) })
export class Player extends Dream.RenderContainer<{ export class Player extends Dream.RenderContainer<{
getPlayer?: (ins: { getPlayer?: (ins: PlayerIns) => void
turnRound: (dir: 1 | -1) => void
target: FYGE.Spine
}) => void
inlineProps?: Record<string, any> inlineProps?: Record<string, any>
}> { }> {
SpineContainer: FYGE.Container
SpinePlayer: FYGE.Spine SpinePlayer: FYGE.Spine
AtomLottie: FYGE.Lottie
aniText: FYGE.TextField
didRendered(): void { didRendered(): void {
this.props.getPlayer && this.props.getPlayer({ this.props.getPlayer && this.props.getPlayer({
turnRound: (dir) => { turnRound: (dir) => {
this.SpinePlayer.scaleX = dir this.SpineContainer.scaleX = dir
},
jump: () => {
return new Promise(r => {
setSpineAni(this.SpinePlayer, PlayerAction.JUMP, 1 , () => {
setSpineAni(this.SpinePlayer, PlayerAction.STAND)
r()
})
})
},
showJumpEndAtom:(score: number) => {
return new Promise(r => {
this.AtomLottie.visible = true
this.aniText.text = `+${score}`
fadeOutUpFactory(500, 100)(this.aniText)
this.AtomLottie.play(1, () => {
this.AtomLottie.visible = false
r()
})
})
}, },
target: this.SpinePlayer jumpPrepare: () => {
return new Promise(r => {
setSpineAni(this.SpinePlayer, PlayerAction.STANDBY, 1 , () => {
r()
})
})
}
}) })
} }
...@@ -35,9 +81,33 @@ export class Player extends Dream.RenderContainer<{ ...@@ -35,9 +81,33 @@ export class Player extends Dream.RenderContainer<{
const PlayerSpineData = RES.getRes('rabbit.spi') const PlayerSpineData = RES.getRes('rabbit.spi')
return ( return (
<DreamContainer inlineProps={{
...this.props.inlineProps
}}>
<DreamTextField ref={el=> {
this.aniText = el
}} size={32} color="#fad99e" text="+0" textWidth={300} inlineProps={{
y: -210,
x: -150,
alpha: 0
}} ></DreamTextField>
<DreamContainer ref={el => {
this.SpineContainer = el
}}>
<DreamLottie ref={el => {
this.AtomLottie = el
}} inlineProps={{
x: -125,
y: -230,
visible: false
}} lottieData={JumpEnd} />
<DreamSpine ref={el => { <DreamSpine ref={el => {
this.SpinePlayer = el this.SpinePlayer = el
}} aniName={PlayAniEnum.Stand} spineData={PlayerSpineData} inlineProps={this.props.inlineProps}></DreamSpine> }} aniName={PlayAniEnum.Stand} spineData={PlayerSpineData} inlineProps={{
y: 10,x: -5
}}></DreamSpine>
</DreamContainer>
</DreamContainer>
) )
} }
} }
\ No newline at end of file
export class Stack<T extends any = number> {
list: T[] = []
get stackHead() {
return this.list[this.list.length - 1]
}
pushStack(item: T) {
this.list.push(item)
return item
}
popStack() {
return this.list.pop()
}
traverse(callbackfn: (value: T, index: number, array: T[]) => void) {
const sliceItems = this.list.slice(0)
sliceItems.forEach(callbackfn)
}
}
\ No newline at end of file
import { GDispatcher } from "..";
import { DreamToast } from "../components/DreamToast/DreamToast";
import { ModalCtroller } from "../modules/ModalControl";
//接口枚举,包括需要调用淘宝的api,用是否含有兑吧区分,或者单独区分
export enum TbNetName {
submitGame = 'mine.submitGame',
reduceTools = "mine.reduceTools",
goBackHome = "mine.goBackHome",
goMyPrize = "mine.goMyPrize",
onDrawLottery = "mine.onDrawLottery",
openCardTask = "mine.openCardTask"
}
async function fetchAsync(url: string) {
// await response of fetch call
let response = await fetch(url);
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
return data;
}
function showToast(msg: string) {
ModalCtroller.showModal(DreamToast, {
msg: msg
}, {
maskAlpha: 0
})
setTimeout(() => {
ModalCtroller.closeModal(DreamToast)
}, 1500)
}
//返回数据类型
interface dataOut {
success: boolean,
data?: any
code?: string,
message?: string
}
//记录数据
let dataRecord: {
[name: string]: any
} = {};
/**
* 发送接口
* @param netName
* @param parameter
* @param callback
* @param hideMsg
*/
export function sendTbNet(
netName: TbNetName,
parameter?: any,
callback?: (success: boolean, res?: dataOut) => void,
hideMsg: boolean = false
): Promise<dataOut> {
return new Promise((resolve, reject) => {
//网络超时
// let waitObj;
//@ts-ignore 本地开发,直接取数据
if (location.port == '8081') {
const netInfo = netName.split(".");
const url = `../../mock/miniTb/${netInfo[0]}/${netInfo[1]}.json`;
fetchAsync(url)
.then((data) => {
//清除超时
// clearWait(waitObj)
//记录数据
dataRecord[netName] = data;
//统一错误信息提示
if (!hideMsg && !data.success) showToast(data.message || "网络异常")
//回调
callback && callback(data.success, data);
resolve(data)
console.log(
`\n%c[ mock ]\n`
+ `NAME : ${netName} \n`
+ `STATE : %o \n`
+ `PARAM : %o \n`
+ `%cDATA : %o \n`
, `${data.success ? 'color:green' : 'color:red'}`
, data.success
, parameter
, `${data.success ? 'color:green' : 'color:red'}`
, data
);
}, () => {
resolve({ success: false, data: null });
})
return
}
let fun = function (e: { type: string, data: dataOut }) {
//清除超时记录
// clearWait(waitObj)
//移除事件
GDispatcher.removeEventListener(netName, fun);
var d = e.data;
//记录数据
dataRecord[netName] = d;
//统一错误信息提示,d.data为了区分网络超时
if (!hideMsg && !d.success) showToast(d.message || "网络超时")
//执行回调
callback && callback(d.success, d);
resolve(d)
console.log(
`\n%c[ request ]\n`
+ `NAME : ${netName} \n`
+ `STATE : %o \n`
+ `PARAM : %o \n`
+ `%cDATA : %o \n`
, `${d.success ? 'color:green' : 'color:red'}`
, d.success
, parameter
, `${d.success ? 'color:green' : 'color:red'}`
, d
);
}
//添加事件接收接口返回信息
GDispatcher.addEventListener(netName, fun);
//用事件方式吧,派发事件发接口,,,,注意很多独有的事件名别重了,onHide,onShow,onMessage等 放到最后,因为有同步的情况
GDispatcher.dispatchEvent({ type: "onMessage" }, { netName, parameter })
})
}
\ No newline at end of file
export class Tools {
static PageData: {
isFirstGame: boolean,
liveCard: number
} = {
isFirstGame: false,
liveCard: 1
}
}
\ No newline at end of file
// @ts-ignore
const app = getApp()
const audioIns = app?.audioContext
if (audioIns) {
audioIns.onPlay(() => {
console.log('播放')
})
audioIns.onError(() => {
console.log('audio error')
})
}
export function PlayAudio() {
audioIns && audioIns.play()
}
\ No newline at end of file
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