Commit 236101d0 authored by haiyoucuv's avatar haiyoucuv
parents b4735776 0eded96c
...@@ -1601,10 +1601,7 @@ var Lottie = (function (_super) { ...@@ -1601,10 +1601,7 @@ var Lottie = (function (_super) {
else if (xs.indexOf("cycle") >= 0 && data[data.length - 1].t < this.rawData.op) { else if (xs.indexOf("cycle") >= 0 && data[data.length - 1].t < this.rawData.op) {
var rr = xs.replace(/[^0-9]/ig, ""); var rr = xs.replace(/[^0-9]/ig, "");
var num = Math.round((this.rawData.op - data[data.length - 1 - rr].t) / (data[data.length - 1].t - data[data.length - 1 - rr].t)); var num = Math.round((this.rawData.op - data[data.length - 1 - rr].t) / (data[data.length - 1].t - data[data.length - 1 - rr].t));
objArr = objArr.slice(-(xs.replace(/[^0-9]/ig, ""))); objArr = objArr.slice(-rr);
if (dis["layerData"].nm == "bonus_light_11.png") {
console.log(dis.alpha);
}
while (--num) { while (--num) {
for (var o = 0; o < objArr.length; o++) { for (var o = 0; o < objArr.length; o++) {
tween.to(objArr[o].obj, objArr[o].deltaTime); tween.to(objArr[o].obj, objArr[o].deltaTime);
...@@ -1712,7 +1709,8 @@ var Main = (function () { ...@@ -1712,7 +1709,8 @@ var Main = (function () {
FYGE.Tween.flush(); FYGE.Tween.flush();
stage.flush(); stage.flush();
} }
self.requestID = FYGE.getRequestAnimationFrame()(loop); my ? self.requestID = canvas.requestAnimationFrame(loop) :
self.requestID = window.requestAnimationFrame(loop);
} }
} }
Main.prototype.onAddToStage = function () { Main.prototype.onAddToStage = function () {
...@@ -1737,10 +1735,12 @@ var Main = (function () { ...@@ -1737,10 +1735,12 @@ var Main = (function () {
}; };
Main.prototype.run = function () { Main.prototype.run = function () {
this._pause = false; this._pause = false;
exports.GDispatcher.dispatchEvent(G_EVENT_1.G_EVENT.ON_SHOW); FYGE.Tween._lastTime = null;
exports.GDispatcher.dispatchEvent({ type: G_EVENT_1.G_EVENT.ON_SHOW });
}; };
Main.prototype.pause = function () { Main.prototype.pause = function () {
exports.GDispatcher.dispatchEvent(G_EVENT_1.G_EVENT.ON_HIDE); this._pause = true;
exports.GDispatcher.dispatchEvent({ type: G_EVENT_1.G_EVENT.ON_HIDE });
}; };
Main.prototype.addGlobalEvent = function (name, fun, thisObj, once) { Main.prototype.addGlobalEvent = function (name, fun, thisObj, once) {
if (once === void 0) { once = false; } if (once === void 0) { once = false; }
...@@ -1759,7 +1759,8 @@ var Main = (function () { ...@@ -1759,7 +1759,8 @@ var Main = (function () {
}; };
Main.prototype.destroy = function () { Main.prototype.destroy = function () {
FYGE.Tween.removeAllTweens(); FYGE.Tween.removeAllTweens();
FYGE.getCancelAnimationFrame()(this.requestID); my ? canvas.cancelAnimationFrame(this.requestID) :
window.cancelAnimationFrame(this.requestID);
layers_1.destroyLayers(); layers_1.destroyLayers();
ctrls_1.destroyAllCtrls(); ctrls_1.destroyAllCtrls();
this.stage.destroy(); this.stage.destroy();
...@@ -11307,7 +11308,6 @@ var fc; ...@@ -11307,7 +11308,6 @@ var fc;
function sendTbNet(netName, parameter, callback, hideMsg) { function sendTbNet(netName, parameter, callback, hideMsg) {
if (hideMsg === void 0) { hideMsg = false; } if (hideMsg === void 0) { hideMsg = false; }
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
var waitObj;
if (!my) { if (!my) {
var url = "../../mock/miniTb/" + netName + ".json"; var url = "../../mock/miniTb/" + netName + ".json";
fetchAsync(url) fetchAsync(url)
...@@ -11327,7 +11327,6 @@ function sendTbNet(netName, parameter, callback, hideMsg) { ...@@ -11327,7 +11327,6 @@ function sendTbNet(netName, parameter, callback, hideMsg) {
return; return;
} }
var fun = function (e) { var fun = function (e) {
ctrls_1.clearWait(waitObj);
Main_1.GDispatcher.removeEventListener(netName, fun); Main_1.GDispatcher.removeEventListener(netName, fun);
var d = e.data; var d = e.data;
dataRecord[netName] = d; dataRecord[netName] = d;
...@@ -11342,16 +11341,6 @@ function sendTbNet(netName, parameter, callback, hideMsg) { ...@@ -11342,16 +11341,6 @@ function sendTbNet(netName, parameter, callback, hideMsg) {
+ "%cDATA : %o \n", "" + (d.success ? 'color:green' : 'color:red'), d.success, parameter, "" + (d.success ? 'color:green' : 'color:red'), d); + "%cDATA : %o \n", "" + (d.success ? 'color:green' : 'color:red'), d.success, parameter, "" + (d.success ? 'color:green' : 'color:red'), d);
}; };
Main_1.GDispatcher.addEventListener(netName, fun); Main_1.GDispatcher.addEventListener(netName, fun);
waitObj = ctrls_1.wait(function () {
if (netName != TbNetName.favorShop &&
netName != TbNetName.getUserAddress &&
netName != TbNetName.authorize &&
netName != TbNetName.getAdoptName &&
netName != TbNetName.trackingReport &&
netName != TbNetName.reportAnalytics) {
fun({ type: netName, data: { success: false } });
}
}, 10000);
Main_1.GDispatcher.dispatchEvent({ type: "onMessage" }, { netName: netName, parameter: parameter }); Main_1.GDispatcher.dispatchEvent({ type: "onMessage" }, { netName: netName, parameter: parameter });
}); });
} }
...@@ -18201,7 +18190,6 @@ var Scene_1 = __webpack_require__(/*! ../../module/views/Scene */ "./module/view ...@@ -18201,7 +18190,6 @@ var Scene_1 = __webpack_require__(/*! ../../module/views/Scene */ "./module/view
var Tools_1 = __webpack_require__(/*! ../Tools */ "./src/Tools.ts"); var Tools_1 = __webpack_require__(/*! ../Tools */ "./src/Tools.ts");
var ProgressBarS_1 = __webpack_require__(/*! ../common/ProgressBarS */ "./src/common/ProgressBarS.ts"); var ProgressBarS_1 = __webpack_require__(/*! ../common/ProgressBarS */ "./src/common/ProgressBarS.ts");
var RES_1 = __webpack_require__(/*! ../../module/RES */ "./module/RES.ts"); var RES_1 = __webpack_require__(/*! ../../module/RES */ "./module/RES.ts");
var Main_1 = __webpack_require__(/*! ../Main */ "./src/Main.ts");
var TaoBaoNet_1 = __webpack_require__(/*! ../TaoBaoNet */ "./src/TaoBaoNet.ts"); var TaoBaoNet_1 = __webpack_require__(/*! ../TaoBaoNet */ "./src/TaoBaoNet.ts");
var ctrls_1 = __webpack_require__(/*! ../../module/ctrls */ "./module/ctrls/index.ts"); var ctrls_1 = __webpack_require__(/*! ../../module/ctrls */ "./module/ctrls/index.ts");
var MapScene_1 = __webpack_require__(/*! ./map/MapScene */ "./src/scene/map/MapScene.ts"); var MapScene_1 = __webpack_require__(/*! ./map/MapScene */ "./src/scene/map/MapScene.ts");
...@@ -18279,20 +18267,20 @@ var LoadingScene = (function (_super) { ...@@ -18279,20 +18267,20 @@ var LoadingScene = (function (_super) {
switch (_a.label) { switch (_a.label) {
case 0: case 0:
_super.prototype.start.call(this); _super.prototype.start.call(this);
Main_1.GDispatcher.addEventListener(FYGE.Event.PROGRESS, this.progressEvent, this); this.addEventListener(FYGE.Event.PROGRESS, this.progressEvent, this);
Main_1.GDispatcher.dispatchEvent(FYGE.Event.PROGRESS, 0.2); this.dispatchEvent(FYGE.Event.PROGRESS, 0.2);
return [4, TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getAppData)]; return [4, TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getAppData)];
case 1: case 1:
data = (_a.sent()).data; data = (_a.sent()).data;
Tools_1.Tools.globalData = data; Tools_1.Tools.globalData = data;
Main_1.GDispatcher.dispatchEvent(FYGE.Event.PROGRESS, 0.3); this.dispatchEvent(FYGE.Event.PROGRESS, 0.3);
Tools_1.Tools.checkPermission(); Tools_1.Tools.checkPermission();
return [4, Tools_1.Tools.getIndex()]; return [4, Tools_1.Tools.getIndex()];
case 2: case 2:
getIndexSuccesss = _a.sent(); getIndexSuccesss = _a.sent();
if (!getIndexSuccesss) if (!getIndexSuccesss)
return [2]; return [2];
Main_1.GDispatcher.dispatchEvent(FYGE.Event.PROGRESS, 0.3); this.dispatchEvent(FYGE.Event.PROGRESS, 0.3);
return [4, TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getActivityBaseInfoById)]; return [4, TaoBaoNet_1.sendTbNet(TaoBaoNet_1.TbNetName.getActivityBaseInfoById)];
case 3: case 3:
baseInfo = _a.sent(); baseInfo = _a.sent();
...@@ -18301,7 +18289,7 @@ var LoadingScene = (function (_super) { ...@@ -18301,7 +18289,7 @@ var LoadingScene = (function (_super) {
for (k in Tools_1.Tools.baseInfo.levelPrize) { for (k in Tools_1.Tools.baseInfo.levelPrize) {
Tools_1.Tools.baseInfo.prizeLevels.push(+k.split('_')[1]); Tools_1.Tools.baseInfo.prizeLevels.push(+k.split('_')[1]);
} }
Main_1.GDispatcher.dispatchEvent(FYGE.Event.PROGRESS, 0.5); this.dispatchEvent(FYGE.Event.PROGRESS, 0.5);
return [4, Promise.all([ return [4, Promise.all([
'map', 'map',
'mapCrabEffect', 'mapCrabEffect',
...@@ -18313,7 +18301,7 @@ var LoadingScene = (function (_super) { ...@@ -18313,7 +18301,7 @@ var LoadingScene = (function (_super) {
}))]; }))];
case 4: case 4:
_a.sent(); _a.sent();
Main_1.GDispatcher.dispatchEvent(FYGE.Event.PROGRESS, 1); this.dispatchEvent(FYGE.Event.PROGRESS, 1);
return [2]; return [2];
} }
}); });
...@@ -18321,11 +18309,12 @@ var LoadingScene = (function (_super) { ...@@ -18321,11 +18309,12 @@ var LoadingScene = (function (_super) {
}; };
LoadingScene.prototype.progressEvent = function (e) { LoadingScene.prototype.progressEvent = function (e) {
var _this = this; var _this = this;
var pro = e.data;
FYGE.Tween.get(this.progressBar, null, null, true) FYGE.Tween.get(this.progressBar, null, null, true)
.to({ value: e.data }, 2000) .to({ value: pro }, 2000)
.call(function () { .call(function () {
if (e.data >= 1) { if (pro >= 1) {
Main_1.GDispatcher.removeEventListener(FYGE.Event.PROGRESS, _this.progressEvent, _this); _this.removeEventListener(FYGE.Event.PROGRESS, _this.progressEvent, _this);
ctrls_1.changeScene(MapScene_1.MapScene, { from: "loading" }); ctrls_1.changeScene(MapScene_1.MapScene, { from: "loading" });
} }
}); });
...@@ -22730,11 +22719,9 @@ var Tool = (function () { ...@@ -22730,11 +22719,9 @@ var Tool = (function () {
Tool.indexToRcMap10 = []; Tool.indexToRcMap10 = [];
Tool.indexPositions10 = []; Tool.indexPositions10 = [];
Tool.ExplosiveMatchArr = [ Tool.ExplosiveMatchArr = [
[0, -2],
[-1, -1], [0, -1], [1, -1], [-1, -1], [0, -1], [1, -1],
[-2, 0], [-1, 0], [1, 0], [2, 0], [-1, 0], [1, 0],
[-1, 1], [0, 1], [1, 1], [-1, 1], [0, 1], [1, 1],
[0, 2],
]; ];
return Tool; return Tool;
}()); }());
This source diff could not be displayed because it is too large. You can view the blob instead.
var fs = require("fs"); var fs = require("fs");
var iconv = require('iconv-lite'); var iconv = require('iconv-lite');
//暂时用作测试用
return
var data = iconv.decode(fs.readFileSync("./lotties/bb.json"), "utf-8");//GBK var data = iconv.decode(fs.readFileSync("./lotties/bb.json"), "utf-8");//GBK
//反序列化 //反序列化
data = JSON.parse(data); data = JSON.parse(data);
......
var fs = require("fs");
var iconv = require('iconv-lite');
var path = require('path');
//用于处理带base64图片的lottie文件,取出图片,同名lottie文件夹,写入代码"./src/lotties/"中;
var pathName = "./lottiesT"
//读文件夹
var files = fs.readdirSync(pathName);
//对每个json文件作处理
files.forEach(function (lottiesFileName) {
//后缀不是json的,不处理
if (path.extname(lottiesFileName).indexOf(".json") < 0) return;
//读数据
var data = iconv.decode(fs.readFileSync(pathName + "/" + lottiesFileName), "utf-8");//GBK
//反序列化
data = JSON.parse(data);
//存图片
var assets = data.assets;
if (!assets || !assets.length) return;
//删除属性
delete data.assets;
var imgOutPath = pathName + "/" + data.nm
//建文件夹data.nm
if (!fs.existsSync(imgOutPath)) fs.mkdirSync(imgOutPath);
assets.forEach((e) => {
//没有base64数据
if (!e.p) return
let id = e.id;
let uuid = guid();
//存图片
var base64 = e.p.replace(/^data:image\/\w+;base64,/, "");//去掉图片base64码前面部分data:image/png;base64
var dataBuffer = new Buffer(base64, 'base64'); //把base64码转成buffer对象,
fs.writeFile(imgOutPath + "/" + uuid + ".png", dataBuffer);
//修改用到id的所有refId
data.layers.forEach((l) => { l.refId === id && (l.refId = uuid) })
})
//开始删东西
delete data.ddd;
//遍历删除图层东西
for (var i = 0; i < data.layers.length; i++) {
var l = data.layers[i];
//是否3d,后缀,sr,ap,开始时间,混合模式,特效
["ddd", "cl", "sr", "ao", "st", "bm", "ef"].forEach((e) => { delete l[e]; });
//ks删除
["o", "r", "p", "a", "s"].forEach((e) => {
var d = l.ks[e];
//ix不知道干嘛用,删了
delete d.ix;
//删除k里数据
if (d.k.length && typeof d.k[0] == "object") {
d.k.forEach((ee) => {
["i", "o", "ti", "to"].forEach((eee) => { delete ee[eee]; })
})
}
})
}
//导出代码到src的lotties文件夹,名字就是lottie动画名字,资源名字临时处理了,首页加载动画用图层的nm,bonustime用refid
var endPath = './src/lotties';
if (!fs.existsSync(endPath)) fs.mkdirSync(endPath);
//导出对象直接用lottie动画名字
var endFile = `export const ${data.nm} = ${JSON.stringify(data, "", "\t")}`
//文件名字用lottie动画名字
fs.writeFileSync(endPath + "/" + data.nm + ".ts", endFile);
})
function guid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
import { removeTweens } from "../module/ctrls";
import { RES } from "../module/RES";
interface LottieData {
"fr": number,//珍露 30 60等
"ip": number,//开始帧
"op": number,//结束帧
"w": number,//宽度
"h": number,//高度
"nm": string,//名字
"layers": LayerData[]
}
interface LayerData {
"ind": number,//id唯一
"ty": number,//类型,暂时只有2
"nm": "owl_sleep.png",//暂时就是图片
"refId": string,
"parent"?: number,//父级id
"ks": KsData;
"ip": number,//开始帧
"op": number,//结束帧
}
interface KsData {
o: KeyData
r: KeyData
p: KeyData
a: KeyData
s: KeyData
}
interface KeyData {
a: number, k: { "t": number, "s": number[] }[] | number[] | number, x: string
}
/**
* 每帧数据
*/
interface FrameData {
a: number,
r: number,
ax: number,
ay: number,
x: number,
y: number,
sx: number,
sy: number,
v: boolean,
}
/**
* 用Tween拼,后续计算帧数据记录
* 临时写的,乱得很,以后再说
*/
export class Lottie extends FYGE.Container {
rawData: LottieData;
totalTime: number;
totalFrames: number;
/**
* 锁步的时间间隔,按fps定,毫秒
*/
private timeInterval;
/**
* 按帧率计算,60为1,30为2,
*/
private deltaFrame: number = 1;
get videoWidth(): number {
return this.rawData && this.rawData.w;
};
get videoHeight(): number {
return this.rawData && this.rawData.h;
};
/**
* 供循环用
*/
private loops: number
private callback: () => void
// private
constructor(data) {
super()
this._instanceType = "MovieClip";
//初始化
if (data) {
this.init(data);
} else {
this.totalFrames = 0;
}
}
init(data: LottieData) {
if (!data) return
this.rawData = data;
this.timeInterval = 1000 / data.fr;
this.totalFrames = data.op - data.ip + 1//感觉得加1;
//间隔帧数,
this.deltaFrame = 60 / data.fr;
this.name = data.nm;
this.initChildren();
}
private initChildren() {
const hash = {};
//初始化内容吧,假设所有资源已经加载好额
var layers = this.rawData.layers.slice();
//先筛选出所有不带parents,说明是顶级容器
for (var i = layers.length - 1; i >= 0; i--) {
let layer = layers[i];
if (!layer.parent) {
let c = this.addChild(new FYGE.Container())
c.addChild(new FYGE.Sprite(RES.getRes(layer.nm) || RES.getRes(layer.refId + ".png")));
c.name = layer.nm;
//记录一下数据
c["layerData"] = layer;
//计入hash
hash[layer.ind] = c;
//从数组移除
layers.splice(i, 1);
}
}
//剩下就找爹了
while (layers.length) {
for (var j = layers.length - 1; j >= 0; j--) {
let layer = layers[j];
if (hash[layer.parent]) {
let c = hash[layer.parent].addChild(FYGE.Sprite.fromFrame(layer.nm));
c.name = layer.nm;
//记录一下数据
c["layerData"] = layer;
//计入hash
hash[layer.ind] = c;
//从数组移除
layers.splice(j, 1);
}
}
}
this.initState()
}
/**
* 初始化每个对象的帧数据
*/
private initFrameData(dis: FYGE.DisplayObject, layerData: LayerData) {
var frames: FrameData[] = this.createEmptyFrames();
//@ts-ignore 透明度,有动画的
if (layerData.ks.o.k.length) {
}
//无动画的
else {
//@ts-ignore
this.coverProp(frames, { alpha: layerData.ks.o.k / 100 })
}
// c.alpha = layerData.ks.o.k[0] ? layerData.ks.o.k[0].s[0] : layerData.ks.o.k / 100;
// ["o", "r", "a", "p", "s"].forEach((e) => {
// let data: = layerData.ks[e].k;
// if (e == "o") {
// }
// })
// for (var i = 0; i < layerData.ks.) { }
}
private addFrames() {
}
private createEmptyFrames() {
var frames: FrameData[] = []
var count = 0;
while (count++ < this.totalFrames) {
//@ts-ignore
frames.push({
a: 1,
r: 0,
ax: 0,
ay: 0,
x: 0,
y: 0,
sx: 1,
sy: 1,
v: true,
})
}
return frames
}
private coverProp(frames: FrameData[], obj) {
//@ts-ignore
frames.forEach((f) => { Object.assign(f, obj) })
}
private updateFrame() {
}
update() {
this.updateFrame();
super.update()
}
private initState(con = this.children) {
for (var i = 0; i < con.length; i++) {
var c: FYGE.Sprite = con[i];
if (c["layerData"]) {
//取第一个数据
let data: LayerData = c["layerData"];
//@ts-ignore 透明度
c.alpha = data.ks.o.k[0] ? data.ks.o.k[0].s[0] : data.ks.o.k / 100;
//@ts-ignore 选转
c.rotation = data.ks.r.k[0] ? data.ks.r.k[0].s[0] : data.ks.r.k / 100;
//锚点,用贴图锚点
var ad = typeof data.ks.a.k[0] == "number" ? data.ks.a.k : data.ks.a.k[0].s;
c.anchor.set(ad[0], ad[1])
//位置
var ad = typeof data.ks.p.k[0] == "number" ? data.ks.p.k : data.ks.p.k[0].s;
c.position.set(ad[0] - c.anchorX, ad[1] - c.anchorY)
//缩放
var ad = typeof data.ks.s.k[0] == "number" ? data.ks.s.k : data.ks.s.k[0].s;
c.scale.set(ad[0] / 100, ad[1] / 100)
//如果入场不在的
if (data.ip != 0) c.visible = false
}
if (c.children.length) this.initState(c.children)
}
}
/**
* 只有一次或无数次
*/
play(loop: number = 1, callback?: () => void) {
this.initState();
this.loops = loop;
this.callback = callback;
this.addTweens();
}
/**
* 移除所有的Tween
*/
stop() {
removeTweens(this);
this.initState();
}
private addTweens(con = this.children) {
for (var i = 0; i < con.length; i++) {
let c: FYGE.Sprite = con[i];
if (c["layerData"]) {
//取第一个数据
let data: LayerData = c["layerData"];
//@ts-ignore 透明度,如果k是数组,肯定有帧数据
if (data.ks.o.k.length) this.addTween(c, "o");
//@ts-ignore 旋转
if (data.ks.r.k.length) this.addTween(c, "r");
//位置,得是对象
if (typeof data.ks.p.k[0] != "number") this.addTween(c, "p");
//缩放
if (typeof data.ks.s.k[0] != "number") this.addTween(c, "s");
}
if (c.children.length) this.addTweens(c.children)
}
}
private addTween(dis: FYGE.DisplayObject, type: "r" | "o" | "s" | "p") {
const data: { "t": number, "s": number[] }[] = dis["layerData"].ks[type].k
let tween = FYGE.Tween.get(dis, { loop: true })
let countTime = 0;
//记录用过的obj
var objArr: { obj: any, deltaTime: number }[] = []
for (let i = 0; i < data.length; i++) {
let d = data[i];
let deltaTime = d.t * this.timeInterval - countTime;
countTime += deltaTime;
let obj;
switch (type) {
case "r":
obj = { rotation: d.s[0] }
break;
case "o":
obj = { alpha: d.s[0] }
break;
case "s":
obj = { scaleX: d.s[0] / 100, scaleY: d.s[1] / 100 }
break;
case "p":
obj = { x: d.s[0] - dis.anchorX, y: d.s[1] - dis.anchorY }
break;
}
//第一个不是0,加wait
if (i == 0 && d.t != 0) {
tween.wait(deltaTime)
.call(() => { dis.visible = true })
continue
} else if (i == 0 && d.t == 0) {//从0开始的,不进行缓动,但是要记录状态
objArr.push({ obj, deltaTime })
continue
}
tween.to(obj, deltaTime);
objArr.push({ obj, deltaTime })
}
if (dis["layerData"].ks[type].x) {
var xs = dis["layerData"].ks[type].x;
if (xs.indexOf("loopOut") >= 0) {
//如果是往复的,
if (xs.indexOf("pingpong") >= 0 && data[data.length - 1].t < this.rawData.op) {
var round = Math.round(this.rawData.op / data[data.length - 1].t)
var dir = false;
while (--round) {
if (dir) {
for (var o = 0; o < objArr.length; o++) {
tween.to(objArr[o].obj, objArr[o].deltaTime);
}
} else {
for (var o = objArr.length - 1; o >= 1; o--) {
tween.to(objArr[o - 1].obj, objArr[o].deltaTime);
}
}
dir = !dir;
}
}
//如果是循环的,且没满一个循环的
else if (xs.indexOf("cycle") >= 0 && data[data.length - 1].t < this.rawData.op) {
//补满
for (var o = 0; o < objArr.length; o++) {
tween.to(objArr[o].obj, objArr[o].deltaTime);
}
}
}
}
//入场不是0
if (dis["layerData"].ip != 0) {
tween.call(() => {
dis.visible = false;
})
}
//不管x的
if (!dis["layerData"].ks[type].x) {
if (data[data.length - 1].t < this.rawData.op) {
tween.wait(this.rawData.op * this.timeInterval - countTime)
}
}
tween.call(() => {
if (--this.loops == 0) {
this.stop();
this.callback && this.callback();
}
})
}
destroy() {
removeTweens(this);
super.destroy();
}
}
...@@ -25,6 +25,7 @@ export class Main { ...@@ -25,6 +25,7 @@ export class Main {
stage: FYGE.Stage; stage: FYGE.Stage;
private requestID; private requestID;
private _pause: boolean; private _pause: boolean;
private canvas: HTMLCanvasElement
constructor(canvas: HTMLCanvasElement) { constructor(canvas: HTMLCanvasElement) {
var sysInfo; var sysInfo;
//@ts-ignore 存在my就初始化 //@ts-ignore 存在my就初始化
...@@ -44,6 +45,7 @@ export class Main { ...@@ -44,6 +45,7 @@ export class Main {
FYGE.RENDERER_TYPE.CANVAS FYGE.RENDERER_TYPE.CANVAS
); );
this.stage = stage; this.stage = stage;
this.canvas = canvas;//赋值下,为了下面的destroy的cancelAnimationFrame
//开始循环 //开始循环
// FYGE.Stage.flushAll(); // FYGE.Stage.flushAll();
//stage初始化 //stage初始化
...@@ -62,7 +64,10 @@ export class Main { ...@@ -62,7 +64,10 @@ export class Main {
// stats.end(); // stats.end();
} }
//@ts-ignore //@ts-ignore
self.requestID = FYGE.getRequestAnimationFrame()(loop); // self.requestID = FYGE.getRequestAnimationFrame()(loop);
//为了兼容多page的canvas
my ? self.requestID = canvas.requestAnimationFrame(loop) :
self.requestID = window.requestAnimationFrame(loop);
} }
} }
...@@ -107,16 +112,16 @@ export class Main { ...@@ -107,16 +112,16 @@ export class Main {
//在小程序显示时调用onShow //在小程序显示时调用onShow
run() { run() {
this._pause = false this._pause = false;
//@ts-ignore Tween计时清零 //@ts-ignore Tween计时清零
// FYGE.Tween._lastTime = null //下面的_pause 不执行,先去掉,试试有没有问题 FYGE.Tween._lastTime = null;
GDispatcher.dispatchEvent(G_EVENT.ON_SHOW); GDispatcher.dispatchEvent({ type: G_EVENT.ON_SHOW });
} }
//在小程序隐藏时调用onHide //在小程序隐藏时调用onHide
pause() { pause() {
// this._pause = true;//先去掉吧 this._pause = true;
GDispatcher.dispatchEvent(G_EVENT.ON_HIDE); GDispatcher.dispatchEvent({ type: G_EVENT.ON_HIDE });
} }
/** /**
...@@ -158,7 +163,10 @@ export class Main { ...@@ -158,7 +163,10 @@ export class Main {
FYGE.Tween.removeAllTweens() FYGE.Tween.removeAllTweens()
// removeAllTimeoutId();//这个再看,尽量用tween的修改 // removeAllTimeoutId();//这个再看,尽量用tween的修改
//停掉计时器 //停掉计时器
FYGE.getCancelAnimationFrame()(this.requestID); // FYGE.getCancelAnimationFrame()(this.requestID);
//@ts-ignore 为了兼容多page的canvas
my ? this.canvas.cancelAnimationFrame(this.requestID) :
window.cancelAnimationFrame(this.requestID);
//层级销毁 //层级销毁
destroyLayers() destroyLayers()
//销毁控制器 //销毁控制器
......
...@@ -177,7 +177,7 @@ export function sendTbNet( ...@@ -177,7 +177,7 @@ export function sendTbNet(
): Promise<dataOut> { ): Promise<dataOut> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
//网络超时 //网络超时
let waitObj; // let waitObj;
//@ts-ignore 本地开发,直接取数据 //@ts-ignore 本地开发,直接取数据
if (!my) { if (!my) {
var url = "../../mock/miniTb/" + netName + ".json"; var url = "../../mock/miniTb/" + netName + ".json";
...@@ -212,7 +212,7 @@ export function sendTbNet( ...@@ -212,7 +212,7 @@ export function sendTbNet(
let fun = function (e: { type: string, data: dataOut }) { let fun = function (e: { type: string, data: dataOut }) {
//清除超时记录 //清除超时记录
clearWait(waitObj) // clearWait(waitObj)
//移除事件 //移除事件
GDispatcher.removeEventListener(netName, fun); GDispatcher.removeEventListener(netName, fun);
...@@ -240,19 +240,19 @@ export function sendTbNet( ...@@ -240,19 +240,19 @@ export function sendTbNet(
//添加事件接收接口返回信息 //添加事件接收接口返回信息
GDispatcher.addEventListener(netName, fun); GDispatcher.addEventListener(netName, fun);
//网络超时 //网络超时,已经可以返回云函数调用失败,有机会把这删了,不需要了
waitObj = wait(() => { // waitObj = wait(() => {
//是用户操作,不设置超时 // //是用户操作,不设置超时
if (netName != TbNetName.favorShop &&//关注店铺用户操作 // if (netName != TbNetName.favorShop &&//关注店铺用户操作
netName != TbNetName.getUserAddress && // 获取地址 // netName != TbNetName.getUserAddress && // 获取地址
netName != TbNetName.authorize && // 授权 // netName != TbNetName.authorize && // 授权
netName != TbNetName.getAdoptName && //领养名字获取 // netName != TbNetName.getAdoptName && //领养名字获取
netName != TbNetName.trackingReport && //埋点接口也不考虑超时 // netName != TbNetName.trackingReport && //埋点接口也不考虑超时
netName != TbNetName.reportAnalytics //淘宝自定义埋点也不考虑超时 // netName != TbNetName.reportAnalytics //淘宝自定义埋点也不考虑超时
) { // ) {
fun({ type: netName, data: { success: false } }) // fun({ type: netName, data: { success: false } })
} // }
}, 10000) // }, 10000)
//用事件方式吧,派发事件发接口,,,,注意很多独有的事件名别重了,onHide,onShow,onMessage等 放到最后,因为有同步的情况 //用事件方式吧,派发事件发接口,,,,注意很多独有的事件名别重了,onHide,onShow,onMessage等 放到最后,因为有同步的情况
GDispatcher.dispatchEvent({ type: "onMessage" }, { netName, parameter }) GDispatcher.dispatchEvent({ type: "onMessage" }, { netName, parameter })
......
...@@ -2,7 +2,6 @@ import { Scene } from "../../module/views/Scene"; ...@@ -2,7 +2,6 @@ import { Scene } from "../../module/views/Scene";
import { Tools } from "../Tools"; import { Tools } from "../Tools";
import { ProgressBarS } from "../common/ProgressBarS"; import { ProgressBarS } from "../common/ProgressBarS";
import { RES } from "../../module/RES"; import { RES } from "../../module/RES";
import { GDispatcher } from "../Main";
import { sendTbNet, TbNetName } from "../TaoBaoNet"; import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { changeScene } from "../../module/ctrls"; import { changeScene } from "../../module/ctrls";
import { MapScene } from "./map/MapScene"; import { MapScene } from "./map/MapScene";
...@@ -93,14 +92,14 @@ export class LoadingScene extends Scene { ...@@ -93,14 +92,14 @@ export class LoadingScene extends Scene {
async start() { async start() {
super.start() super.start()
GDispatcher.addEventListener(FYGE.Event.PROGRESS, this.progressEvent, this) this.addEventListener(FYGE.Event.PROGRESS, this.progressEvent, this)
//首次进度一点 //首次进度一点
GDispatcher.dispatchEvent(FYGE.Event.PROGRESS, 0.2) this.dispatchEvent(FYGE.Event.PROGRESS, 0.2)
//获取app数据 //获取app数据
const { data } = await sendTbNet(TbNetName.getAppData); const { data } = await sendTbNet(TbNetName.getAppData);
Tools.globalData = data; Tools.globalData = data;
GDispatcher.dispatchEvent(FYGE.Event.PROGRESS, 0.3) this.dispatchEvent(FYGE.Event.PROGRESS, 0.3)
//询问读取权限,不阻止进程 //询问读取权限,不阻止进程
Tools.checkPermission(); Tools.checkPermission();
//获取首页数据 //获取首页数据
...@@ -108,7 +107,7 @@ export class LoadingScene extends Scene { ...@@ -108,7 +107,7 @@ export class LoadingScene extends Scene {
//失败不进入 //失败不进入
if (!getIndexSuccesss) return; if (!getIndexSuccesss) return;
GDispatcher.dispatchEvent(FYGE.Event.PROGRESS, 0.3); this.dispatchEvent(FYGE.Event.PROGRESS, 0.3);
// 游戏基本信息 // 游戏基本信息
const baseInfo = await sendTbNet(TbNetName.getActivityBaseInfoById); const baseInfo = await sendTbNet(TbNetName.getActivityBaseInfoById);
...@@ -118,7 +117,7 @@ export class LoadingScene extends Scene { ...@@ -118,7 +117,7 @@ export class LoadingScene extends Scene {
Tools.baseInfo.prizeLevels.push(+k.split('_')[1]); Tools.baseInfo.prizeLevels.push(+k.split('_')[1]);
} }
GDispatcher.dispatchEvent(FYGE.Event.PROGRESS, 0.5); this.dispatchEvent(FYGE.Event.PROGRESS, 0.5);
//首次进入,地图页面需要引导 //首次进入,地图页面需要引导
// if (Tools.gameData.isFristLogin) { // if (Tools.gameData.isFristLogin) {
...@@ -134,17 +133,18 @@ export class LoadingScene extends Scene { ...@@ -134,17 +133,18 @@ export class LoadingScene extends Scene {
return RES.loadGroup(e) return RES.loadGroup(e)
})) }))
GDispatcher.dispatchEvent(FYGE.Event.PROGRESS, 1); this.dispatchEvent(FYGE.Event.PROGRESS, 1);
} }
// private lastP=0 // private lastP=0
progressEvent(e: FYGE.Event) { progressEvent(e: FYGE.Event) {
let pro = e.data;
FYGE.Tween.get(this.progressBar, null, null, true) FYGE.Tween.get(this.progressBar, null, null, true)
.to({ value: e.data }, 2000/**(p-this.lastP)*/) .to({ value: pro }, 2000/**(p-this.lastP)*/)
.call(() => { .call(() => {
if (e.data >= 1) { if (pro >= 1) {
GDispatcher.removeEventListener(FYGE.Event.PROGRESS, this.progressEvent, this); this.removeEventListener(FYGE.Event.PROGRESS, this.progressEvent, this);
changeScene(MapScene, {from: "loading"}) changeScene(MapScene, { from: "loading" })
} }
}) })
// this.lastP=p // this.lastP=p
......
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