看下源码可以知道失焦的功能是在FlxGame中一个createFocusScreen实现的,而我们的主类是继承于这个FlxGame的。
我们在主文档类中重写这个createFocusScreen方法
这里给一个我写的例子作为参考
上面的代码:override protected function createFocusScreen():void{var gfx:Graphics = _focus.graphics;var screenWidth:uint = FlxG.width*FlxCamera.defaultZoom;var screenHeight:uint = FlxG.height*FlxCamera.defaultZoom;var bg:Bitmap = new ImgBlur();bg.scaleX = int(helper/10);if(bg.scaleX < 1)bg.scaleX = 1;bg.scaleY = bg.scaleX;bg.x -= bg.scaleX;_focus.addChild(bg);var halfWidth:uint = screenWidth/2;var halfHeight:uint = screenHeight/2;var helper:uint = FlxU.min(halfWidth,halfHeight)/3;gfx.moveTo(halfWidth-helper,halfHeight-helper);gfx.beginFill(0x999999,1);gfx.lineTo(halfWidth+helper,halfHeight);gfx.lineTo(halfWidth-helper,halfHeight+helper);gfx.lineTo(halfWidth-helper,halfHeight-helper);gfx.endFill();var logo:Bitmap = new ImgLogo();logo.scaleX = int(helper/10);if(logo.scaleX < 1)logo.scaleX = 1;logo.scaleY = logo.scaleX;logo.x -= logo.scaleX;logo.alpha = 0.35;_focus.addChild(logo);addChild(_focus);}