AS3:全屏而不是让我的电影剪辑遍布其上

发布于 2024-12-09 17:21:22 字数 1051 浏览 0 评论 0原文

好吧,我已经尝试了很多方法让我的游戏全屏运行,但这似乎是不可能的。这是我到目前为止所尝试过的:

代码 1:

stop();
stage.stageWidth = Capabilities.screenResolutionX;
stage.stageHeight = Capabilities.screenResolutionY;


var arrayStars:Array = [];
for(var i:int = 0; i<260; i++)
{
    var star:Star = new Star();

    star.x = Math.floor(Math.random() * stage.stageWidth);
    star.y = Math.floor(Math.random() * stage.stageHeight);

    addChild(star);
    arrayStars.push(star);
}

代码 2:

stop();
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
var sX:Number =stage.stageWidth;
var sY:Number = stage.stageHeight;


var arrayStars:Array = [];
for(var i:int = 0; i<260; i++)
{
    var star:Star = new Star();

    star.x = Math.floor(Math.random() * sX);
    star.y = Math.floor(Math.random() * sY);

    addChild(star);
    arrayStars.push(star);
}

代码 3: 与代码 2 类似,但我没有使用变量 sX 和 sY,而是直接使用 stage.stageWidth 和 stage.stageHeight。 主要问题不是让应用程序全屏运行,它确实如此,但是影片剪辑全部保留在一个区域中,而不是覆盖整个屏幕。我认为问题可能与全屏方法无关,也许与随机生成器有关?

Well guys, I've tried lots of ways to get my game running on fullscreen, it seems to be impossible. Here's what I've tried so far:

CODE 1:

stop();
stage.stageWidth = Capabilities.screenResolutionX;
stage.stageHeight = Capabilities.screenResolutionY;


var arrayStars:Array = [];
for(var i:int = 0; i<260; i++)
{
    var star:Star = new Star();

    star.x = Math.floor(Math.random() * stage.stageWidth);
    star.y = Math.floor(Math.random() * stage.stageHeight);

    addChild(star);
    arrayStars.push(star);
}

CODE 2:

stop();
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
var sX:Number =stage.stageWidth;
var sY:Number = stage.stageHeight;


var arrayStars:Array = [];
for(var i:int = 0; i<260; i++)
{
    var star:Star = new Star();

    star.x = Math.floor(Math.random() * sX);
    star.y = Math.floor(Math.random() * sY);

    addChild(star);
    arrayStars.push(star);
}

CODE 3: Similar to code 2, but instead of using the variables sX and sY I've used directly stage.stageWidth and stage.stageHeight.
The main problem is not getting the app to run in fullscreen, it does, but the movie clips, stay all in a area, not covering all the screen. I think that the problem may not have to do with the fullscreen methods, maybe with the random generator?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

墨落成白 2024-12-16 17:21:23

我认为代码是在阶段实际切换到全屏之前运行的。试试这个:

private function OnFullScreenButtonMouseClick( _e:MouseEvent ):void {
  stage.addEventListener( Event.RESIZE, OnResize, false, 0, true );
  stage.align = StageAlign.TOP_LEFT;
  stage.scaleMode = StageScaleMode.NO_SCALE;
  stage.displayState = StageDisplayState.FULL_SCREEN;
}
...
function OnResize( event:Event ):void {
  var sX:Number =stage.stageWidth;
  var sY:Number = stage.stageHeight;


  var arrayStars:Array = [];
  for(var i:int = 0; i<260; i++)
  {
      var star:Star = new Star();

      star.x = Math.floor(Math.random() * sX);
      star.y = Math.floor(Math.random() * sY);

      addChild(star);
      arrayStars.push(star);
  }
}

I think code is runned before stage is actually switched to fullscreen. Try this:

private function OnFullScreenButtonMouseClick( _e:MouseEvent ):void {
  stage.addEventListener( Event.RESIZE, OnResize, false, 0, true );
  stage.align = StageAlign.TOP_LEFT;
  stage.scaleMode = StageScaleMode.NO_SCALE;
  stage.displayState = StageDisplayState.FULL_SCREEN;
}
...
function OnResize( event:Event ):void {
  var sX:Number =stage.stageWidth;
  var sY:Number = stage.stageHeight;


  var arrayStars:Array = [];
  for(var i:int = 0; i<260; i++)
  {
      var star:Star = new Star();

      star.x = Math.floor(Math.random() * sX);
      star.y = Math.floor(Math.random() * sY);

      addChild(star);
      arrayStars.push(star);
  }
}
流绪微梦 2024-12-16 17:21:22

舞台大小调整为全屏并返回必须在用户操作时完成,例如鼠标单击:

来自文档:“全屏模式是响应用户的鼠标单击或按键而启动的;如果没有用户,影片无法更改 Stage.displayState输入。”

static public function handleStageDisplayStateChange ( e : MouseEvent ) : void
{
    if ( stage.displayState == StageDisplayState.NORMAL )
        stage.displayState = StageDisplayState.FULL_SCREEN;
    else
        stage.displayState = StageDisplayState.NORMAL;
}

The stage resize to fullScreen and back must be done on user itteraction, fo example mouseClick:

From documentation: "Full-screen mode is initiated in response to a mouse click or key press by the user; the movie cannot change Stage.displayState without user input."

static public function handleStageDisplayStateChange ( e : MouseEvent ) : void
{
    if ( stage.displayState == StageDisplayState.NORMAL )
        stage.displayState = StageDisplayState.FULL_SCREEN;
    else
        stage.displayState = StageDisplayState.NORMAL;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文