fix:ticker回收
This commit is contained in:
parent
c8e88364c1
commit
a8a715c5a8
@ -160,7 +160,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
core.setWeather(weather[0], weather[1]);
|
core.setWeather(weather[0], weather[1]);
|
||||||
else core.setWeather();
|
else core.setWeather();
|
||||||
|
|
||||||
core.deleteAllTickers(); // 摧毁所有现存的高级动画
|
core.deleteAllAnis(); // 摧毁所有现存的高级动画
|
||||||
|
|
||||||
// ...可以新增一些其他内容,比如创建个画布在右上角显示什么内容等等
|
// ...可以新增一些其他内容,比如创建个画布在右上角显示什么内容等等
|
||||||
|
|
||||||
|
|||||||
@ -1146,10 +1146,20 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
if (main.replayChecking) __enable = false;
|
if (main.replayChecking) __enable = false;
|
||||||
if (!__enable) {
|
if (!__enable) {
|
||||||
core.plugin.animate = {};
|
core.plugin.animate = {};
|
||||||
this.deleteAllTickers = () => { };
|
this.aniMap = new Map();
|
||||||
|
this.deleteAllAnis = () => { };
|
||||||
return;
|
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 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 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);
|
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);
|
requestAnimationFrame(k);
|
||||||
|
|
||||||
/** 摧毁所有有名字的ticker */
|
|
||||||
this.deleteAllTickers = function () {
|
|
||||||
w.forEach((ticker) => ticker.destroy());
|
|
||||||
}
|
|
||||||
|
|
||||||
// I is Ticker
|
// I is Ticker
|
||||||
class I {
|
class I {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -1900,7 +1905,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
|
|
||||||
const transitionList = [];
|
const transitionList = [];
|
||||||
|
|
||||||
const ctxName = 'globalAnimate';
|
const ctxName = 'autoClear';
|
||||||
|
|
||||||
if (Ticker) {
|
if (Ticker) {
|
||||||
const ticker = new Ticker();
|
const ticker = new Ticker();
|
||||||
@ -2121,6 +2126,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
let px = tx * 32 - core.bigmap.offsetX;
|
let px = tx * 32 - core.bigmap.offsetX;
|
||||||
let py = ty * 32 - core.bigmap.offsetY;
|
let py = ty * 32 - core.bigmap.offsetY;
|
||||||
const t = new Transition();
|
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'))
|
t.mode(hyper('sin', 'out'))
|
||||||
.time(transitionTime)
|
.time(transitionTime)
|
||||||
.absolute()
|
.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 &&
|
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
|
Math.abs(t.value.y - y * 32 + core.bigmap.offsetY) < 0.05
|
||||||
) {
|
) {
|
||||||
t.ticker.destroy();
|
onDestory(t);
|
||||||
const index = transitionList.findIndex(v => v === t);
|
|
||||||
transitionList.splice(index, 1);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2385,6 +2394,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
function drawCommentStr(content, x, y, vx) {
|
function drawCommentStr(content, x, y, vx) {
|
||||||
if (core.isReplaying() || !Animation) return;
|
if (core.isReplaying() || !Animation) return;
|
||||||
const ani = new Animation();
|
const ani = new Animation();
|
||||||
|
core.plugin.aniMap().set(ani, (ani) => ani.ticker.destroy());
|
||||||
ani.ticker.add(() => {
|
ani.ticker.add(() => {
|
||||||
core.fillText(ctxName, content, x + ani.x, y, 'white', '16px Verdana');
|
core.fillText(ctxName, content, x + ani.x, y, 'white', '16px Verdana');
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user