Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将移相器与Cordova连接_Android_Html_Cordova_Phaser Framework - Fatal编程技术网

Android 如何将移相器与Cordova连接

Android 如何将移相器与Cordova连接,android,html,cordova,phaser-framework,Android,Html,Cordova,Phaser Framework,我正在使用Visual Studio 2015开发html5游戏,并已下载Phaser 2.4.6,我正在尝试推出apk。我可以取出,但移相器没有加载 HTML 我没有收到启动Phaser的警报消息。我下载了VS 2015 Update 1,并在Visual Studio中安装了Apache Cordova支持所需的bits 使用新的项目模板,我得到了以下index.html: <!DOCTYPE html> <html> <head> <

我正在使用Visual Studio 2015开发html5游戏,并已下载Phaser 2.4.6,我正在尝试推出apk。我可以取出,但移相器没有加载

HTML


我没有收到启动Phaser的警报消息。

我下载了VS 2015 Update 1,并在Visual Studio中安装了Apache Cordova支持所需的bits

使用新的项目模板,我得到了以下index.html

<!DOCTYPE html>
<html>
    <head>
    <!--
        Customize the content security policy in the meta tag below as needed. Add 'unsafe-inline' to default-src to enable inline JavaScript.
        For details, see http://go.microsoft.com/fwlink/?LinkID=617521
    -->
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <title>SimplePhaserTest</title>
    </head>
    <body>
        <div class="app">
            <p id="deviceready" class="event">Connecting to Device</p>
        </div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="scripts/platformOverrides.js"></script>
        <script src="scripts/phaser.min.js"></script>
        <script type="text/javascript" src="scripts/index.js"></script>
    </body>
</html>
在本地运行此命令,然后在Android设备(Galaxy S4)上运行,会产生预期的警报消息

也许这只是一个问题,但我在你的代码中看到的一些问题都存在于你的游戏创作中:

var game = new Phaser.GAMES(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
这应该是
new Phaser.Game(
),并且您正在将它添加到现有的
div
,id为
Phaser example
,它在示例HTML中不存在

浏览器中的
新的Phaser.GAMES
代码也会让它窒息,所以我很困惑为什么你不会在那里看到问题


如果有帮助的话,我还有一个在a中的上述代码的工作示例(链接到特定提交,以防我将来扩展回购)。

以上两个文件是不同的吗?还是那是你的HTML文件?我也试图澄清你的问题,但我不确定你说“我可以取出,但Phaser没有加载…”是什么意思是的,上面我们有两个不同的文件1)Html 2)Javascript我加载了cordova,platformOverrides,Phaser,Html页面中的索引,使用index.js,我尝试使用上面的移相器代码启动移相器,但它没有启动,在启动的下面,我们有一个警报框,它没有出现在游戏中如果你在浏览器中运行它,它能工作吗?有控制台错误吗?我认为你试图将游戏附加到一个不存在的div上。在浏览器中,我们没有任何问题,它工作得很完美…但是在android中,我们面临这个问题…谢谢你的回答!!!但问题并没有解决,我复制了您的整个HTML代码和Index.js代码并将其放入了我的编码中……我从您的GIT帐户中获取了Phaser.js文件并将其放入我的文件中,我尝试运行应用程序,直到“设备就绪”设备中的文本…就是这样…然后我导入您的完整代码,并在Visual Studio中创建一个项目。如果运行Visual Studio没有结果,则我也会在Visual Studio中创建一个项目。如果您甚至在新项目中也没有看到警报,则没有浏览器弹出窗口听起来像是设备问题。您使用什么设备进行测试?如果您认为这可能是有益的,我可以更新项目以实际使用游戏实例;
警报调用可能有问题。我创建了一个新项目,只显示一些文本和Phaser徽标。我已经创建了一个自述文件,介绍了我为达到这一点所做的工作。它不使用警报,因此可能对您更有效。
<!DOCTYPE html>
<html>
    <head>
    <!--
        Customize the content security policy in the meta tag below as needed. Add 'unsafe-inline' to default-src to enable inline JavaScript.
        For details, see http://go.microsoft.com/fwlink/?LinkID=617521
    -->
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <title>SimplePhaserTest</title>
    </head>
    <body>
        <div class="app">
            <p id="deviceready" class="event">Connecting to Device</p>
        </div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="scripts/platformOverrides.js"></script>
        <script src="scripts/phaser.min.js"></script>
        <script type="text/javascript" src="scripts/index.js"></script>
    </body>
</html>
// For an introduction to the Blank template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkID=397704
// To debug code on page load in Ripple or on Android devices/emulators: launch your app, set breakpoints, 
// and then run "window.location.reload()" in the JavaScript Console.
(function () {
    "use strict";

    document.addEventListener('deviceready', onDeviceReady.bind(this), false);

    function onDeviceReady() {
        // Handle the Cordova pause and resume events
        document.addEventListener('pause', onPause.bind(this), false);
        document.addEventListener('resume', onResume.bind(this), false);

        // TODO: Cordova has been loaded. Perform any initialization that requires Cordova here.
        var element = document.getElementById("deviceready");
        element.innerHTML = 'Device Ready';
        element.className += ' ready';

        var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create })
        alert("Phaser Going Called ...");
    };

    function preload() {

    };

    function create() {

    };

    function onPause() {
        // TODO: This application has been suspended. Save application state here.
    };

    function onResume() {
        // TODO: This application has been reactivated. Restore application state here.
    };
})();
var game = new Phaser.GAMES(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });