diff --git a/project/functions.js b/project/functions.js index 38473475..3361b52d 100644 --- a/project/functions.js +++ b/project/functions.js @@ -160,7 +160,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.setWeather(weather[0], weather[1]); else core.setWeather(); - core.deleteAllTickers(); // 摧毁所有现存的高级动画 + core.deleteAllAnis(); // 摧毁所有现存的高级动画 // ...可以新增一些其他内容,比如创建个画布在右上角显示什么内容等等 diff --git a/project/plugins.js b/project/plugins.js index f11bd935..034e7603 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -1146,10 +1146,20 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = if (main.replayChecking) __enable = false; if (!__enable) { core.plugin.animate = {}; - this.deleteAllTickers = () => { }; + this.aniMap = new Map(); + this.deleteAllAnis = () => { }; return; } + /** 键为一个自建Ticker, 值为摧毁它的事件 */ + this.aniMap = new Map(); + + /** 对Map中所有Ticker执行摧毁事件 */ + this.deleteAllAnis = function () { + core.plugin.aniMap.forEach((destroyEvent, ani) => destroyEvent(ani)); + core.plugin.aniMap.clear(); + } + var M = Object.defineProperty; var E = (n, i, t) => i in n ? M(n, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[i] = t; var o = (n, i, t) => (E(n, typeof i != "symbol" ? i + "" : i, t), t); @@ -1167,11 +1177,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }; requestAnimationFrame(k); - /** 摧毁所有有名字的ticker */ - this.deleteAllTickers = function () { - w.forEach((ticker) => ticker.destroy()); - } - // I is Ticker class I { constructor() { @@ -1900,7 +1905,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = const transitionList = []; - const ctxName = 'globalAnimate'; + const ctxName = 'autoClear'; if (Ticker) { const ticker = new Ticker(); @@ -2121,6 +2126,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = let px = tx * 32 - core.bigmap.offsetX; let py = ty * 32 - core.bigmap.offsetY; const t = new Transition(); + const onDestory = function (t) { + t.ticker.destroy(); + const index = transitionList.findIndex(v => v === t); + transitionList.splice(index, 1); + } // 摧毁Transition t + core.plugin.aniMap.set(t, onDestory); t.mode(hyper('sin', 'out')) .time(transitionTime) .absolute() @@ -2136,9 +2147,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = if (Math.abs(t.value.x - x * 32 + core.bigmap.offsetX) < 0.05 && Math.abs(t.value.y - y * 32 + core.bigmap.offsetY) < 0.05 ) { - t.ticker.destroy(); - const index = transitionList.findIndex(v => v === t); - transitionList.splice(index, 1); + onDestory(t); } }); } @@ -2385,6 +2394,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = function drawCommentStr(content, x, y, vx) { if (core.isReplaying() || !Animation) return; const ani = new Animation(); + core.plugin.aniMap().set(ani, (ani) => ani.ticker.destroy()); ani.ticker.add(() => { core.fillText(ctxName, content, x + ani.x, y, 'white', '16px Verdana'); }) @@ -2392,9 +2402,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = .time(600 / vx) .absolute() .move(-600, 0) - ani.all().then(() => { - ani.ticker.destroy(); - }); + ani.all().then(() => { + ani.ticker.destroy(); + }); } //#endregion