2013-04-24 70 views

回答

1

开发出快速解决方案!基本上创建一个与屏幕大小相同的四元组,并将其添加到最前面的图层。

添加到的init()最前层文件的功能:

Starling.current.addEventListener('TOUCH_BLOCKER_ENABLE', touchBlockerEnable); 
Starling.current.addEventListener('TOUCH_BLOCKER_DISABLE', touchBlockerDisable); 

接着定义这些功能:

private function touchBlockerEnable(e:Event):void 
{ 
    if(!_quad) 
    { 
     _quad = new Quad(Starling.current.stage.width,Starling.current.stage.height,0xFFE6E6); 
     _quad.x = 0; 
     _quad.y = 0; 
     _quad.alpha = 0.1; 
     addChild(_quad); 
    } 
} 

private function touchBlockerDisable(e:Event):void 
{ 
    if(_quad) 
    { 
     removeChild(_quad); 
     _quad = null; 
    } 
} 

调用此函数可激活触摸拦截:

Starling.current.dispatchEvent(new Event('TOUCH_BLOCKER_ENABLE')); 
3

如果您不想让对象触摸,可以禁用“可触摸”属性。当它被禁用时,对象和它的孩子都不会再收到任何触摸事件。

没有必要添加新的显示对象来防止触摸。

this.touchable = false;