File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export class SpriteManager {
2323 }
2424 set activeSprite ( s : VisibleSprite | null ) {
2525 if ( s === this . #activeSprite) return ;
26+ if ( s && ! s . actable ) return ;
2627 this . #activeSprite = s ;
2728 this . #evtTool. emit ( ESpriteManagerEvt . ActiveSpriteChange , s ) ;
2829 }
@@ -32,7 +33,7 @@ export class SpriteManager {
3233 this . getSprites ( )
3334 // 排在后面的层级更高
3435 . reverse ( )
35- . find ( ( s ) => s . visible && s . rect . checkHit ( x , y ) ) ?? null ;
36+ . find ( ( s ) => s . visible && s . actable && s . rect . checkHit ( x , y ) ) ?? null ;
3637 }
3738
3839 async addSprite ( vs : VisibleSprite ) : Promise < void > {
Original file line number Diff line number Diff line change @@ -30,6 +30,11 @@ export class VisibleSprite extends BaseSprite {
3030 */
3131 visible = true ;
3232
33+ /**
34+ * 元素是否可选中,用于设置元素是否响应画布的选中事件,设置为 false 时不可选中,默认为 true 可选中
35+ */
36+ actable = true ;
37+
3338 constructor ( clip : IClip ) {
3439 super ( ) ;
3540 this . #clip = clip ;
@@ -108,6 +113,7 @@ export class VisibleSprite extends BaseSprite {
108113 super . copyStateTo ( target ) ;
109114 if ( target instanceof VisibleSprite ) {
110115 target . visible = this . visible ;
116+ target . actable = this . actable ;
111117 }
112118 }
113119
You can’t perform that action at this time.
0 commit comments