多语言展示
当前在线:1850今日阅读:86今日分享:14

flixel如何替换失焦图片

我们都知道flixel引擎有失焦管理系统,当焦点脱离flash后会暂停,画面中会被灰色的盖住。但有时会觉得这样比较丑,下面将会告诉你如何替换这个失焦图片。
方法/步骤
1

看下源码可以知道失焦的功能是在FlxGame中一个createFocusScreen实现的,而我们的主类是继承于这个FlxGame的。

2

我们在主文档类中重写这个createFocusScreen方法

3

这里给一个我写的例子作为参考

4

上面的代码: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);}

推荐信息