0

我想在我的游戏中实现这一点http://www.emanueleferonato.com/2011/03/29/pausing-a-flash-game-or-movie-detecting-its-focus/

一切正常(游戏暂停),但屏幕没有“绘制”,但如果我将鼠标移到 swf 上,屏幕就会出现

private function onDeactivate(e:Event):void {
            pauseGame=true;
            addChild(FocusScreen);
            if(musicOn==true){
                musicCh.stop();
            }
            stage.frameRate = 0;
        }

更新:仅当我将阶段帧速率设置为 0 时才会发生这种情况,但我需要将帧速率设置为 0

private function onDeactivate(e:Event):void {
                pauseGame=true;
                addChild(FocusScreen);
                if(musicOn==true){
                    musicCh.stop();
                }
            }
4

1 回答 1

1

e.updateAfterEvent()设置舞台帧率后调用。这会强制重绘舞台,之后舞台的帧速率设置为 0,并且在您恢复其帧速率之前不会再重绘舞台。

更新:显然这是 Flash 播放器 11.3 中的一个错误(可能是更多的 FP11)在 FP10 中没有到位,所以当我使用 FlashDevelop 附带的调试器 FP10 时,教程中的“裸”方法对我有用,但是当我在安装了 FP11.3 的 FF 中尝试它时没有用。所以解决方法如下:Sprite在代码中添加一个虚假对象,不要在任何地方添加它,它将作为自定义MouseEvent事件的接收者,仅用于调用updateAfterEvent(). 这对我来说可以显示一个表示暂停状态的自定义 DisplayObject。

private var pausedRecipient:Sprite=new Sprite();
// do not add child so that its listener won't trigger on user input
pausedRecipient.addEventListener(MouseEvent.CLICK,uae);
private function uae(e:MouseEvent):void {e.updateAfterEvent();}
private function onDeactivate(e:Event):void {
            pauseGame=true;
            addChild(FocusScreen);
            if(musicOn==true){
                musicCh.stop();
            }
            pausedRecipient.dispatchEvent(
              new MouseEvent(MouseEvent.CLICK,true, true, -1, -1, stage));
            // ^ this does the trick of indirect call of updateAfterEvent()
        }
于 2013-08-05T04:00:01.943 回答