swissnetizen Posted March 29, 2015 Share Posted March 29, 2015 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:0I'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 theoutlander 1 Link to comment Share on other sites More sharing options...
blue_mc Posted April 2, 2015 Share Posted April 2, 2015 I've encountered the same problem. Anybody have a fix for this yet? Link to comment Share on other sites More sharing options...
mxmlb Posted April 2, 2015 Share Posted April 2, 2015 Where did you defined the "phaser" const you use in require ?I use phaser 2.3 with requirejs without problem. Link to comment Share on other sites More sharing options...
blue_mc Posted April 2, 2015 Share Posted April 2, 2015 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 More sharing options...
swissnetizen Posted April 4, 2015 Author Share Posted April 4, 2015 I did it without the shim; it works in 2.2.2. Link to comment Share on other sites More sharing options...
dgoemans Posted April 6, 2015 Share Posted April 6, 2015 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 More sharing options...
poloop Posted April 7, 2015 Share Posted April 7, 2015 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 More sharing options...
theoutlander Posted May 9, 2015 Share Posted May 9, 2015 Faced the same problem. As stated in the threads here, it works with 2.2. However, I had to define a shim for it to work. Link to comment Share on other sites More sharing options...
dgoemans Posted August 17, 2015 Share Posted August 17, 2015 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 More sharing options...
georgejfrick Posted August 17, 2015 Share Posted August 17, 2015 We've started letting Phaser be a global as of 2.4 and bring it in with a separate include. So we have.. <script src="engine/phaser.min.js"></script> <script src="engine/engine.min.js"></script> Link to comment Share on other sites More sharing options...
Recommended Posts