Jump to content

'phaser' not defined


mohammed alsaqqal
 Share

Recommended Posts

im trying to make a prefabs and this is the code of .js file  
 

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 ;


and this is the html code 

 

<!DOCTYPE HTML>
<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>


if you notice in the pic ... i have an error // 'phaser' is not defined 
please help ! 

Untitled.jpg

Link to comment
Share on other sites

That is just a linter issue, unless you tell the linter that Phaser is a global it can expect to be present then there is nothing in the code that gives it any hints.

Looks like your code will actually run fine, does it?

A lot of people seem to get hung up on process where linters are concerned, they are there simply to give you a hint (jshint), not to rule your life. There are lots of places where linting in JS is particularly error prone and awkward, this is an example of one of them.

Link to comment
Share on other sites

On 3/30/2016 at 9:21 AM, mattstyles said:

That is just a linter issue, unless you tell the linter that Phaser is a global it can expect to be present then there is nothing in the code that gives it any hints.

Looks like your code will actually run fine, does it?

A lot of people seem to get hung up on process where linters are concerned, they are there simply to give you a hint (jshint), not to rule your life. There are lots of places where linting in JS is particularly error prone and awkward, this is an example of one of them.

thank you >>> 

the problem was in the spelling .. its Phaser not phaser :P

but i have another problem .. the update function of prefab not work !! 

BasicGame.balls.prototype.update 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...