AS3 - 仅 iOS 强制横向模式? [英] AS3 - iOS force landscape mode only?

查看:20
本文介绍了AS3 - 仅 iOS 强制横向模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为 iOS 开发了一款专为横向模式设计的游戏,它运行得很好,只是如果你将设备转到纵向模式,它就会停在那里,界面只占屏幕的中半部分.如何强制应用程序只允许两种横向模式而不是停在纵向位置.

I've built a game for iOS that is designed for landscape mode and it works just fine except that if you turn the device to portrait mode it stops there to with the interface only filling about the middle half of the screen. How can I force the app to only allow the two landscape modes and not stop at the portrait position.

我已经尝试了所有发布设置.纵横比设置为横向并选中自动方向,如果我取消选中自动方向,应用程序不会旋转到其他横向模式,我听说这是 Apple 的自动拒绝.

I've tried all the publishing settings. Aspect Ratio is set for Landscape and Auto Orientation is checked on, if I uncheck AUto Orientation that the app does not rotate to the other landscape mode and I hear that's an automatic rejection from Apple.

除了这个小缺陷之外,这个应用程序已经准备就绪.感谢您提供的任何帮助.

This app is ready to go except for this little flaw. Thanks for any help you can offer.

丰富

推荐答案

我几天前在 Adob​​e 论坛上找到了这个问题的答案.

I found the answer to this over on the Adobe forums a few days ago.

将纵横比设置为自动.

将自动方向设置为允许.

Set Auto Orientation to allowed.

然后在您的主剪辑上使用此代码:

Then use this code on your main clip:

var startOrientation:String = stage.orientation;
if (startOrientation == StageOrientation.DEFAULT || startOrientation == StageOrientation.UPSIDE_DOWN)
  {
    stage.setOrientation(StageOrientation.ROTATED_RIGHT);
  }
  else
  {
    stage.setOrientation(startOrientation);
  }                    

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChangeListener);

function orientationChangeListener(e:StageOrientationEvent)
{
   if (e.afterOrientation == StageOrientation.DEFAULT || e.afterOrientation ==  StageOrientation.UPSIDE_DOWN)
   {
     e.preventDefault();
   }
}

对我来说效果很好..

这篇关于AS3 - 仅 iOS 强制横向模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆