Commit c2432134 authored by wangjianfeng.yz's avatar wangjianfeng.yz

2.0.67

parent d5c1a94f
declare namespace FYGE{export const VERSION = "2.0.66";
declare namespace FYGE{export const VERSION = "2.0.67";
export function cos(angle: number): number;
......@@ -7826,10 +7826,10 @@ export class AnimationClip extends EventDispatcher {
* 在一个区间范围内播放
* @param beginTime 开始时间,秒计,默认0,
* @param endTime 结束时间,秒计,默认_totalTime
* @param loops 循环次数,默认1,0表示无限循环
* @param callback 参数loop表示还剩几次
* @param loops 循环次数,0或负数表示无限循环,默认1
* @param callback 播放完成后的回调,无限循环时无效
*/
startAniRange(beginTime?: number, endTime?: number, loops?: number, callback?: (loop: number) => void): void;
startAniRange(beginTime?: number, endTime?: number, loops?: number, callback?: () => void): void;
/**
* 矫正
*/
......@@ -7919,8 +7919,9 @@ export abstract class AnimationNode extends Container {
* 播放loop次后回调
* @param loop 播放次数
* @param callback 播放次数完后回调
* @param isFront 播放顺序,默认true,正向
*/
play(loop?: number, callback?: () => void): void;
play(loop?: number, callback?: () => void, isFront?: boolean): void;
/**
* 开始播放
* @param isFront 是否正向,默认是
......@@ -7976,12 +7977,12 @@ export abstract class AnimationNode extends Container {
gotoAndPlay: (time: number, isFront?: boolean) => void;
/**
* 在一个区间范围内播放
* @param beginTime 开始时间,计,默认0,
* @param endTime 结束时间,秒计,默认_totalTime
* @param loops 循环次数,默认1,0表示无限循环
* @param callback 参数loop表示还剩几次
* @param beginTime 开始时间,按帧数计,默认0,
* @param endTime 结束时间,秒帧数计,默认totalFrames
* @param loops 循环次数,0或负数表示无限循环,默认1
* @param callback 播放完成后的回调,无限循环时无效
*/
startAniRange: (beginTime: number, endTime: number, loops: number, callback?: (loop: number) => void) => void;
startAniRange: (beginTime?: number, endTime?: number, loops?: number, callback?: () => void) => void;
}
export class FrameAni extends AnimationNode {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
export const VERSION = "2.0.66";
export const VERSION = "2.0.67";
export function cos(angle: number): number;
......@@ -7826,10 +7826,10 @@ export class AnimationClip extends EventDispatcher {
* 在一个区间范围内播放
* @param beginTime 开始时间,秒计,默认0,
* @param endTime 结束时间,秒计,默认_totalTime
* @param loops 循环次数,默认1,0表示无限循环
* @param callback 参数loop表示还剩几次
* @param loops 循环次数,0或负数表示无限循环,默认1
* @param callback 播放完成后的回调,无限循环时无效
*/
startAniRange(beginTime?: number, endTime?: number, loops?: number, callback?: (loop: number) => void): void;
startAniRange(beginTime?: number, endTime?: number, loops?: number, callback?: () => void): void;
/**
* 矫正
*/
......@@ -7919,8 +7919,9 @@ export abstract class AnimationNode extends Container {
* 播放loop次后回调
* @param loop 播放次数
* @param callback 播放次数完后回调
* @param isFront 播放顺序,默认true,正向
*/
play(loop?: number, callback?: () => void): void;
play(loop?: number, callback?: () => void, isFront?: boolean): void;
/**
* 开始播放
* @param isFront 是否正向,默认是
......@@ -7976,12 +7977,12 @@ export abstract class AnimationNode extends Container {
gotoAndPlay: (time: number, isFront?: boolean) => void;
/**
* 在一个区间范围内播放
* @param beginTime 开始时间,计,默认0,
* @param endTime 结束时间,秒计,默认_totalTime
* @param loops 循环次数,默认1,0表示无限循环
* @param callback 参数loop表示还剩几次
* @param beginTime 开始时间,按帧数计,默认0,
* @param endTime 结束时间,秒帧数计,默认totalFrames
* @param loops 循环次数,0或负数表示无限循环,默认1
* @param callback 播放完成后的回调,无限循环时无效
*/
startAniRange: (beginTime: number, endTime: number, loops: number, callback?: (loop: number) => void) => void;
startAniRange: (beginTime?: number, endTime?: number, loops?: number, callback?: () => void) => void;
}
export class FrameAni extends AnimationNode {
......
......@@ -207,6 +207,7 @@
//svga动画
SvgaParser.loadSvga("./res/小贱成年常态.svga", (v) => {
// console.log(v)
var s = stage.addChild(new FYGE.SvgaAni(v))
s.x += 200;
s.y -= 600;
......@@ -214,7 +215,9 @@
//lottie动画(文件全)
FYGE.GlobalLoader.loadJson((s, json) => {
var l = stage.addChild(new FYGE.Lottie(json))
l.play()
// l.startAniRange(l.totalFrames,0,2,()=>{
// console.log(111)
// })
l.x += 200
}, "./res/click_action_11.json")
//lottie转svga播放,先不支持了,引擎内删除了
......@@ -266,7 +269,14 @@
//测试svga蒙版
SvgaParser.loadSvga("./res/测蒙版.svga", (v) => {
stage.addChild(new FYGE.SvgaAni(v)).y -= 100
let s=stage.addChild(new FYGE.SvgaAni(v))
s.y -= 100;
s.play(0,()=>{
console.log(111)
},false)
// s.startAniRange(0,s.totalFrames,3,()=>{
// console.log(111)
// })
})
// var ss = stage.addChild(new FYGE.EditableText())
......
{
"name": "fyge",
"version": "2.0.66",
"version": "2.0.67",
"description": "canvas渲染引擎",
"main": "./build/fyge.min.js",
"module": "./build/fyge.esm.js",
......
......@@ -601,6 +601,10 @@
ScrollView的_scrollTo缓动方法默认值改成Ease.quadOut
Object3D的destroy方法吧removeAllEventListener的操作放到removeChild之后,否则从scene移除的事件触发不了
2.0.67 AnimationClip的startAniRange方法修改,主要为了倒放时有bug
AnimationNode的play方法新增第三个参数isFront,为了play可以按次数倒放
AnimationNode的声明方法startAniRange修改了参数可传可不传
......
......@@ -181,14 +181,14 @@ export class AnimationClip extends EventDispatcher {
* 在一个区间范围内播放
* @param beginTime 开始时间,秒计,默认0,
* @param endTime 结束时间,秒计,默认_totalTime
* @param loops 循环次数,默认1,0表示无限循环
* @param callback 参数loop表示还剩几次
* @param loops 循环次数,0或负数表示无限循环,默认1
* @param callback 播放完成后的回调,无限循环时无效
*/
public startAniRange(
beginTime: number = 0,
endTime: number = this._totalTime,
loops: number = 1,
callback?: (loop: number) => void
callback?: () => void
) {
//loops处理下
loops = loops || 0;//去掉null等等
......@@ -204,13 +204,8 @@ export class AnimationClip extends EventDispatcher {
this.gotoAndStop(beginTime)
//如果相等
return
} else if (beginTime < endTime) {
this._isFront = true;
} else {
this._isFront = false;
var temp = beginTime;
beginTime = endTime;
endTime = temp;
this._isFront = beginTime < endTime;
}
//移除原先的绑定吧
if (this.startAniRangeFun) this.removeEventListener(Event.ENTER_FRAME, this.startAniRangeFun, this)
......@@ -219,33 +214,19 @@ export class AnimationClip extends EventDispatcher {
let loopCount = loops ? (loops + 0.5 >> 0) : Infinity;
this.addEventListener(Event.ENTER_FRAME, this.startAniRangeFun = (e: Event) => {
let s: AnimationClip = e.target;
if (s._isFront) {
if (s.curTime >= endTime || s._endMark) {//
loopCount--;
if (loopCount <= 0) {
s.gotoAndStop(endTime);//这个在下一帧才生效,所以加一个矫正rectify
// s.rectify();
s.removeEventListener(Event.ENTER_FRAME, this.startAniRangeFun, this);
this.startAniRangeFun = null;
callback && callback(loopCount);
s.rectify();//放在最后吧,callback里也可能干了啥
} else {
s.gotoAndPlay(beginTime);
}
}
} else {
if (s.curTime <= beginTime || s._endMark) {
loopCount--
if (loopCount <= 0) {
s.gotoAndStop(beginTime);//这个在下一帧才生效,所以加一个矫正rectify
// s.rectify();
s.removeEventListener(Event.ENTER_FRAME, this.startAniRangeFun, this);
this.startAniRangeFun = null;
callback && callback(loopCount);
s.rectify();//放在最后吧,callback里也可能干了啥
} else {
s.gotoAndPlay(endTime, false);
}
let cond = s._isFront ? s.curTime >= endTime : s.curTime <= endTime;
if (cond || s._endMark) {
loopCount--;
if (loopCount <= 0) {
s._isPlaying = false;
s.curTime = endTime;//这个在下一帧才生效,所以加一个矫正rectify
// s.rectify();
s.removeEventListener(Event.ENTER_FRAME, s.startAniRangeFun, s);
s.startAniRangeFun = null;
callback && callback();
s.rectify();//放在最后吧,callback里也可能干了啥
} else {
s.curTime = beginTime;
}
}
}, this)
......
......@@ -7,7 +7,7 @@
* @name VERSION
* @type {string}
*/
export const VERSION = "2.0.66";
export const VERSION = "2.0.67";
/**
......
......@@ -119,8 +119,9 @@ export abstract class AnimationNode extends Container {
* 播放loop次后回调
* @param loop 播放次数
* @param callback 播放次数完后回调
* @param isFront 播放顺序,默认true,正向
*/
play(loop?: number, callback?: () => void): void;
play(loop?: number, callback?: () => void, isFront?: boolean): void;
/**
* 开始播放
* @param isFront 是否正向,默认是
......@@ -131,7 +132,7 @@ export abstract class AnimationNode extends Container {
* @param {number|boolean} loop 播放测试,默认0,一直循环播放
* @param callback 回调
*/
play(loop?: any, callback?: () => void): void {
play(loop?: any, callback?: () => void, isFront: boolean = true): void {
if (!this.animationClip) return;
//如果没有参数,或者第一个参数是布尔的走animationClip.play
if (!arguments.length || typeof arguments[0] == "boolean") {
......@@ -140,7 +141,13 @@ export abstract class AnimationNode extends Container {
}
//其他走播放次数
loop = loop || 0;
this.animationClip.startAniRange(0, this.animationClip.totalTime, loop, callback)
let endTime = this.animationClip.totalTime;//其实就是this.totalFrames
this.animationClip.startAniRange(
isFront ? 0 : endTime,
isFront ? endTime : 0,
loop,
callback
)
}
/**
* 停止,需要自定义的用this.animationClip
......@@ -201,12 +208,12 @@ export abstract class AnimationNode extends Container {
gotoAndPlay: (time: number, isFront?: boolean) => void;
/**
* 在一个区间范围内播放
* @param beginTime 开始时间,计,默认0,
* @param endTime 结束时间,秒计,默认_totalTime
* @param loops 循环次数,默认1,0表示无限循环
* @param callback 参数loop表示还剩几次
* @param beginTime 开始时间,按帧数计,默认0,
* @param endTime 结束时间,秒帧数计,默认totalFrames
* @param loops 循环次数,0或负数表示无限循环,默认1
* @param callback 播放完成后的回调,无限循环时无效
*/
startAniRange: (beginTime: number, endTime: number, loops: number, callback?: (loop: number) => void) => void;
startAniRange: (beginTime?: number, endTime?: number, loops?: number, callback?: () => void) => void;
};
//这三个直接用clip的
["gotoAndStop", "gotoAndPlay", "startAniRange"].forEach((v) => {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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