2016-04-02 7 views
1

Ich versuche, ein Spiel mit XDK mit Phaser-Bibliothek zu entwickeln. Ich habe 2 Prefabs und ich habe Fehler in ihnen. Hierhtml5 + Phaser Probleme

ist der Code von einem von ihnen und die html des Spiels:

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>

Also das Problem ist, ich habe einen Fehler in dem prefabs wo ‚Phaser‘ ist nicht definiert .

enter image description here

Antwort

1

JSHint meldet einen Fehler, weil es bei einer einzigen Datei nur auf der Suche ist und nicht wissen können, wenn einige Globals an anderer Stelle definiert wurden, wie es der Fall mit Phaser. Wenn Sie in www/src/app.js aussehen werden Sie eine Zeile wie diese:

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

Dies ist eine JSHint-Direktive, die es nicht zu Flagge erzählt Phaser oder BasicGame als nicht definiert, das heißt annehmen, sie sind Globals an anderer Stelle definiert.

In jedem Fall sollte es nicht den Lauf Ihrer App beeinflussen. Sie sollten es im Debugger und in Ihrem laufenden Code definiert sehen.