简体   繁体   English

如何在仅适用于景观的应用程序的Android上的Corona SDK中检测方向变化?

[英]how to detect an orientation change in Corona SDK on Android for an Landscape Only app?

How to detect an orientation change in Corona SDK on Android for an Landscape Only app? 如何在仅适用于景观的应用程序的Android上的Corona SDK中检测方向变化?

I note that the following do not work: 我注意到以下无效:

  • using the orientation event won't work - this is noting an orientation event is not produced when switching between landscapeLeft to landscapeRight or vice-versa (ie portrait not supported in the app) 使用定位事件将不起作用-这说明当在landscapeLeft和landscapeRight之间切换(反之亦然)(即应用中不支持纵向)时,不会产生定位事件

  • using the "resize" event doesn't work - it only occurs for apps that support both portrait and landscape orientations 使用“调整大小”事件不起作用-仅在同时支持纵向和横向的应用中发生

MAIN QUESTION THEREFORE: How to detect an orientation change in Corona SDK on Android for an Landscape Only app? 主要问题:如何在仅适用于景观的应用程序的Android上的Corona SDK中检测方向变化?

UPDATE: Actually some concerning is that I've just confirmed that on Android (on my new Nexus 7) that "system.orientation" is NOT changes when I tip the device upside down. 更新:实际上,我担心的是,我刚刚确认在Android设备(在新的Nexus 7上)将设备倒置时,“ system.orientation”不变。 That is it stay on "landscapeRight". 那就是停留在“ landscapeRight”上。 So would this be a Corona bug? 那这会是一个电晕虫吗? Only fix is going to be not allowing users to be able to tip/use the game upside down then no? 唯一的解决办法就是不允许用户颠倒使用/倾斜游戏,不是吗? (ie in landscapeLeft) (即在landscapeLeft中)

Corona won't distinguish between landscapeLeft and landscapeRight if your app only supports landscape mode. 如果您的应用仅支持横向模式,那么Corona不会区分landscapeLeft和landscapeRight。 The Docs for Project Build Settings ( http://docs.coronalabs.com/guide/distribution/buildSettings/index.html ) state that: 用于项目构建设置的文档( http://docs.coronalabs.com/guide/distribution/buildSettings/index.html )指出:

4.In Android 2.2, if you build a landscape-only app by supporting landscapeRight and landscapeLeft, it will never display in the landscapeLeft mode. 4,在Android 2.2中,如果通过支持landscapeRight和landscapeLeft构建仅风景应用,则它将永远不会以landscapeLeft模式显示。 Likewise, if you build a portrait-only app by supporting portrait and portraitUpsideDown, it will never appear as portraitUpsideDown. 同样,如果您通过支持portrait和portraitUpsideDown来构建仅纵向应用,则该应用永远不会显示为portraitUpsideDown。 This is an Android 2.2 limitation. 这是Android 2.2的限制。

I've created a small project and can confirm that on my Nexus4 with Android 4.3, "orientation" event too doesn't get called (although it works in Simulator). 我已经创建了一个小项目,可以确认在带有Android 4.3的Nexus4上也没有调用“定向”事件(尽管它在Simulator中可以正常工作)。

To answer your questions then: you can't detect orientation change for landscape only app. 然后要回答您的问题:您无法检测仅适用于景观的应用程序的方向变化。 It doesn't seem to be Corona bug, rather Android limitation. 它似乎不是Corona错误,而是Android的局限性。

当前在Android设备上,仅在build.settings文件中启用自动旋转时才生成方向事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM