繁体   English   中英

html5 + 移相器问题

[英]html5 + phaser issues

我正在尝试使用 xdk 和 Phaser 库开发游戏。 我有 2 个预制件,其中有错误。

这是其中之一的代码和游戏的 html:

 var BasicGame = BasicGame || {}; BasicGame.balls = function(game ,x,y ) { Phaser.Sprite.call(this,game,x,y); this.game=game; this.game.physics.Arcade.enable(this) ; this.anchor.setTo(0.5) ; this.body.velocity = this.game.RandomDataGenerator ; }; BasicGame.balls.prototype = Object.create(Phaser.Sprite.prototype); BasicGame.balls.prototype.constructor = BasicGame.balls ;
 <html> <head> <title>Phaser Full Screen Mobile Example</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="chrome=1, IE=9"> <meta name="format-detection" content="telephone=no"> <meta name="HandheldFriendly" content="true" /> <meta name="robots" content="noindex,nofollow" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" /> <meta name="apple-mobile-web-app-title" content="Phaser App"> <meta name="viewport" content="initial-scale=1 maximum-scale=1 user-scalable=0 minimal-ui" /> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> <!-- non-retina iPhone pre iOS 7 --> <link rel="apple-touch-icon" sizes="57x57" href="icons/app_icon_57x57.png"> <link rel="apple-touch-icon" sizes="60x60" href="icons/app_icon_60x60.png"> <!-- non-retina iPad pre iOS 7 --> <link rel="apple-touch-icon" sizes="72x72" href="icons/app_icon_72x72.png"> <!-- non-retina iPad iOS 7 --> <link rel="apple-touch-icon" sizes="76x76" href="icons/app_icon_76x76.png"> <!-- retina iPhone pre iOS 7 --> <link rel="apple-touch-icon" sizes="114x114" href="icons/app_icon_114x114.png"> <!-- retina iPhone iOS 7 --> <link rel="apple-touch-icon" sizes="120x120" href="icons/app_icon_120x120.png"> <!-- retina iPad pre iOS 7 --> <link rel="apple-touch-icon" sizes="144x144" href="icons/app_icon_144x144.png"> <!-- retina iPad iOS 7 --> <link rel="apple-touch-icon" sizes="152x152" href="icons/app_icon_152x152.png"> <link rel="apple-touch-icon" sizes="256x256" href="icons/app_icon_256x256.png"> <link rel="apple-touch-icon" sizes="512x512" href="icons/app_icon_512x512.png"> <link rel="apple-touch-icon" sizes="1024x1024" href="icons/app_icon_1024x1024.png"> <link rel="stylesheet" href="css/stylesheet.css" type="text/css" charset="utf-8" /> <!-- Load Phaser engine --> <script src="lib/phaser.min.js"></script> <!-- Load game source files --> <script src="src/Game.js"></script> <!-- Load game entrance --> <script src="src/app.js"></script> <!-- Load and initialize Cordova --> <script src="cordova.js"></script> <script src="src/cordova-init.js"></script> <script src="src/prefabs/balls.js"></script> <script src="src/prefabs/homes.js"></script> </head> <body> <!-- Main canvas for rendering game stage --> <div id="game"></div> <div id="balls"></div> <div id="homes"></div> </body> </html>

所以问题是我在未定义“Phaser”的预制件中出现错误。

在此处输入图片说明

JSHint 将报告错误,因为它只查看单个文件,无法知道是否在其他地方定义了某些全局变量,如Phaser的情况。 如果您查看www/src/app.js您会看到如下一行:

/* globals Phaser:false, BasicGame: false */

这是一个JSHint指令,它告诉它不要将PhaserBasicGame标记为未定义,即假设它们是在别处定义的全局变量。

在任何情况下,它都不应该影响您的应用程序的运行。 您应该会在调试器和正在运行的代码中看到它的定义。

暂无
暂无

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

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