【发布时间】:2014-04-13 23:58:32
【问题描述】:
我浏览了整个网络,试图弄清楚如何调整 Adobe Air 应用程序视口矩形的大小。我似乎无法弄清楚。
我想做的是用 Adobe AIR 制作一个游戏,这样当按下“退格”键(现在进行测试)时,它可以让游戏进入 FULL_SCREEN。
游戏目前在 stage.displayState.NORMAL 中启动,我将在未来实现一个选项以启用 FULL_SCREEN。
但是,我似乎无法弄清楚的问题是,当 FULL_SCREEN 在 Adobe AIR 中处于活动状态时,如何让我的舞台与屏幕中心对齐。
我想要的是,当您进入全屏时,舞台就像发布的第一张图片一样位于中间。
这是我处理舞台设置的 Main.AS。当舞台进入全屏时,如何对齐设置在中间的舞台。像伊萨克的结合?
[SWF(frameRate="60", width="1920", height="1080", backgroundColor="#000000")]
public class Main extends MovieClip {
public var _starling:Starling;
public static var screenWidth:Number = 0.0;
public static var screenHeight:Number = 0.0;
public function Main() {
addEventListener(Event.ADDED_TO_STAGE, stageSetup);
}
private function stageSetup(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, stageSetup);
stage.displayState = StageDisplayState.NORMAL;
var rect:Rectangle = new Rectangle(0, 0, stage.fullScreenWidth, stage.fullScreenHeight);
screenWidth = stage.fullScreenWidth > 1920 ? 1920 : stage.fullScreenWidth;
screenHeight = stage.fullScreenHeight > 1080 ? 1080 : stage.fullScreenHeight;
Starling.handleLostContext = false;
_starling = new Starling( GameEngine, stage);
_starling.antiAliasing = 1;
_starling.start();
_starling.showStats = true;
stage.addEventListener(KeyboardEvent.KEY_DOWN, escKeyOverride);
stage.addEventListener(KeyboardEvent.KEY_DOWN, enableFullScreen);
stage.addEventListener(Event.RESIZE, resize);
}
private function enableFullScreen(e:KeyboardEvent):void {
if (e.keyCode == 8) {
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
stage.scaleMode = StageScaleMode.EXACT_FIT;
}
else {
//build in button listener for settings to resize back to normal
stage.scaleMode = StageScaleMode.EXACT_FIT;
}
}
private function escKeyOverride(e:KeyboardEvent):void {
if (e.keyCode == 27) {
e.preventDefault();
}
}
private function resize(e:Event):void {
var viewPortRectangle:Rectangle = new Rectangle();
viewPortRectangle.width = stage.stageWidth;
viewPortRectangle.height = stage.stageHeight;
Starling.current.viewPort = viewPortRectangle;
_starling.stage.stageWidth = stage.stageWidth;
_starling.stage.stageHeight = stage.stageHeight;
}
}
谢谢。
【问题讨论】:
标签: actionscript-3 actionscript air adobe