Commit b6598fa8 authored by wildfirecode's avatar wildfirecode

1

parent 01dcb6db
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<script src="libs/zepto.min.js"></script> <script src="libs/zepto.min.js"></script>
<script src="libs/security.js"></script> <script src="libs/security.js"></script>
<script src="libs/downloadApp.js"></script> <script src="libs/downloadApp.js"></script>
<script src="libs/svga.egret.min.js"></script> <script src="http://yun.duiba.com.cn/db_games/svga.egret.min.new.js"></script>
<script> <script>
......
export as namespace SVGA;
declare global {
const SVGA: {
Parser: typeof Parser,
EgretMovieClip: typeof EgretMovieClip,
}
}
export class VideoEntity {
videoSize: { width: number, height: number }
FPS: number
frames: number
}
export class Parser {
load(url: string, success: (videoItem: VideoEntity) => void, failure?: (err: Error) => void): void
}
export class EgretMovieClip extends egret.DisplayObjectContainer {
/**
* 锁步,只关心每帧间隔时间,不管浏览器帧率
* 默认false
*/
lockStep: boolean;
/**
* 当前帧数
* 1最小
*/
readonly currentFrame: number;
/**
* 是否播放
*/
readonly isPlaying: boolean;
/**
* 正序还是反序
*/
readonly isFront: boolean;
/**
* 所有帧数
*/
totalFrames: number;
/**
*
* @param imagekey 要替换的图片key值
* @param imageUrl 图片路径或_png
*/
setImage(imagekey: string, imageUrl: string): void
/**
* 停止
*/
stop(): void;
/**
* 播放
*/
play(): void;
/**
* 进入下一帧
*/
nextFrame(): void;
/**
* 进入上一帧
*/
prevFrame(): void;
/**
* 停在指定帧
* @param frameIndex
*/
gotoAndStop(frameIndex: number): void;
/**
* 从某帧开始播放
* @param frameIndex 1开始
* @param isFront 默认true正向播放
*/
gotoAndPlay(frameIndex: number, isFront: boolean): void;
readonly isInTimeFrame: boolean;
/**
* 帧数范围播放
* @param beginFrame 开始播放的帧序号,默认第一帧
* @param endFrame 结束播放的帧序号,默认最后一帧
* @param loops 循环次数, 默认1次,负数为无限次,无限循环callback无效,因为永远不会完成,用正常的complete监听最后一帧或第一帧
* @param callback 所有播放完的回调
*/
startAniRange(beginFrame: number, endFrame: number, loops: number, callback?: Function): void
constructor(mv: VideoEntity)
}
...@@ -162,11 +162,11 @@ class Main extends MainBase { ...@@ -162,11 +162,11 @@ class Main extends MainBase {
// 创建游戏场景 // 创建游戏场景
protected createGameScene() { protected createGameScene() {
super.createGameScene(); super.createGameScene();
// SceneCtrl.instance.change(ModuleTypes.ShareStarterScene); SceneCtrl.instance.change(ModuleTypes.TransScene);
// PanelCtrl.instance.show(ModuleTypes.SloganPanel); // PanelCtrl.instance.show(ModuleTypes.SloganPanel);
// Waiting.instance.hide(); Waiting.instance.hide();
// return; return;
//获取UA信息 //获取UA信息
let userAgent = navigator.userAgent.toLowerCase(); let userAgent = navigator.userAgent.toLowerCase();
console.log(userAgent); console.log(userAgent);
......
const parser = new SVGA.Parser();
export const loadSvga = (url: string, parent?: egret.DisplayObjectContainer) => {
return new Promise((resolve, reject) => {
parser.load(url, (videoItem) => {
const mv = new SVGA.EgretMovieClip(videoItem);
if (parent) {
mv.gotoAndPlay(1, true)
parent.addChild(mv);
}
mv.addEventListener(egret.Event.COMPLETE, () => {
// console.log("播放完成")
}, this);
resolve(mv);
}, (error) => {
reject(error.message);
})
});
}
export const loadSvgaRes = (url: string) => {
return new Promise((resolve, reject) => {
parser.load(url, (videoItem) => {
resolve();
}, (error) => {
reject(error.message);
})
});
}
\ No newline at end of file
import Scene from "../views/Scene"; import Scene from "../views/Scene";
import { getResPath } from "../utils";
import { loadSvgaRes, loadSvga } from "../loadSvga";
import { wait } from "../GameConst";
export default class TransScene extends Scene { export default class TransScene extends Scene {
_standby: SVGA.EgretMovieClip;
_trans: SVGA.EgretMovieClip;
_isLeft = false;
protected get skinKey() { return 'Trans' } protected get skinKey() { return 'Trans' }
constructor(data) { constructor(data) {
...@@ -8,8 +14,56 @@ export default class TransScene extends Scene { ...@@ -8,8 +14,56 @@ export default class TransScene extends Scene {
this.initUI(data); this.initUI(data);
} }
initUI(data) { async initUI(data) {
// await Promise.all([
// loadSvgaRes(getResPath() + 'resource/assets/svgas/progress.svga'),
// loadSvgaRes(getResPath() + 'resource/assets/svgas/progress2.svga'),
// ]);
//要区分是分享者,还是被分享者 //要区分是分享者,还是被分享者
this._standby = await loadSvga(getResPath() + 'resource/assets/svgas/standby.svga', this) as SVGA.EgretMovieClip;
this._trans = await loadSvga(getResPath() + 'resource/assets/svgas/trans.svga', this) as SVGA.EgretMovieClip;
this._standby.visible = false;
this._trans.visible = false;
this.changeToStandBy();
setTimeout(() => {
this.changeToTrans();
}, 2000);
if (this._isLeft) {
} else {
this.setRightPhone();
}
}
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(1, true);
await wait(100);
this._standby.visible = false;
this._trans.visible = true;
this._trans.once(egret.Event.COMPLETE, () => {
console.log('COMPLETE')
this.changeToStandBy();
if (!this._isLeft) {
this._standby.x = 40;
this._standby.y = 10;
}
}, this);
} }
onTap_btn() { onTap_btn() {
......
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