Jump to content

Phaser using javascript with VS 2013 web express


rpiller
 Share

Recommended Posts

I'm trying to look for tutorials on using phaser with javascript (not typescript) in VS 2013 web express using it's IISExpress. I assume this is possible but everything I read is about apache and typescript.

 

I downloaded phaser, added the src to my MVC project under the Scripts folder. I include it in my index.cshtml page and it blew up talking about pixi. So I downloaded pixi and added the source under the Scripts folder as well. I included that in index.cshtml before Phaser and it ran without error.

 

Then after those 2 files are included I added one line to test:

 

var game = new Phaser.Game(500, 600, Phaser.AUTO, 'game_div');

 

 

I get an error saying "JavaScript runtime error: Object doesn't support this action" on that line above.

 

 

Is my setup OK? What am I missing here? I can't seem to find a tutorial for the setup I want to use which is the title of this post.

 

Link to comment
Share on other sites

I use VS 2013 Web and Phaser without any problems. Make a new ASP.Net Empty Web Application and add phaser.js or phaser.min.js to your source or js folder.

The only thing to look after is that when you want to use json files (for tilemaps etc.) you need to add this to the Web.config file:

 

<system.webServer>
      <staticContent>
        <mimeMap fileExtension=".json" mimeType="application/json" />
      </staticContent>
</system.webServer>
Link to comment
Share on other sites

I downloaded phaser, added the src to my MVC project under the Scripts folder.

 

I think this is your problem. The src folder is only for building the PhaserJS project from scratch. To use phaser in a project you need to add phaser.js (or phaser.min.js) from the build folder.
Link to comment
Share on other sites

In a massive JavaScript project, you don't want to have a 100,000 line text file open at all times. You also would not be able to do Source Control as easily if every change was basically a merge. Another aspect would be not being able to mix JavaScript, CoffeeScript, and TypeScript (Don't know if this is ever really done though). Updating a library dependency would mean copy-pasting the parts you need into your file or forcing the user to include that library as well.

Technically, you could write your game in a development environment where you have included all the src, and it would be the same as using Phaser.js or phaser.min.js. However, that would be awful for the user.

build/phaser.js and phaser.min.js are the JavaScript equivalent of a C++ dll file. Lots of code merged together and placed in one file so that it's easier to include, and is also sufficiently black-boxed (especially in the case of .min.js) so that you rely on the documentation and aren't tempted to modify the source of Phaser (and if you do, you're more likely to pull down the repo of Phaser and share your fixes/improvements)

So yeah, with all JavaScript libraries, you want to get the main files under build, like phaser.js and phaser.min.js. When you are in development mode, it's best to use the non-minified version as you can debug through it and get better errors. When you go to deploy, switch to the min versions.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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