mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 08:42:43 +08:00
@@ -18,4 +18,7 @@ export type TweenEasing =
|
||||
export interface ITweenOption {
|
||||
easing?: TweenEasing | ((k: number) => number);
|
||||
progress?: (start: number, end: number, current: number, ratio: number) => number;
|
||||
onStart?: Function;
|
||||
onUpdate?: Function;
|
||||
onComplete?: Function;
|
||||
}
|
||||
@@ -63,18 +63,9 @@ function TweenOptionChecker (opts: ITweenOption) {
|
||||
if (opts['interpolation']) {
|
||||
warn(header + 'interpolation' + message);
|
||||
}
|
||||
if (opts['onStart']) {
|
||||
warn(header + 'onStart' + message);
|
||||
}
|
||||
if (opts['onStop']) {
|
||||
warn(header + 'onStop' + message);
|
||||
}
|
||||
if (opts['onUpdate']) {
|
||||
warn(header + 'onUpdate' + message);
|
||||
}
|
||||
if (opts['onComplete']) {
|
||||
warn(header + 'onComplete' + message);
|
||||
}
|
||||
}
|
||||
|
||||
export class TweenAction extends ActionInterval {
|
||||
@@ -170,6 +161,7 @@ export class TweenAction extends ActionInterval {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this._opts.onStart) { this._opts.onStart(); }
|
||||
}
|
||||
|
||||
update (t: number) {
|
||||
@@ -182,7 +174,7 @@ export class TweenAction extends ActionInterval {
|
||||
let easingTime = t;
|
||||
if (opts.easing) easingTime = opts.easing(t);
|
||||
|
||||
let progress = this._opts.progress;
|
||||
let progress = opts.progress;
|
||||
for (const name in props) {
|
||||
let prop = props[name];
|
||||
let time = prop.easing ? prop.easing(t) : easingTime;
|
||||
@@ -208,6 +200,8 @@ export class TweenAction extends ActionInterval {
|
||||
|
||||
target[name] = prop.current;
|
||||
}
|
||||
if (opts.onUpdate) { opts.onUpdate(); }
|
||||
if (t == 1 && opts.onComplete) { opts.onComplete(); }
|
||||
}
|
||||
|
||||
progress (start: any, end: any, current: any, t: number) {
|
||||
|
||||
Reference in New Issue
Block a user