Jump to content

Problems with requirejs and new v2.3.0


swissnetizen
 Share

Recommended Posts

I've tried the new version of Phaser, but I've noticed it doesn't like requirejs. It's giving the following error:

ReferenceError: p2 is not defined phaser.js:77528:0

I've downloaded the build from the website and tested loading it via <script> with no problems.

Source:

index.html:

<html>	<head>		<meta charset="utf-8" />		<script type="application/javascript" src="require.min.js" data-main="game.js"></script>	</head></html>

game.js: (I've also had a function inside; I've also tried starting the game and putting the new version in an already working game)

require(["phaser"])

+ phaser.js and require.min.js

 

I've packaged the example in gist form (for the lazy people like me) https://gist.github.com/samarthwiz/5002c3344490e0650d2e .

 

UPDATE: I've attached a zip too, for the event when github goes down.

phasertest.zip

Link to comment
Share on other sites

on main.js for requirejs

 

 (function () {       'use strict';    requirejs.config({        baseUrl: "src/",                paths: {            phaser:   'libs/phaser/phaser.min',        },        shim: {            'phaser': {                exports: 'Phaser'            }        }    });        require(['phaser', 'game'], function (Phaser, Game) {        var game = new Game();        game.start();    });    }());
Link to comment
Share on other sites

I'm looking into this and it's to do with a change in the way p2.js (v0.61) does it's build process. Phaser 2.2.2 works because it's using an older version of p2 (v0.60). The change is related to p2 removing the insertGlobals option in the gruntfile. I've added a pull request to both repos with a fix. If you build from my phaser dev branch, all is well :)

https://github.com/dgoemans/phaser

Link to comment
Share on other sites

Hello dgoemans, I'm trying to use your dev branch of phaser 2.3 with requirejs. Everything seems to work properly in development but when I'm trying to build my project, it seems phaser.js not include in my main.js file. Is there a solution?

Link to comment
Share on other sites

  • 1 month later...
  • 3 months later...

Sorry guys, i didn't get an email reply from this. I believe Richard has integrated this into Phaser 2.4.0, so everything should be there. I'm not sure about doing the compilation, it's possible i didn't test that. I only had this as a test game, a project i did for teaching people Html5 dev:

https://github.com/dgoemans/awesomegame/

 

Not sure if it helps, and sorry again for the super late reply!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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