Jump to content

Problems with requirejs and new v2.3.0


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.



<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)


+ 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.


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 :)


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:



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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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