Commit fad806bf authored by wjf's avatar wjf

l

parent 303e94ae
{ {
"code": "530001", "code": "530001",
"data": { "data": {
"power": 1231,
"tools": {
"STEPS": 3,
"BOOMS": 4,
"HAMMERS": 5
},
"isvip": false, "isvip": false,
"url": "//market.m.taobao.com/apps/market/shopmember/index.html?wh_weex=true&sellerId=2207623078795&extraInfo=%7B%22source%22%3A%22isvapp%22%2C%22entrance%22%3A%22duiba%22%7D" "url": "//market.m.taobao.com/apps/market/shopmember/index.html?wh_weex=true&sellerId=2207623078795&extraInfo=%7B%22source%22%3A%22isvapp%22%2C%22entrance%22%3A%22duiba%22%7D"
}, },
"success": false, "success": true,
"message": "需要成为会员" "message": "需要成为会员"
} }
\ No newline at end of file
{ {
"success": false, "success": true,
"message": "您还不是会员", "message": "您还不是会员",
"data": { "data": {
"isvip": false, "isvip": false,
......
{ {
"groups": [ "groups": [
{ {
"keys": "bonusTime0.png,bonusTime1.png,bonusTime10.png,bonusTime11.png,bonusTime12.png,bonusTime13.png,bonusTime14.png,bonusTime15.png,bonusTime16.png,bonusTime17.png,bonusTime18.png,bonusTime19.png,bonusTime2.png,bonusTime20.png,bonusTime21.png,bonusTime22.png,bonusTime23.png,bonusTime24.png,bonusTime25.png,bonusTime26.png,bonusTime27.png,bonusTime28.png,bonusTime3.png,bonusTime4.png,bonusTime5.png,bonusTime6.png,bonusTime7.png,bonusTime8.png,bonusTime9.png", "keys": "img_0.png,img_1.png,img_10.png,img_11.png,img_12.png,img_13.png,img_14.png,img_15.png,img_16.png,img_17.png,img_18.png,img_19.png,img_2.png,img_3.png,img_4.png,img_5.png,img_6.png,img_7.png,img_8.png,img_9.png",
"name": "bonusTime" "name": "bonusTime"
}, },
{ {
...@@ -37,7 +37,11 @@ ...@@ -37,7 +37,11 @@
"name": "FreePowerPanel" "name": "FreePowerPanel"
}, },
{ {
"keys": "carb_arm.png,carb_body.png,carb_hand_l.png,carb_hand_r.png,fox_arm_l.png,fox_body.png,fox_head.png,fox_tail0.png,fox_tail1.png,fox_tail10.png,fox_tail11.png,fox_tail12.png,fox_tail13.png,fox_tail14.png,fox_tail2.png,fox_tail3.png,fox_tail4.png,fox_tail5.png,fox_tail6.png,fox_tail7.png,fox_tail8.png,fox_tail9.png,hommer.png,img_line1.png,img_line2.png,img_line3.png,img_line4.png,img_line5.png,img_owl.png,img_tree.png,loadingBg.jpg,loadingBg2.png,loadingPro0.png,loadingPro1.png,loadingPro10.png,loadingPro11.png,loadingPro2.png,loadingPro3.png,loadingPro4.png,loadingPro5.png,loadingPro6.png,loadingPro7.png,loadingPro8.png,loadingPro9.png,loadingTitle.png,owl_sleep.png,proDown.png,wheel.png", "keys": "joinBg.png,joinBtn.png",
"name": "JoinPanel"
},
{
"keys": "carb_arm.png,carb_body.png,carb_hand_l.png,carb_hand_r.png,fox_arm_l.png,fox_body.png,fox_head.png,fox_tail0.png,fox_tail1.png,fox_tail10.png,fox_tail11.png,fox_tail12.png,fox_tail13.png,fox_tail14.png,fox_tail2.png,fox_tail3.png,fox_tail4.png,fox_tail5.png,fox_tail6.png,fox_tail7.png,fox_tail8.png,fox_tail9.png,hommer.png,img_line1.png,img_line2.png,img_line3.png,img_line4.png,img_line5.png,img_owl.png,img_tree.png,lighting_1.png,lighting_2.png,loadingBg.jpg,loadingBg2.png,loadingPro0.png,loadingPro1.png,loadingPro10.png,loadingPro11.png,loadingPro2.png,loadingPro3.png,loadingPro4.png,loadingPro5.png,loadingPro6.png,loadingPro7.png,loadingPro8.png,loadingPro9.png,loadingTitle.png,owl_sleep.png,proDown.png,wheel.png",
"name": "loadingScene" "name": "loadingScene"
}, },
{ {
...@@ -73,8 +77,8 @@ ...@@ -73,8 +77,8 @@
"name": "playScene" "name": "playScene"
}, },
{ {
"keys": "img_line1.png,img_line2.png,img_line3.png,img_line4.png,img_line5.png,loadingBg.jpg,loadingBg2.png,loadingPro0.png,loadingPro1.png,loadingPro10.png,loadingPro11.png,loadingPro2.png,loadingPro3.png,loadingPro4.png,loadingPro5.png,loadingPro6.png,loadingPro7.png,loadingPro8.png,loadingPro9.png,loadingTitle.png,proDown.png,wheel.png", "keys": "活动规则背景.png",
"name": "loadingScene" "name": "RulePanel"
}, },
{ {
"keys": "star_light_0.png,star_light_1.png,star_light_10.png,star_light_11.png,star_light_12.png,star_light_13.png,star_light_14.png,star_light_15.png,star_light_2.png,star_light_3.png,star_light_4.png,star_light_5.png,star_light_6.png,star_light_7.png,star_light_8.png,star_light_9.png", "keys": "star_light_0.png,star_light_1.png,star_light_10.png,star_light_11.png,star_light_12.png,star_light_13.png,star_light_14.png,star_light_15.png,star_light_2.png,star_light_3.png,star_light_4.png,star_light_5.png,star_light_6.png,star_light_7.png,star_light_8.png,star_light_9.png",
......
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();
}
}
import { removeTweens } from "../module/ctrls"; import { removeTweens } from "../module/ctrls";
import { RES } from "../module/RES";
interface LottieData { interface LottieData {
"fr": number,//珍露 30 60等 "fr": number,//珍露 30 60等
...@@ -12,7 +13,8 @@ interface LottieData { ...@@ -12,7 +13,8 @@ interface LottieData {
interface LayerData { interface LayerData {
"ind": number,//id唯一 "ind": number,//id唯一
"ty": number,//类型,暂时只有2 "ty": number,//类型,暂时只有2
"nm": "owl_sleep.png",//暂时就是图片 "nm": string//"owl_sleep.png",//暂时就是图片
"refId": string,
"parent"?: number,//父级id "parent"?: number,//父级id
"ks": KsData; "ks": KsData;
"ip": number,//开始帧 "ip": number,//开始帧
...@@ -109,7 +111,7 @@ export class Lottie extends FYGE.Container { ...@@ -109,7 +111,7 @@ export class Lottie extends FYGE.Container {
let layer = layers[i]; let layer = layers[i];
if (!layer.parent) { if (!layer.parent) {
let c = this.addChild(new FYGE.Container()) let c = this.addChild(new FYGE.Container())
c.addChild(FYGE.Sprite.fromFrame(layer.nm)); c.addChild(new FYGE.Sprite(RES.getRes(layer.nm) || RES.getRes(layer.refId + ".png")));
c.name = layer.nm; c.name = layer.nm;
//记录一下数据 //记录一下数据
c["layerData"] = layer; c["layerData"] = layer;
...@@ -123,8 +125,8 @@ export class Lottie extends FYGE.Container { ...@@ -123,8 +125,8 @@ export class Lottie extends FYGE.Container {
while (layers.length) { while (layers.length) {
for (var j = layers.length - 1; j >= 0; j--) { for (var j = layers.length - 1; j >= 0; j--) {
let layer = layers[j]; let layer = layers[j];
if (hash[layer.parent]) { if (hash[layer.parent]) {//这种方式有问题,谁先添加有bug
let c = hash[layer.parent].addChild(FYGE.Sprite.fromFrame(layer.nm)); let c = hash[layer.parent].addChildAt(new FYGE.Sprite(RES.getRes(layer.nm) || RES.getRes(layer.refId + ".png")), layer["td"] || 999);
c.name = layer.nm; c.name = layer.nm;
//记录一下数据 //记录一下数据
c["layerData"] = layer; c["layerData"] = layer;
...@@ -144,9 +146,9 @@ export class Lottie extends FYGE.Container { ...@@ -144,9 +146,9 @@ export class Lottie extends FYGE.Container {
//取第一个数据 //取第一个数据
let data: LayerData = c["layerData"]; let data: LayerData = c["layerData"];
//@ts-ignore 透明度 //@ts-ignore 透明度
c.alpha = data.ks.o.k[0] ? data.ks.o.k[0].s[0] : data.ks.o.k / 100; c.alpha = data.ks.o.k[0] ? data.ks.o.k[0].s[0]/100 : data.ks.o.k / 100;
//@ts-ignore 选转 //@ts-ignore 选转
c.rotation = data.ks.r.k[0] ? data.ks.r.k[0].s[0] : data.ks.r.k / 100; c.rotation = data.ks.r.k[0] ? data.ks.r.k[0].s[0] : data.ks.r.k;
//锚点,用贴图锚点 //锚点,用贴图锚点
var ad = typeof data.ks.a.k[0] == "number" ? data.ks.a.k : data.ks.a.k[0].s; 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]) c.anchor.set(ad[0], ad[1])
...@@ -216,7 +218,7 @@ export class Lottie extends FYGE.Container { ...@@ -216,7 +218,7 @@ export class Lottie extends FYGE.Container {
obj = { rotation: d.s[0] } obj = { rotation: d.s[0] }
break; break;
case "o": case "o":
obj = { alpha: d.s[0] } obj = { alpha: d.s[0]/100 }
break; break;
case "s": case "s":
obj = { scaleX: d.s[0] / 100, scaleY: d.s[1] / 100 } obj = { scaleX: d.s[0] / 100, scaleY: d.s[1] / 100 }
...@@ -241,7 +243,7 @@ export class Lottie extends FYGE.Container { ...@@ -241,7 +243,7 @@ export class Lottie extends FYGE.Container {
if (dis["layerData"].ks[type].x) { if (dis["layerData"].ks[type].x) {
var xs = dis["layerData"].ks[type].x; var xs = dis["layerData"].ks[type].x;
if (xs.indexOf("loopOut") >= 0) { if (xs.indexOf("loopOut") >= 0) {
//如果是往复的, //如果是往复的,还有问题,没考虑第二个参数
if (xs.indexOf("pingpong") >= 0 && data[data.length - 1].t < this.rawData.op) { 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 round = Math.round(this.rawData.op / data[data.length - 1].t)
var dir = false; var dir = false;
...@@ -262,11 +264,24 @@ export class Lottie extends FYGE.Container { ...@@ -262,11 +264,24 @@ export class Lottie extends FYGE.Container {
} }
//如果是循环的,且没满一个循环的 //如果是循环的,且没满一个循环的
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 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 = objArr.slice(-(xs.replace(/[^0-9]/ig, "")))
if (dis["layerData"].nm == "bonus_light_11.png") { console.log(dis.alpha) }
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);
} }
} }
//补满
// for (var o = 0; o < objArr.length; o++) {
// tween.to(objArr[o].obj, objArr[o].deltaTime);
// }
}
} }
} }
//入场不是0 //入场不是0
...@@ -289,7 +304,7 @@ export class Lottie extends FYGE.Container { ...@@ -289,7 +304,7 @@ export class Lottie extends FYGE.Container {
}) })
} }
destroy(){ destroy() {
removeTweens(this); removeTweens(this);
super.destroy(); super.destroy();
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { layers, destroyLayers } from "../module/views/layers"; import { layers, destroyLayers } from "../module/views/layers";
import { RES } from "../module/RES"; import { RES } from "../module/RES";
import { changeScene, showWaiting, destroyAllCtrls } from "../module/ctrls"; import { changeScene, showWaiting, destroyAllCtrls, showPanel } from "../module/ctrls";
import { ResJson } from "./ResJson"; import { ResJson } from "./ResJson";
import { destroyNetData, sendTbNet, TbNetName } from "./TaoBaoNet"; import { destroyNetData, sendTbNet, TbNetName } from "./TaoBaoNet";
...@@ -11,6 +11,7 @@ import { G_EVENT } from "./common/G_EVENT"; ...@@ -11,6 +11,7 @@ import { G_EVENT } from "./common/G_EVENT";
import { MapScene } from "./scene/map/MapScene"; import { MapScene } from "./scene/map/MapScene";
import { PlayScene } from "./scene/PlayScene"; import { PlayScene } from "./scene/PlayScene";
import { LoadingScene } from "./scene/LoadingScene"; import { LoadingScene } from "./scene/LoadingScene";
import { JoinPanel } from "./panels/JoinPanel";
/** /**
* 全局事件,为了和小程序交互 * 全局事件,为了和小程序交互
...@@ -85,6 +86,7 @@ export class Main { ...@@ -85,6 +86,7 @@ export class Main {
// changeScene(StoryScene); // changeScene(StoryScene);
// changeScene(AdoptScene); // changeScene(AdoptScene);
// console.log("恶趣味去") // console.log("恶趣味去")
// showPanel(JoinPanel)
//测试 //测试
// sendTbNet(TbNetName.aaa, {}, (s, res) => { // sendTbNet(TbNetName.aaa, {}, (s, res) => {
// console.log(res) // console.log(res)
...@@ -106,14 +108,13 @@ export class Main { ...@@ -106,14 +108,13 @@ export class Main {
run() { run() {
this._pause = false this._pause = false
//@ts-ignore Tween计时清零 //@ts-ignore Tween计时清零
FYGE.Tween._lastTime = null // FYGE.Tween._lastTime = null //下面的_pause 不执行,先去掉,试试有没有问题
GDispatcher.dispatchEvent(G_EVENT.ON_SHOW); GDispatcher.dispatchEvent(G_EVENT.ON_SHOW);
} }
//在小程序隐藏时调用onHide //在小程序隐藏时调用onHide
pause() { pause() {
// this._pause = true;//先去掉吧 // this._pause = true;//先去掉吧
GDispatcher.dispatchEvent(G_EVENT.ON_HIDE); GDispatcher.dispatchEvent(G_EVENT.ON_HIDE);
} }
......
export const ResJson = { export const ResJson = {
"groups": [ "groups": [
{ {
"keys": "bonusTime0.png,bonusTime1.png,bonusTime10.png,bonusTime11.png,bonusTime12.png,bonusTime13.png,bonusTime14.png,bonusTime15.png,bonusTime16.png,bonusTime17.png,bonusTime18.png,bonusTime19.png,bonusTime2.png,bonusTime20.png,bonusTime21.png,bonusTime22.png,bonusTime23.png,bonusTime24.png,bonusTime25.png,bonusTime26.png,bonusTime27.png,bonusTime28.png,bonusTime3.png,bonusTime4.png,bonusTime5.png,bonusTime6.png,bonusTime7.png,bonusTime8.png,bonusTime9.png", "keys": "img_0.png,img_1.png,img_10.png,img_11.png,img_12.png,img_13.png,img_14.png,img_15.png,img_16.png,img_17.png,img_18.png,img_19.png,img_2.png,img_3.png,img_4.png,img_5.png,img_6.png,img_7.png,img_8.png,img_9.png",
"name": "bonusTime" "name": "bonusTime"
}, },
{ {
...@@ -37,7 +37,11 @@ export const ResJson = { ...@@ -37,7 +37,11 @@ export const ResJson = {
"name": "FreePowerPanel" "name": "FreePowerPanel"
}, },
{ {
"keys": "carb_arm.png,carb_body.png,carb_hand_l.png,carb_hand_r.png,fox_arm_l.png,fox_body.png,fox_head.png,fox_tail0.png,fox_tail1.png,fox_tail10.png,fox_tail11.png,fox_tail12.png,fox_tail13.png,fox_tail14.png,fox_tail2.png,fox_tail3.png,fox_tail4.png,fox_tail5.png,fox_tail6.png,fox_tail7.png,fox_tail8.png,fox_tail9.png,hommer.png,img_line1.png,img_line2.png,img_line3.png,img_line4.png,img_line5.png,img_owl.png,img_tree.png,loadingBg.jpg,loadingBg2.png,loadingPro0.png,loadingPro1.png,loadingPro10.png,loadingPro11.png,loadingPro2.png,loadingPro3.png,loadingPro4.png,loadingPro5.png,loadingPro6.png,loadingPro7.png,loadingPro8.png,loadingPro9.png,loadingTitle.png,owl_sleep.png,proDown.png,wheel.png", "keys": "joinBg.png,joinBtn.png",
"name": "JoinPanel"
},
{
"keys": "carb_arm.png,carb_body.png,carb_hand_l.png,carb_hand_r.png,fox_arm_l.png,fox_body.png,fox_head.png,fox_tail0.png,fox_tail1.png,fox_tail10.png,fox_tail11.png,fox_tail12.png,fox_tail13.png,fox_tail14.png,fox_tail2.png,fox_tail3.png,fox_tail4.png,fox_tail5.png,fox_tail6.png,fox_tail7.png,fox_tail8.png,fox_tail9.png,hommer.png,img_line1.png,img_line2.png,img_line3.png,img_line4.png,img_line5.png,img_owl.png,img_tree.png,lighting_1.png,lighting_2.png,loadingBg.jpg,loadingBg2.png,loadingPro0.png,loadingPro1.png,loadingPro10.png,loadingPro11.png,loadingPro2.png,loadingPro3.png,loadingPro4.png,loadingPro5.png,loadingPro6.png,loadingPro7.png,loadingPro8.png,loadingPro9.png,loadingTitle.png,owl_sleep.png,proDown.png,wheel.png",
"name": "loadingScene" "name": "loadingScene"
}, },
{ {
...@@ -73,8 +77,8 @@ export const ResJson = { ...@@ -73,8 +77,8 @@ export const ResJson = {
"name": "playScene" "name": "playScene"
}, },
{ {
"keys": "img_line1.png,img_line2.png,img_line3.png,img_line4.png,img_line5.png,loadingBg.jpg,loadingBg2.png,loadingPro0.png,loadingPro1.png,loadingPro10.png,loadingPro11.png,loadingPro2.png,loadingPro3.png,loadingPro4.png,loadingPro5.png,loadingPro6.png,loadingPro7.png,loadingPro8.png,loadingPro9.png,loadingTitle.png,proDown.png,wheel.png", "keys": "活动规则背景.png",
"name": "loadingScene" "name": "RulePanel"
}, },
{ {
"keys": "star_light_0.png,star_light_1.png,star_light_10.png,star_light_11.png,star_light_12.png,star_light_13.png,star_light_14.png,star_light_15.png,star_light_2.png,star_light_3.png,star_light_4.png,star_light_5.png,star_light_6.png,star_light_7.png,star_light_8.png,star_light_9.png", "keys": "star_light_0.png,star_light_1.png,star_light_10.png,star_light_11.png,star_light_12.png,star_light_13.png,star_light_14.png,star_light_15.png,star_light_2.png,star_light_3.png,star_light_4.png,star_light_5.png,star_light_6.png,star_light_7.png,star_light_8.png,star_light_9.png",
......
...@@ -5,6 +5,7 @@ import DisplayObject = FYGE.DisplayObject; ...@@ -5,6 +5,7 @@ import DisplayObject = FYGE.DisplayObject;
import Ease = FYGE.Ease; import Ease = FYGE.Ease;
import { sendTbNet, TbNetName } from "./TaoBaoNet"; import { sendTbNet, TbNetName } from "./TaoBaoNet";
import { PropType } from "./something/enum/PropType"; import { PropType } from "./something/enum/PropType";
import { showToast } from "../module/ctrls";
/** /**
* 定制,记录一些全局量和方法 * 定制,记录一些全局量和方法
...@@ -101,7 +102,7 @@ export class Tools { ...@@ -101,7 +102,7 @@ export class Tools {
*/ */
public static consumerTools(type: PropType): Promise<boolean> { public static consumerTools(type: PropType): Promise<boolean> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
sendTbNet(TbNetName.consumerTools, {type}, (s, res) => { sendTbNet(TbNetName.consumerTools, { type }, (s, res) => {
if (s) { if (s) {
//修改道具数量 //修改道具数量
this.gameData.tools = res.data.tools; this.gameData.tools = res.data.tools;
...@@ -119,16 +120,17 @@ export class Tools { ...@@ -119,16 +120,17 @@ export class Tools {
*/ */
public static async exchange(type: PropType): Promise<boolean | string> { public static async exchange(type: PropType): Promise<boolean | string> {
//先获取积分,判断是否有积分 //先获取积分,判断是否有积分
var creditsData = await sendTbNet(TbNetName.queryCredits) var creditsData = await sendTbNet(TbNetName.queryCredits, null, null, true)
//接口失败,没数据时,返回false //接口失败,没数据时,返回false
if (!creditsData || !creditsData.data) { if (!creditsData || !creditsData.data) {
showToast("网络异常,请重试")//上面禁掉了提示,这里提示下
return false return false
} }
//非会员,返回会员路径 //非会员,返回会员路径
if (creditsData && !creditsData.success && !creditsData.data.isvip) { if (creditsData && !creditsData.success && !creditsData.data.isvip) {
return creditsData.data.url return creditsData.data.url
} }
const res = await sendTbNet(TbNetName.exchange, {type, credits: creditsData.data.credits}) const res = await sendTbNet(TbNetName.exchange, { type, credits: creditsData.data.credits })
if (res.success) { if (res.success) {
//修改道具数量和体力 //修改道具数量和体力
this.gameData.power = res.data.power; this.gameData.power = res.data.power;
...@@ -147,11 +149,11 @@ export class Tools { ...@@ -147,11 +149,11 @@ export class Tools {
var tbMy = my var tbMy = my
if (!tbMy) return; if (!tbMy) return;
//@ts-ignore //@ts-ignore
const {cloud} = getApp(); const { cloud } = getApp();
//测试地址//到时云存储传一个小json,,改路径 //测试地址//到时云存储传一个小json,,改路径
var url = "cloud://B4F0300E5148F478B506DEDC26EA4C6C//butterfly0.svga"; var url = "cloud://B4F0300E5148F478B506DEDC26EA4C6C//butterfly0.svga";
//获取临时地址 //获取临时地址
var urls = await cloud.file.getTempFileURL({fileId: [url]}) var urls = await cloud.file.getTempFileURL({ fileId: [url] })
url = urls[0].url.replace('-internal', ''); url = urls[0].url.replace('-internal', '');
tbMy.downloadFile({ tbMy.downloadFile({
url: url, url: url,
...@@ -160,10 +162,10 @@ export class Tools { ...@@ -160,10 +162,10 @@ export class Tools {
tbMy.getFileSystemManager().readFile({ tbMy.getFileSystemManager().readFile({
filePath: i, filePath: i,
// encoding: "utf8", // encoding: "utf8",
success: function(r) { success: function (r) {
}, },
fail: function(res) { fail: function (res) {
} }
}) })
...@@ -307,11 +309,11 @@ export class Tools { ...@@ -307,11 +309,11 @@ export class Tools {
showTime: number = 300 showTime: number = 300
) { ) {
Tween.get(target) Tween.get(target)
.set({alpha: 0, visible: true}) .set({ alpha: 0, visible: true })
.to({alpha: 1}, showTime, Ease.quadIn) .to({ alpha: 1 }, showTime, Ease.quadIn)
.wait(time) .wait(time)
.to({alpha: 0}, showTime, Ease.quadOut) .to({ alpha: 0 }, showTime, Ease.quadOut)
.set({alpha: 0, visible: false}) .set({ alpha: 0, visible: false })
.call(() => { .call(() => {
call(); call();
}); });
......
This source diff could not be displayed because it is too large. You can view the blob instead.
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { wait } from "../../module/ctrls";
export class JoinPanel extends Panel {
get groupNames() {
return ["JoinPanel"]
}
data: { url: string }
initUi() {
this.addChild(FYGE.Sprite.fromFrame("joinBg.png"))
this.addChild(new FYGE.Button(RES.getRes("关闭按钮.png")))
.addEventListener(FYGE.MouseEvent.CLICK, () => { this.hidePanel(); }, this)
.position.set(634, 472)
this.addChild(new FYGE.Button(RES.getRes("joinBtn.png")))
.addEventListener(FYGE.MouseEvent.CLICK, () => {
this.enableMouseEvt(false);
wait(() => { this.enableMouseEvt(true) }, 2000)
sendTbNet(TbNetName.navigateToOutside, { url: this.data.url })
}, this)
.position.set(166, 744)
}
}
import { Panel } from "../../module/views/Panel"; import { Panel } from "../../module/views/Panel";
import { PropType } from "../something/enum/PropType"; import { PropType } from "../something/enum/PropType";
import { getTbData, TbNetName } from "../TaoBaoNet";
import { Tools } from "../Tools";
import { showWaiting, hideWaiting, getCurrentScene, showPanel, showToast } from "../../module/ctrls";
import { JoinPanel } from "./JoinPanel";
export class ToolsOutPanel extends Panel { export class ToolsOutPanel extends Panel {
get groupNames() { get groupNames() {
...@@ -9,24 +13,50 @@ export class ToolsOutPanel extends Panel { ...@@ -9,24 +13,50 @@ export class ToolsOutPanel extends Panel {
get skinName() { get skinName() {
return "ToolsOutPanel" return "ToolsOutPanel"
} }
get closeBtns() {
return [this.consideBtn, this.closeBtn]
}
consideBtn: FYGE.Button; consideBtn: FYGE.Button;
sureBtn: FYGE.Button; sureBtn: FYGE.Button;
closeBtn: FYGE.Button; closeBtn: FYGE.Button;
msgTxt: FYGE.TextField; msgTxt: FYGE.TextField;
data:{type:PropType} data: { type: PropType }
initUi() { initUi() {
// 文案居中
Tools.changeTextAlign(this.msgTxt, FYGE.TEXT_ALIGN.CENTER, 500)
} }
start(data) { start(data) {
super.start(); super.start();
//文案按接口返回的来
this.msgTxt.text = "要消耗" +
getTbData(TbNetName.getActivityBaseInfoById).data.buyCredits[data.type] +
"积分兑换吗?"
} }
initEvents() { initEvents() {
super.initEvents(); super.initEvents();
this.sureBtn.addEventListener(FYGE.MouseEvent.CLICK, async () => {
//购买道具
showWaiting();
var res = await Tools.exchange(this.data.type);
hideWaiting();
//如果是链接,弹出加入会员弹框
if (typeof res == "string") {
showPanel(JoinPanel, { url: res })
}
//成功了,关闭弹框,修改道具信息
else if (res) {
showToast("兑换成功")
this.hidePanel();
getCurrentScene().updateScene()
}
}, this)
} }
removeEvents() { removeEvents() {
......
...@@ -23,6 +23,20 @@ export class LoadingScene extends Scene { ...@@ -23,6 +23,20 @@ export class LoadingScene extends Scene {
this.y = -layers.stageOffsetY this.y = -layers.stageOffsetY
//背景 //背景
this.addChild(FYGE.Sprite.fromFrame("loadingBg.jpg")) this.addChild(FYGE.Sprite.fromFrame("loadingBg.jpg"))
//光
var l1 = this.addChild(FYGE.Sprite.fromFrame("lighting_1.png"))
l1.position.set(543, 765)
var l2 = this.addChild(FYGE.Sprite.fromFrame("lighting_2.png"))
l2.position.set(545, 765)
l2.visible = false;
FYGE.Tween.get(l1, { loop: true })
.wait(500)
.call(() => { l1.visible = !l1.visible })
FYGE.Tween.get(l2, { loop: true })
.wait(500)
.call(() => { l2.visible = !l2.visible })
// console.log(a.position,b.position)
//摩天轮 //摩天轮
var wheel = this.addChild(FYGE.Sprite.fromFrame("wheel.png")) var wheel = this.addChild(FYGE.Sprite.fromFrame("wheel.png"))
.addEventListener(FYGE.Event.ENTER_FRAME, () => { .addEventListener(FYGE.Event.ENTER_FRAME, () => {
...@@ -75,9 +89,6 @@ export class LoadingScene extends Scene { ...@@ -75,9 +89,6 @@ export class LoadingScene extends Scene {
(750 - 500) / 2, (750 - 500) / 2,
1288 - 24 + 18 + 48 1288 - 24 + 18 + 48
)) ))
} }
async start() { async start() {
...@@ -87,7 +98,7 @@ export class LoadingScene extends Scene { ...@@ -87,7 +98,7 @@ export class LoadingScene extends Scene {
GDispatcher.dispatchEvent(FYGE.Event.PROGRESS, 0.2) GDispatcher.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) GDispatcher.dispatchEvent(FYGE.Event.PROGRESS, 0.3)
//询问读取权限,不阻止进程 //询问读取权限,不阻止进程
...@@ -129,7 +140,7 @@ export class LoadingScene extends Scene { ...@@ -129,7 +140,7 @@ export class LoadingScene extends Scene {
// private lastP=0 // private lastP=0
progressEvent(e: FYGE.Event) { progressEvent(e: FYGE.Event) {
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: e.data }, 2000/**(p-this.lastP)*/)
.call(() => { .call(() => {
if (e.data >= 1) { if (e.data >= 1) {
GDispatcher.removeEventListener(FYGE.Event.PROGRESS, this.progressEvent, this); GDispatcher.removeEventListener(FYGE.Event.PROGRESS, this.progressEvent, this);
...@@ -196,19 +207,19 @@ class Title extends FYGE.Container { ...@@ -196,19 +207,19 @@ class Title extends FYGE.Container {
this.y = -560;//待调整 this.y = -560;//待调整
//新建就动画出现吧, //新建就动画出现吧,
FYGE.Tween.get(this) FYGE.Tween.get(this)
.to({y: targetY + 25}, 300) .to({ y: targetY + 25 }, 300)
.to({y: targetY - 30}, 100) .to({ y: targetY - 30 }, 100)
.to({y: targetY}, 100); .to({ y: targetY }, 100);
[line, title].forEach((e) => { [line, title].forEach((e) => {
FYGE.Tween.get(e) FYGE.Tween.get(e)
.to({rotation: 1.5}, 300) .to({ rotation: 1.5 }, 300)
.to({rotation: -0.5}, 100) .to({ rotation: -0.5 }, 100)
.to({rotation: 0}, 100) .to({ rotation: 0 }, 100)
if (e === line) { if (e === line) {
FYGE.Tween.get(e) FYGE.Tween.get(e)
.to({scaleY: 1.05}, 300) .to({ scaleY: 1.05 }, 300)
.to({scaleY: 0.96}, 100) .to({ scaleY: 0.96 }, 100)
.to({scaleY: 1}, 100) .to({ scaleY: 1 }, 100)
} }
}) })
......
...@@ -55,6 +55,8 @@ import { RES } from '../../module/RES'; ...@@ -55,6 +55,8 @@ import { RES } from '../../module/RES';
import { showToast, showWaiting, showPanel, hideWaiting } from '../../module/ctrls'; import { showToast, showWaiting, showPanel, hideWaiting } from '../../module/ctrls';
import { layers } from '../../module/views/layers'; import { layers } from '../../module/views/layers';
import { ToolsOutPanel } from '../panels/ToolsOutPanel'; import { ToolsOutPanel } from '../panels/ToolsOutPanel';
import { Lottie } from '../Lottie';
import { bb } from '../bb';
const aniClass = { const aniClass = {
"BoomAni": BoomAni, "BoomAni": BoomAni,
...@@ -95,7 +97,12 @@ export const effectBaseTimes = { ...@@ -95,7 +97,12 @@ export const effectBaseTimes = {
//加载器 //加载器
let svgaParser; let svgaParser;
//三个toast和bonusTime //三个toast和bonusTime
const movieClips: any = {} const movieClips = {
wonderful: null,
amazing: null,
great: null,
bonusTime: null
}
//红包炸弹弹框名字 //红包炸弹弹框名字
const redBombPanelName = "RedBombAlert"; const redBombPanelName = "RedBombAlert";
...@@ -106,7 +113,7 @@ const festivalIndex: number = 40 ...@@ -106,7 +113,7 @@ const festivalIndex: number = 40
export class PlayScene extends Scene { export class PlayScene extends Scene {
get groupNames() { get groupNames() {
return ["playScene", "fiveVerHorDis", "bonusTime"] return ["playScene", "fiveVerHorDis"]
} }
//关卡数据 //关卡数据
...@@ -226,7 +233,7 @@ export class PlayScene extends Scene { ...@@ -226,7 +233,7 @@ export class PlayScene extends Scene {
//步数道具引导时的圆 //步数道具引导时的圆
stepCircle: FYGE.Graphics//Shape; stepCircle: FYGE.Graphics//Shape;
//bonus Time 提示 //bonus Time 提示
bonusTime: BonusTime; // bonusTime: BonusTime;
//游戏操作引导 //游戏操作引导
gameGuide: GameGuide; gameGuide: GameGuide;
//记录是否有红包炸弹弹框 //记录是否有红包炸弹弹框
...@@ -314,34 +321,15 @@ export class PlayScene extends Scene { ...@@ -314,34 +321,15 @@ export class PlayScene extends Scene {
* 加载所有用到的svga * 加载所有用到的svga
* 重写,变成其他动画 * 重写,变成其他动画
*/ */
initSvgas() { async initSvgas() {
// var resPath = getResPath(); //这里加载资源吧
// if (!svgaParser) svgaParser = new window["SVGA"].Parser(); await RES.loadGroup("bonusTime")
// var svgas = ["amazing", "great", "wonderful", "bonusTime"]; var bonusTime = new Lottie(bb)
// //如果有节日的加 bonusTime.position.set(
// if (this.festivalTarget) svgas.push("redBombLight"); (750 - bonusTime.videoWidth) / 2,
// for (let i = 0; i < svgas.length; i++) { (1624 - bonusTime.videoHeight) / 2 - layers.stageOffsetY
// if (movieClips[svgas[i]]) continue; )
// svgaParser.load(resPath + 'resource/assets/svgas/' + svgas[i] + ".svga", (videoItem) => { movieClips.bonusTime = bonusTime;
// var mv = new window["SVGA"].EgretMovieClip(videoItem);
// mv.lockStep = true;
// if (svgas[i] != "bonusTime") {
// mv.x = (750 - 520) / 2;
// mv.y = 500;
// }
// mv.stop();
// let fun;
// mv.addEventListener(FYGE.Event.COMPLETE, fun = function (e) {
// e.currentTarget.stop()
// if (e.currentTarget.parent) {
// e.currentTarget.parent.removeChild(e.currentTarget)
// }
// }, this)
// movieClips[svgas[i]] = mv;
// }, function (error) {
// // alert(error.message);
// })
// }
} }
//初始化界面ui,,道具弄在这里s //初始化界面ui,,道具弄在这里s
...@@ -398,9 +386,9 @@ export class PlayScene extends Scene { ...@@ -398,9 +386,9 @@ export class PlayScene extends Scene {
this.propGuide = new PropGuide(this.propBtnCon.y - 10); this.propGuide = new PropGuide(this.propBtnCon.y - 10);
// this.addChild(this.propGuide); // this.addChild(this.propGuide);
//bonusTime引导,备用的,无需加入场景 //bonusTime引导,备用的,无需加入场景
this.bonusTime = new BonusTime(); // this.bonusTime = new BonusTime();
this.bonusTime.x = 375 // this.bonusTime.x = 375
this.bonusTime.y = 1624 / 2 - layers.stageOffsetY; // this.bonusTime.y = 1624 / 2 - layers.stageOffsetY;
} }
initTarget() { initTarget() {
...@@ -1835,9 +1823,9 @@ export class PlayScene extends Scene { ...@@ -1835,9 +1823,9 @@ export class PlayScene extends Scene {
//连消基数为1 //连消基数为1
this.commonContinuityTimes = 1; this.commonContinuityTimes = 1;
this.effectContinuityTimes = 1; this.effectContinuityTimes = 1;
this.addChild(this.bonusTime); this.addChild(movieClips.bonusTime);
this.bonusTime.play(1, () => { movieClips.bonusTime.play(1, () => {
this.removeChild(this.bonusTime) this.removeChild(movieClips.bonusTime)
this.terminateSteps(); this.terminateSteps();
}) })
return return
......
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