@@ -18,7 +18,7 @@ export interface ISummonInitData {
1818/**
1919 * 类似于 Unity 的 MonoBehaviour (针对召唤物)
2020 */
21- export abstract class BaseSummon extends Phaser . Physics . Arcade . Sprite {
21+ export abstract class BaseSummon extends Phaser . GameObjects . Sprite {
2222 protected isDespawning : boolean = false ; // ✅ 移到基类,统一管理状态
2323 protected lifeTimer : number = 0 ;
2424 protected maxLifeTime : number = - 1 ;
@@ -36,17 +36,13 @@ export abstract class BaseSummon extends Phaser.Physics.Arcade.Sprite {
3636 public onSpawn ( data : ISummonInitData ) {
3737 this . setActive ( true ) ;
3838 this . setVisible ( true ) ;
39- this . body ! . enable = true ; // 确保物理开启
4039 this . isDespawning = false ; // ✅ 关键:复活时重置状态
4140
4241 this . setPosition ( data . x , data . y ) ;
4342 this . lifeTimer = 0 ;
4443 this . maxLifeTime = data . lifeTime ?? - 1 ;
4544 this . target = data . target || null ;
4645
47- // 重置物理状态
48- this . setVelocity ( 0 , 0 ) ;
49- this . setAcceleration ( 0 , 0 ) ;
5046 this . setAlpha ( 1 ) ;
5147 this . setScale ( 1 ) ;
5248
@@ -101,7 +97,6 @@ export abstract class BaseSummon extends Phaser.Physics.Arcade.Sprite {
10197 protected kill ( ) {
10298 this . setActive ( false ) ;
10399 this . setVisible ( false ) ;
104- if ( this . body ) this . body . enable = false ;
105100 // 状态已在 onSpawn 重置,这里不需要改 isDespawning
106101 console . log ( `[BaseSummon] ${ this . constructor . name } returned to pool.` ) ;
107102 }
@@ -117,4 +112,4 @@ export abstract class BaseSummon extends Phaser.Physics.Arcade.Sprite {
117112 // 默认行为:没有动画,直接死
118113 this . kill ( ) ;
119114 }
120- }
115+ }
0 commit comments