【问题标题】:How to get operation system where Corona Simulator is working on?如何获得 Corona Simulator 正在运行的操作系统?
【发布时间】:2019-05-11 03:51:54
【问题描述】:

我只是想知道有没有什么方法可以获取运行 Corona 模拟器的主机的操作系统?

我知道system.getInfo("environment") == "simulator" 和system.getInfo("platform")。

在电晕模拟器中,返回的值取决于皮肤 选中,允许您通过更改测试依赖于平台的逻辑 皮肤。

我正在 Windows 上开发,我的模拟器皮肤设置为 Android 设备,但使用 system.getInfo("platform") 我找不到主机操作系统(即 Windows)。

【问题讨论】:

  • 有具体的操作系统吗?这个是安卓还是IOS?
  • 我已经更新了我的问题。
  • system.getInfo( "androidApiLevel" ) 返回android api级别?您可以使用它来转换为版本代码,例如android api 级别 26 = Android 8.0 Oreo。我在官方文档中找不到关于返回正在使用的 Windows 操作系统的任何地方。

标签: lua coronasdk


【解决方案1】:

我错过了关于您想知道模拟器是否在 Windows、macOS 或其他系统上运行的要点。显然,正如您所指出的,这将为您提供皮肤平台。

system.getInfo() API 允许您获取平台:

http://docs.coronalabs.com/api/library/system/getInfo.html#platform

这会让您知道您使用的是“android”、“ios”、“win32”等。

只有少数用例需要您关心模拟器在运行什么。在大多数情况下,您希望模拟最终设备。我猜您正在构建一些用户将在 Windows 或 macOS 上运行的工具。我认为您会为 Windows 或 macOS 二进制文件构建一个 .exe 并将其分发给任何想要使用它的人。

但您可以使用“architectureInfo”来获取底层架构信息。如果您在 Windows 上,它将返回“x86”或“x64”之类的内容。您可以结合查看您是否在模拟器中运行来测试它:

if system.getInfo( "environment" ) == "simulator" then
    if (system.getInfo("architectureInfo") == "x86" or system.getInfo("architectureInfo") == "x64") then
        print("This simulator is running on Windows")
    elseif (system.getInfo("architectureInfo") == "x86_64" or system.getInfo("architectureInfo") == "i386") then
        print("This simulator is running on macOS")
    end
end

见:http://docs.coronalabs.com/api/library/system/getInfo.html#architectureinfo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-01
    • 1970-01-01
    • 2011-03-19
    • 1970-01-01
    • 1970-01-01
    • 2012-11-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多