From 99c1b05e892fc6412f2fb16c8e10cce8b7fa32d3 Mon Sep 17 00:00:00 2001 From: AqeeAqee Date: Sun, 27 Aug 2023 22:09:29 +0800 Subject: [PATCH] fix, crash if ParticleSource.anchor isn't a Sprite --- render_raycasting.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/render_raycasting.ts b/render_raycasting.ts index f3812ce..df4f086 100644 --- a/render_raycasting.ts +++ b/render_raycasting.ts @@ -261,9 +261,12 @@ namespace Render { } } else if(spr instanceof particles.ParticleSource){ const particle = (spr as particles.ParticleSource) - if (this.spriteParticles.indexOf(particle) < 0) { - this.spriteParticles[(particle.anchor as Sprite).id]=particle - particle.anchor=this.tempSprite + if (this.spriteParticles.indexOf(particle) < 0 && particle.anchor instanceof Sprite) { + const spr = (particle.anchor as Sprite) + if(this.sprites.indexOf(spr)>=0){ + this.spriteParticles[spr.id]=particle + particle.anchor=this.tempSprite + } } } else { if (this.spriteLikes.indexOf(spr) < 0)