Commit f30e05f0 authored by wildfirecode's avatar wildfirecode

1

parent 55baa0d8
......@@ -185,6 +185,11 @@ class Main extends MainBase {
Waiting.instance.hide();
return;
}
if (window['pageID'] == 'TransScene') {
SceneCtrl.instance.change(ModuleTypes.TransScene);
Waiting.instance.hide();
return;
}
loadSvgaRes(getResPath() + 'resource/assets/svgas/standby.svga');
loadSvgaRes(getResPath() + 'resource/assets/svgas/trans.svga');
......
......@@ -46,6 +46,7 @@ export enum ModuleTypes {
Share2Scene,
TeamShareScene,
ShareStarterScene,
TransInviterScene,
TransScene,
TransRecordPanel,
TOAST
......
import Scene from "../views/Scene";
import { getResPath } from "../utils";
import { loadSvgaRes, loadSvga } from "../loadSvga";
import { wait } from "../GameConst";
import { NetManager } from "../../libs/tw/manager/NetManager";
import { DataManager } from "../../libs/tw/manager/DataManager";
export default class TransInviterScene extends Scene {
_bg: SVGA.EgretMovieClip;
_standby: SVGA.EgretMovieClip;
_trans: SVGA.EgretMovieClip;
_isInviterSide = false;
_shareCode;
protected get skinKey() { return 'Trans' }
constructor(data) {
super();
this.initUI(data);
}
async initUI(data) {
// await Promise.all([
// loadSvgaRes(getResPath() + 'resource/assets/svgas/progress.svga'),
// loadSvgaRes(getResPath() + 'resource/assets/svgas/progress2.svga'),
// ]);
//要区分是分享者,还是被分享者
this._bg = await loadSvga(getResPath() + 'resource/assets/svgas/bg.svga', this['group']) as SVGA.EgretMovieClip;
this._bg.visible = false;
this._standby = await loadSvga(getResPath() + 'resource/assets/svgas/standby.svga', this['group']) as SVGA.EgretMovieClip;
this._standby.visible = false;
this._trans = await loadSvga(getResPath() + 'resource/assets/svgas/trans.svga', this['group']) as SVGA.EgretMovieClip;
this._trans.visible = false;
this.changeToStandBy();
this['group'].addChild(this['waitTips']);
this['group'].addChild(this['matchingTips']);
this['group'].addChild(this['shareTips']);
this.addAni(this['waitTips']);
this.addAni(this['matchingTips']);
this.addAni(this['shareTips']);
// this['matchingTips'];
// this['shareTips'];
const sharecode = 0;
if (this._isInviterSide) {//邀请者
this['matchingTips'].visible = true;
NetManager.ins.yyh_pollingAnimationState((success) => {
const data = DataManager.ins.getData('yyh_pollingAnimationState').data;
if (data == 3) {//摇一摇
this.changeToTrans();
this['waitTips'].visible = false;
this['matchingTips'].visible = false;
this['shareTips'].visible = false;
}
}, sharecode, () => {
const data = DataManager.ins.getData('yyh_pollingAnimationState').data;
if (data == 1) {//被邀请者确认邀请
this['waitTips'].visible = true;
this['matchingTips'].visible = false;
}
if (data == 2) {//用户取消
//暂时无法取消
}
return data === null || data === 0 || data == 1|| data == 2;
})
} else {
this.setRightPhone();//邀请者
this['shareTips'].visible = true;
//进入页面后发送确认消息
NetManager.ins.yyh_updateAnimationState(sharecode, 1, (success) => {
if (success) {
this.addShareEvent();
}
});
}
}
addAni(d) {
egret.Tween.get(d, { loop: true })
.to({ alpha: 0 }, 500).wait(500)
.to({ alpha: 1 }, 500).wait(500);
}
addShareEvent() {
if (window.DeviceMotionEvent) {
var speed = 25;
var x = 0, y = 0, z = 0, lastX = 0, lastY = 0, lastZ = 0;
window.addEventListener('devicemotion', (event) => {
var acceleration = event.accelerationIncludingGravity;
x = acceleration.x;
y = acceleration.y;
if (Math.abs(x - lastX) > speed || Math.abs(y - lastY) > speed) {
this['shareTips'].visible = false;
NetManager.ins.yyh_updateAnimationState(this._shareCode, 3, (success) => {
if (success) {
}
});
}
lastX = x;
lastY = y;
}, false);
}
}
setRightPhone() {
this._standby.x = -750;
this._trans.x = -750;
}
changeToStandBy() {
this._standby.visible = true;
this._trans.visible = false;
this._standby.gotoAndPlay(1, true);
}
async changeToTrans() {
this._trans.gotoAndPlay(40, true);
wait(500).then(async () => {
this._bg.gotoAndPlay(1, true);
await wait(100);
this._bg.visible = true;
this._bg.once(egret.Event.COMPLETE, () => {
this._bg.stop();
}, this);
});
await wait(100);
this._standby.visible = false;
this._trans.visible = true;
this._trans.once(egret.Event.COMPLETE, () => {
console.log('COMPLETE')
this.changeToStandBy();
if (!this._isInviterSide) {
this._standby.x = 40;
this._standby.y = 10;
}
}, this);
}
onTap_btn() {
console.log('onTap_btn');
}
initEvents() {
// this.onTap(this['btn'], this.onTap_btn);
}
}
\ 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