123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- var t = require;
- var e = module;
- var i = exports;
- Object.defineProperty(i, "__esModule", {value: !0});
- t = t("BaseClass");
- i.default = class extends t.default {
- constructor() {
- super();
- }
- static get ins() {
- return this.getInstance();
- }
- showSpotMove(e, t, i, s, o, a, n) {
- var r = this.getCurveFuncAroundSrcPoint(t, i, o);
- return this.tweenHelper(
- e.item,
- s,
- function (t) {
- t = r(t);
- (e.item.x = t.x), (e.item.y = t.y), (e.particle1.x = t.x), (e.particle1.y = t.y);
- },
- "smooth",
- a,
- n
- );
- }
- showCurveByRandomPoint(e, t, i, s, o, a, n) {
- (e.x = t.x), (e.y = t.y);
- var r = this.getCurveFuncAroundSrcPoint(t, i, o);
- this.tweenHelper(
- e,
- s,
- function (t) {
- e.isValid && ((t = r(t)), (e.x = t.x), (e.y = t.y));
- },
- "smooth",
- a,
- n
- );
- }
- showCurveBySurePoint(i, t, e, s, o, a = "linear", n, r, l) {
- var h = this.getCurveFunc(t, s, e);
- this.tweenHelper(
- i,
- o,
- function (t) {
- var e = h(t);
- (i.x = e.x), (i.y = e.y), l && l.apply(r, [t]);
- },
- a,
- n,
- r
- );
- }
- getCurveFuncAroundSrcPoint(t, e, i = 100) {
- i = this.getControllPointAroundSrcPoint(t, e, i);
- return this.getCurveFunc(t, e, i);
- }
- getCurveFuncAroundMidPoint(t, e) {
- var i = this.getControllPointAroundMidPoint(t, e);
- return this.getCurveFunc(t, e, i);
- }
- getControllPointAroundSrcPoint(t, e, i) {
- var s = Math.random() * Math.PI * 2,
- i = new cc.Vec2(Math.sin(s) * i, Math.cos(s) * i);
- return t.add(i);
- }
- getControllPointAroundMidPoint(t, e) {
- var i = t.sub(e).mag() / 4,
- t = t.lerp(e, 0.5),
- e = Math.random() * Math.PI * 2;
- return t.add(new cc.Vec2(i * Math.sin(e), i * Math.cos(e)));
- }
- getCurveFunc(i, s, o) {
- return function (t) {
- var e = (1 - t) * (1 - t) * i.x + 2 * t * (1 - t) * o.x + t * t * s.x,
- t = (1 - t) * (1 - t) * i.y + 2 * t * (1 - t) * o.y + t * t * s.y;
- return new cc.Vec2(e, t);
- };
- }
- phase1Easing(t) {
- t = (2 - t) / 2;
- return 1 - (Math.cos(Math.PI / 4) - Math.cos((90 * t * Math.PI) / 180)) / Math.cos(Math.PI / 4);
- }
- phase3Easing(t) {
- t = (t + 1) / 2;
- return (Math.cos(Math.PI / 4) - Math.cos((90 * t * Math.PI) / 180)) / Math.cos(Math.PI / 4);
- }
- tweenHelper(t, e, o, i, s, a) {
- var n = {t: 0},
- r =
- e <= 2
- ? cc
- .tween()
- .to(
- e / 2,
- {t: 0.5},
- {
- progress: function (t, e, i, s) {
- o(t + (e - t) * s);
- },
- easing: this.phase1Easing
- }
- )
- .call(function () {
- n.t = 0.5;
- })
- .to(
- e / 2,
- {t: 1},
- {
- progress: function (t, e, i, s) {
- o(t + (e - t) * s);
- },
- easing: this.phase3Easing
- }
- )
- : cc
- .tween()
- .to(
- 1.5,
- {t: 1.5 / e},
- {
- progress: function (t, e, i, s) {
- o(t + (e - t) * s);
- },
- easing: this.phase1Easing
- }
- )
- .call(function () {
- n.t = 1.5 / e;
- })
- .to(
- e - 1.5 - 0.5,
- {t: 1 - 0.5 / e},
- {
- progress: function (t, e, i, s) {
- o(t + (e - t) * s);
- },
- easing: function (t) {
- return t;
- }
- }
- )
- .call(function () {
- n.t = 1 - 0.5 / e;
- })
- .to(
- 0.5,
- {t: 1},
- {
- progress: function (t, e, i, s) {
- o(t + (e - t) * s);
- },
- easing: this.phase3Easing
- }
- );
- return cc
- .tween(n)
- .then(r)
- .call(function () {
- s && s.call(a, t);
- })
- .start();
- }
- };
|