fix: 离屏画布没有删除导致的内存泄漏

This commit is contained in:
AncTe committed 2024-11-20 21:11:01 +08:00
1 parent 003369bed1
commit f1b20450aa
15 files changed
+179 -87

No files matched your search

+5
View File
@@ -163,8 +163,10 @@ export class ArrowProjectile extends Projectile<TowerBoss> {
this.easing = void 0;
this.dangerEasing = void 0;
this.horizontal?.clear();
this.horizontal?.delete();
this.horizontal = null;
this.vertical?.clear();
this.vertical?.delete();
this.vertical = null;
}
@@ -465,6 +467,7 @@ export class ThunderProjectile extends Projectile<TowerBoss> {
static end() {
this.cache?.clear();
this.cache?.delete();
this.cache = null;
}
@@ -648,8 +651,10 @@ export class ThunderBallProjectile extends Projectile<TowerBoss> {
static end() {
this.dangerEasing = void 0;
this.horizontal?.clear();
this.horizontal?.delete();
this.horizontal = null;
this.vertical?.clear();
this.vertical?.delete();
this.vertical = null;
}
+2
View File
@@ -337,6 +337,8 @@ export class Chase extends EventEmitter<ChaseEvent> {
Chase.shader.remove();
this.emit('end', success);
this.removeAllListeners();
this.pathMap.forEach(v => v.delete());
this.pathMap.clear();
}
}
+2 -2
View File
@@ -1,7 +1,7 @@
import { Animation, hyper, linear, power, sleep } from 'mutate-animate';
import { Chase, ChaseData, IChaseController } from './chase';
import { completeAchievement } from '../ui/achievement';
import { Camera, CameraAnimation, CameraScale } from '@/core/render/camera';
import { Camera, CameraAnimation, ICameraScale } from '@/core/render/camera';
import { LayerGroup } from '@/core/render/preset/layer';
import { MotaRenderer } from '@/core/render/render';
import { Sprite } from '@/core/render/sprite';
@@ -272,7 +272,7 @@ function playAudio(from: number, chase: Chase) {
function processScale(
chase: Chase,
ani: Animation,
scale: CameraScale,
scale: ICameraScale,
camera: Camera
) {
chase.onceLoc(35, 3, 'MT15', () => {