{"id":662,"date":"2015-08-06T09:04:29","date_gmt":"2015-08-06T09:04:29","guid":{"rendered":"http:\/\/www.doolwind.com\/blog\/?page_id=662"},"modified":"2016-04-11T09:21:08","modified_gmt":"2016-04-11T09:21:08","slug":"phaser-with-visual-studio-2015-and-typescript","status":"publish","type":"page","link":"https:\/\/www.doolwind.com\/blog\/phaser-with-visual-studio-2015-and-typescript\/","title":{"rendered":"Phaser with Visual Studio 2015 and TypeScript"},"content":{"rendered":"<p><a href=\"http:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/run.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-medium wp-image-667\" src=\"http:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/run-300x216.png\" alt=\"run\" width=\"300\" height=\"216\" srcset=\"https:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/run-300x216.png 300w, https:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/run.png 514w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>I&#8217;ve been playing with\u00a0<a href=\"http:\/\/phaser.io\/\">Phaser<\/a>\u00a0recently\u00a0and I&#8217;m really liking it so far. I plan to use <a href=\"http:\/\/www.typescriptlang.org\/\">TypeScript<\/a>\u00a0for the language as it has a bunch of advantages over straight javascript. I found the Phaser tutorial was a little out of date so figured I would put together\u00a0a quick tutorial to help others get started with Phaser development in Visual Studio 2015 Community Edition using TypeScript.\u00a0The new Community Edition of Visual Studio is free for commercial use which means anyone running Windows can start making WebGL games in Phaser with a powerful IDE at no cost. Below are the instructions, if you find any problems please let me know.<\/p>\n<ol>\n<li>Download VS 2015 Community &#8211; <a href=\"http:\/\/visualstudio.com\/en-us\/products\/visual-studio-community-vs.aspx\">http:\/\/visualstudio.com\/en-us\/products\/visual-studio-community-vs.aspx<\/a><\/li>\n<li>Download Phaser source &#8211; <a href=\"http:\/\/phaser.io\/download\/stable\">http:\/\/phaser.io\/download\/stable<br \/>\n<\/a>\u00a0 &#8211; Use whichever form you prefer (clone in github or download full source zip)<\/li>\n<li>Create a new project &#8211;\u00a0Select Templates -&gt; Other Languages -&gt; TypeScript -&gt; \u201cHTML Application with TypeScript\u201d<br \/>\n<a href=\"http:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser1.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-663 alignnone\" src=\"http:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser1-300x213.png\" alt=\"Phaser1\" width=\"300\" height=\"213\" srcset=\"https:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser1-300x213.png 300w, https:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser1-1024x728.png 1024w, https:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser1.png 1049w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>For the next two steps, find the phaser src directory you downloaded to in Step #2<\/li>\n<li>Copy &lt;phaser src directory&gt;\\build\\phaser.js into the project (in\u00a0the root)<br \/>\n<a href=\"http:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser2.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-664 alignnone\" src=\"http:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser2-300x142.png\" alt=\"Phaser2\" width=\"300\" height=\"142\" srcset=\"https:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser2-300x142.png 300w, https:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser2.png 790w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Copy the files below into your project (in the root)\n<ol>\n<li>&lt;phaser src directory&gt;\\typescript\\phaser.d.ts<\/li>\n<li>&lt;phaser src directory&gt;\\typescript\\pixi.d.ts<\/li>\n<li>&lt;phaser src directory&gt;\\typescript\\p2.d.ts<br \/>\n<a href=\"http:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser3.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-665 alignnone\" src=\"http:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser3-300x142.png\" alt=\"Phaser3\" width=\"300\" height=\"142\" srcset=\"https:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser3-300x142.png 300w, https:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser3.png 790w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<\/ol>\n<\/li>\n<li>Add <a href=\"http:\/\/phaser.io\/images\/download\/run.png\">http:\/\/phaser.io\/images\/download\/run.png<\/a> to the project in the root<\/li>\n<li>Your solution should look like this:<br \/>\n<a href=\"http:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser4.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-666 alignnone\" src=\"http:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser4-300x195.png\" alt=\"Phaser4\" width=\"300\" height=\"195\" srcset=\"https:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser4-300x195.png 300w, https:\/\/www.doolwind.com\/blog\/wp-content\/uploads\/2015\/08\/Phaser4.png 351w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Edit index.html and include\u00a0the phaser.js script:\n<pre class=\"lang:js decode:true\">&lt;script src=\"phaser.js\"&gt;&lt;\/script&gt;<\/pre>\n<\/li>\n<li>Edit app.ts, remove all the existing code and replace it with:\n<pre class=\"lang:default decode:true\">class PhaserDemo {\r\n\r\n    game: Phaser.Game;\r\n\r\n    constructor() {\r\n        this.game = new Phaser.Game(800, 600, Phaser.AUTO, 'content', { preload: this.preload, create: this.create });\r\n    }\r\n\r\n    preload() {\r\n        this.game.load.image('phaser_run', 'run.png');\r\n    }\r\n\r\n    create() {\r\n        this.game.add.sprite(0, 0, 'phaser_run');\r\n    }\r\n}\r\n\r\nwindow.onload = () =&gt; {\r\n    var game = new PhaserDemo();\r\n};<\/pre>\n<\/li>\n<li>Press F5 to run<br \/>\n&#8211; The page will load up in <a href=\"http:\/\/localhost:%3csomeport\">http:\/\/localhost:&lt;someport<\/a>&gt;<br \/>\n&#8211; You&#8217;re now ready for phaser game development<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been playing with\u00a0Phaser\u00a0recently\u00a0and I&#8217;m really liking it so far. I plan to use TypeScript\u00a0for the language as it has a bunch of advantages over straight javascript. I found the Phaser tutorial was a little out of date so figured I would put together\u00a0a quick tutorial to help others get started with Phaser development in <a class=\"more-link\" href=\"https:\/\/www.doolwind.com\/blog\/phaser-with-visual-studio-2015-and-typescript\/\">Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"class_list":["post-662","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/PgEc5-aG","_links":{"self":[{"href":"https:\/\/www.doolwind.com\/blog\/wp-json\/wp\/v2\/pages\/662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.doolwind.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.doolwind.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.doolwind.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.doolwind.com\/blog\/wp-json\/wp\/v2\/comments?post=662"}],"version-history":[{"count":0,"href":"https:\/\/www.doolwind.com\/blog\/wp-json\/wp\/v2\/pages\/662\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.doolwind.com\/blog\/wp-json\/wp\/v2\/media?parent=662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}