代码之家  ›  专栏  ›  技术社区  ›  AminSojoudi

如何得到电晕模拟器工作的操作系统?

  •  0
  • AminSojoudi  · 技术社区  · 6 年前

    我只想知道有没有任何方法可以得到运行日冕模拟器的主机的操作系统?

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

    在电晕模拟器中,返回的值取决于皮肤 选中,允许您通过更改 皮肤。

    我正在Windows上开发,我的模拟器皮肤设置为Android设备,但是 system.getinfo(“平台”) 我找不到主机操作系统(即Windows)。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Rob Miracle    6 年前

    我没有提到你想知道模拟器是在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