{"id":6937,"date":"2016-06-17T08:06:34","date_gmt":"2016-06-17T06:06:34","guid":{"rendered":"https:\/\/anexia.com\/stagingblog\/?p=6937"},"modified":"2022-04-22T08:36:16","modified_gmt":"2022-04-22T06:36:16","slug":"phaser-tutorial-html5-racing-game","status":"publish","type":"post","link":"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/","title":{"rendered":"Phaser Tutorial: HTML5 Racing Game"},"content":{"rendered":"<p><a href=\"https:\/\/phaser.io\" target=\"_blank\" rel=\"noopener\">Phaser<\/a> offers beginners in game development the opportunity, to create HTML5 based games. In this tutorial, I want to explain the entry in Phaser with the help of a racing game, we will create. <!--more-->The whole source code is available at the end of this post. If you want to have a look at what the finished game looks like in my case, try the <a href=\"https:\/\/apps.facebook.com\/anexia_schlepperacer\/\">Anexia Schlepperacer<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>1. Introduction<\/h2>\n<p>To integrate Phaser into your own project, you can download it from the <a href=\"https:\/\/phaser.io\/download\">official Site<\/a>, or use a <a href=\"https:\/\/cdnjs.com\/libraries\/phaser\">CDN<\/a>.<\/p>\n<p>In my case, I used a CDN, so i just had to use the following script tag to integrate Phaser in my project:<\/p>\n<pre class=\"lang:default decode:true\">&lt;script type=\"text\/javascript\" src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/phaser\/2.4.8\/phaser.min.js\"&gt;&lt;\/script&gt;<\/pre>\n<p>Warning: This script tag will integrate Phaser 2.4.8 in your project, please check if there is a newer version available first!<\/p>\n<p>A Phaser game consists basically of 3 functions: preload, create &amp; update.<\/p>\n<p>The preload function ist the entry point of the game and will be called first. It is (as the name says) here where to load files like graphics, bounding boxes, fonts, scrips, sounds and so on. A typical line of code in the preload-function will look like this:<\/p>\n<pre class=\"lang:default decode:true\">game.load.spritesheet('map','assets\/map.jpg');\r\n<\/pre>\n<p>The create function will be called after the preload-function. In this function, you have the opportunity to run code, that will only be called once, when all files are already available. There is already some action going on here: Most graphics get added to the game, bounding boxes are mapped, particle effects and animations are initialized and configured and the physics, text or keys, to get user inputs, are loaded and configured here.<\/p>\n<p>In the update function the real action is going on. This function will be called everytime a frame gets rendered. Here will user inputs &amp; collisions be handled, sprites moved,etc.<\/p>\n<p>To initialize a Phaser game, you must only include one line of JavaScript into your project:<\/p>\n<pre class=\"lang:default decode:true\">var game = new Phaser.Game(1280, 839, Phaser.AUTO, 'main_game', { preload: preload, create: create, update: update });<\/pre>\n<p>The first 2 parameters set the height and width of the game in pixel. The size of the game can also be changed later, to make the game responsive for example.<\/p>\n<p>With the 3. parameter, you can choose how the game should be rendered (WebGL or Canvas). Normally, you set this to Phaser.AUTO, this will try to use WebGL, if this fails, it will use Canvas.<\/p>\n<p>The 4. parameter is the ID of the Div, in which the HTML element of the game will be placed. You can leave this empty, if you don&#8217;t need any HTML properties.<\/p>\n<p>In the last parameter we will hand over Phaser the preload, create &amp; update function. (Leave this 3 functions empty for the moment)<\/p>\n<p>&nbsp;<\/p>\n<h2>2.  Initialize Car &amp; Map<\/h2>\n<p>For our racing game we first need a map, on which the car can drive on, and a car. From this moment on, you will need a webserver, because the browser doesn&#8217;t have the permission to access local files on your PC. You can use XAMPP or (depending on your system and taste) a similar service.<\/p>\n<p>Here is the map I was using with our office building:<\/p>\n<p><a href=\"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/map.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1297\" src=\"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/map.jpg\" alt=\"map\" width=\"600\" height=\"393\" srcset=\"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/map.jpg 1280w, https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/map-325x213.jpg 325w, https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/map-300x197.jpg 300w, https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/map-1024x671.jpg 1024w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>And here is the car modeled after our Anexia van:<\/p>\n<p><a href=\"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/car.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1298\" src=\"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/car.png\" alt=\"car\" width=\"62\" height=\"100\" \/><\/a><\/p>\n<p>To add graphics into our game, we first have to load them in our preload function:<\/p>\n<pre class=\"lang:default decode:true\">function preload() {\r\n    game.load.spritesheet('map','assets\/map.jpg');\r\n    game.load.spritesheet('car','assets\/car.png');\r\n}<\/pre>\n<p>You can choose any string for the first parameter, you need this name later to add your image to the game.<\/p>\n<p>The second parameter is the path to the file.<\/p>\n<p>Now, the image is loaded, but we still have to add it to the game. We do this in our create function:<\/p>\n<pre class=\"lang:default decode:true\">function create() {\r\n    \/*Adding Map*\/\r\n    var map = game.add.sprite(0,0,'map');\r\n    \/*Adding car*\/\r\n    car = game.add.sprite(570,100,'car');\r\n}<\/pre>\n<p>The first 2 parameters here are the coordinates (X,Y), where the image will be placed. The 3. one is the name of the image, which we were chosing in our preload function.<\/p>\n<p>If you run the game now, you should see the car and the map as background.<\/p>\n<p>Now, let&#8217;s move to the steering of the car!<\/p>\n<p>&nbsp;<\/p>\n<h2>3. Car Steering<\/h2>\n<p>To know in which direction the car should drive, we have to get the user input from the keyboard first. To do so, we have to tell Phaser, which keys we need data from.<\/p>\n<p>&nbsp;<\/p>\n<p>Let&#8217;s make a global variable called &#8222;cursors&#8220; first:<\/p>\n<pre class=\"lang:default decode:true\">var cursors;<\/pre>\n<p>In the create function we can tell Phaser, that we will need all &#8222;cursor-keys&#8220;, (this are all arrow keys) with the following line of code:<\/p>\n<pre class=\"lang:default decode:true\">cursors = game.input.keyboard.createCursorKeys();<\/pre>\n<p>We can now read, if the user is pressing the &#8222;arrow-up&#8220; key with:<\/p>\n<pre class=\"lang:default decode:true\">if (cursors.up.isDown) {\r\n}<\/pre>\n<p>To set a velocity to our car, we have to enable a physics engine first. Phaser is coming with some physics engines on its own, mostly you will find the &#8222;arcade&#8220; engine on the internet. We can&#8217;t use this one, because it doesn&#8217;t support complex bounding boxes. The P2 engine does so, which is why I decided to use it. To start the P2 engine, we have to add the following line in our create function:<\/p>\n<pre class=\"lang:default decode:true\">game.physics.startSystem(Phaser.Physics.P2JS);<\/pre>\n<p>Now the physics engine is started, but we need to enable it for our car:<\/p>\n<pre class=\"lang:default decode:true\">game.physics.p2.enable(car,false);<\/pre>\n<p>Lets&#8217;s turn the car 90 degrees, so it&#8217;s aligned with the road:<\/p>\n<pre class=\"lang:default decode:true\">car.body.angle = 90;<\/pre>\n<p>Now it&#8217;s finally time to set a velocity to our car. Create a global variable for this purpose which is &#8222;0&#8220; at the beginning:<\/p>\n<pre class=\"lang:default decode:true\">var velocity = 0;<\/pre>\n<p>Now to the code, that moves the car:<\/p>\n<pre class=\"lang:default decode:true\">if (cursors.up.isDown &amp;&amp; velocity &lt;= 400)\r\n        velocity+=7;\r\nelse {\r\n    if (velocity &gt;= 7)\r\n        velocity -= 7;\r\n}\r\n                        \r\ncar.body.velocity.x = velocity * Math.cos((car.angle-90)*0.01745);\r\ncar.body.velocity.y = velocity * Math.sin((car.angle-90)*0.01745);\r\n                \r\nif (cursors.left.isDown)\r\n    car.body.angularVelocity = -5*(velocity\/1000);\r\nelse if (cursors.right.isDown)\r\n    car.body.angularVelocity = 5*(velocity\/1000);\r\nelse\r\n    car.body.angularVelocity = 0;<\/pre>\n<p>It is actually quite simple:<\/p>\n<pre class=\"lang:default decode:true\">if (cursors.up.isDown &amp;&amp; velocity &lt;= 400)\r\n        velocity+=7;\r\nelse {\r\n    if (velocity &gt;= 7)\r\n        velocity -= 7;\r\n}<\/pre>\n<p>If the arrow-up key is pressed and the velocity is smaller than 400 pixels\/second (this is the maximum velocity), it will be increased. If the arrow-up key is not pressed, the car will slow down.<\/p>\n<p>After this, we will calculate the velocity for the X and Y axis:<\/p>\n<pre class=\"lang:default decode:true\">car.body.velocity.x = velocity * Math.cos((car.angle-90)*0.01745);\r\ncar.body.velocity.y = velocity * Math.sin((car.angle-90)*0.01745);<\/pre>\n<p>Af first, we will substract 90 degrees from the angle of the car. (we rotated the car first by 90 degrees, if we wouldn&#8217;t do this the front of the car would be on the right side for the physics engine). Then we convert the angle to radiant (*0.01745), take the cosinus function of it, multiply it with the general velocity and we get the velocity of the car on the X-axis.<\/p>\n<p>We have to do the same for the Y-axis, but with the sinus function instead of the cosinus function.<\/p>\n<p>Then we will set the rotation of the car:<\/p>\n<pre class=\"lang:default decode:true\">if (cursors.left.isDown)\r\n    car.body.angularVelocity = -5*(velocity\/1000);\r\nelse if (cursors.right.isDown)\r\n    car.body.angularVelocity = 5*(velocity\/1000);\r\nelse\r\n    car.body.angularVelocity = 0;<\/pre>\n<p>The velocity of the rotation depends on the velocity of the car. If the car is slow, it will also steer slow.<\/p>\n<p>Because the code got a bit complex right now, here ist the whole thing:<\/p>\n<pre class=\"lang:default decode:true\">&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;title&gt;Tutorial&lt;\/title&gt;\r\n        &lt;script type=\"text\/javascript\" src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/phaser\/2.4.8\/phaser.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        &lt;script&gt;\r\n            \r\n            var game = new Phaser.Game(1280, 839, Phaser.AUTO, 'main_game', { preload: preload, create: create, update: update });\r\n            \r\n            function preload() {\r\n                game.load.spritesheet('map','assets\/map.jpg');\r\n                game.load.spritesheet('car','assets\/car.png');\r\n            }\r\n            \r\n            var cursors;\r\n            var velocity = 0;\r\n            function create() {\r\n                \/*Enable Phyics Engine*\/\r\n                game.physics.startSystem(Phaser.Physics.P2JS);\r\n                \/*Adding Map*\/\r\n                var map = game.add.sprite(0,0,'map');\r\n                \/*Adding car*\/\r\n                car = game.add.sprite(570,100,'car');\r\n                game.physics.p2.enable(car);\r\n                car.body.angle = 90;\r\n                \r\n                cursors = game.input.keyboard.createCursorKeys();\r\n            }\r\n            \r\n            function update()\r\n            {\r\n                \/*Update Velocity*\/\r\n                if (cursors.up.isDown &amp;&amp; velocity &lt;= 400) {\r\n                        velocity+=7;\r\n                }\r\n                else {\r\n                    if (velocity &gt;= 7)\r\n                        velocity -= 7;\r\n                }\r\n                        \r\n                \/*Set X and Y Speed of Velocity*\/\r\n                car.body.velocity.x = velocity * Math.cos((car.angle-90)*0.01745);\r\n                car.body.velocity.y = velocity * Math.sin((car.angle-90)*0.01745);\r\n                \r\n                \/*Rotation of Car*\/\r\n                if (cursors.left.isDown)\r\n                    car.body.angularVelocity = -5*(velocity\/1000);\r\n                else if (cursors.right.isDown)\r\n                    car.body.angularVelocity = 5*(velocity\/1000);\r\n                else\r\n                    car.body.angularVelocity = 0;\r\n            }\r\n        &lt;\/script&gt;\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>&nbsp;<\/p>\n<h2>4. Collision Detection:<\/h2>\n<p>Next we want to focus on the collision detection. To create complex bounding boxes, I&#8217;ve used the <a href=\"https:\/\/www.codeandweb.com\/physicseditor\">Physics Editor<\/a>. I don&#8217;t want to explain the usage of this program here, there can already be found many informations about this. The physics editor will generate a JSON File, which will contain all bounding boxes. We load this file in the preload function:<\/p>\n<pre class=\"lang:default decode:true\">game.load.physics(\"collision\",\"assets\/collision.json\");<\/pre>\n<p>I will explain the collision with the building in the middle of the map here, it&#8217;s rougly the same for other objects.<\/p>\n<p>Because the building is 3-dimensional, I wanted that the car to be able to drive &#8222;under&#8220; the building. That should look like this:<\/p>\n<p><a href=\"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/carUnderBuilding.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1304\" src=\"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/carUnderBuilding.png\" alt=\"carUnderBuilding\" width=\"600\" height=\"500\" srcset=\"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/carUnderBuilding.png 440w, https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/carUnderBuilding-325x271.png 325w, https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/carUnderBuilding-300x250.png 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>To do so, you have to cut the image and save it as a PNG File with a transparent background. We will add the building at the end of the create-function, like we did with all the other images. To make sure, the image of the car lies underneath the image of the building, we have to add the image of the building after the car.<\/p>\n<p>Then we have to create collision groups for the objects:<\/p>\n<pre class=\"lang:default decode:true\">var carCollisionGroup = game.physics.p2.createCollisionGroup();\r\nvar buildingCollisionGroup = game.physics.p2.createCollisionGroup();\r\ngame.physics.p2.updateBoundsCollisionGroup();<\/pre>\n<p>Now we have to add the building to the game (after we loaded the image in the preload function):<\/p>\n<pre class=\"lang:default decode:true\">var building = game.add.sprite(640,420,'building');\r\n<\/pre>\n<p>Then we enable the physics engine for the building:<\/p>\n<pre class=\"lang:default decode:true\">game.physics.p2.enable(building);\r\n<\/pre>\n<p>We&#8217;re configuring, that the building is an immovable object:<\/p>\n<pre class=\"lang:default decode:true\">building.body.kinematic = true;\r\n<\/pre>\n<p>Then we&#8217;re deleting the bounding box, that is laying on the building on default:<\/p>\n<pre class=\"lang:default decode:true\">building.body.clearShapes();\r\n<\/pre>\n<p>And we&#8217;re loading our own bounding box, which we&#8217;ve exported from physics editor earlier:<\/p>\n<pre class=\"lang:default decode:true\">building.body.loadPolygon('collision','building');<\/pre>\n<p>Now we map the collision groups to the car and the building:<\/p>\n<pre class=\"lang:default decode:true\">car.body.setCollisionGroup(carCollisionGroup);\r\nbuilding.body.setCollisionGroup(buildingCollisionGroup);<\/pre>\n<p>And last, we&#8217;re configuring, that the car and the building will collide:<\/p>\n<pre class=\"lang:default decode:true\">car.body.collides([carCollisionGroup,buildingCollisionGroup]);\r\nbuilding.body.collides([buildingCollisionGroup,carCollisionGroup]);<\/pre>\n<p>Hint: If you have problems with the bounding box, try the following:<\/p>\n<pre class=\"lang:default decode:true\">game.physics.p2.enable(building,true);<\/pre>\n<p>If you set the second parameter to be &#8222;true&#8220;, the bounding box of the building will be displayed. This helps with debugging if it is mapped wrong. \ud83d\ude09<\/p>\n<p>If you have done everything right, you now have the basic game to create your own HTML5 Phaser racing game!<\/p>\n<p>If not, you can download the whole game here: <a href=\"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/HTML5-Racing-Game1.zip\">HTML5 Racing Game<\/a><\/p>\n<p>If you have any further questions, write me an <a href=\"mailto:dwuggenig@anexia-it.com\">E-Mail<\/a>.<\/p>\n<p>You want to know what happened to the game in my case?<\/p>\n<p>Visit out <a href=\"https:\/\/apps.facebook.com\/anexia_schlepperacer\/\">Anexia Schlepperacer<\/a> on Facebook and have a look at it, you can also win an iPad Air 2, if you have the best time until 1. Juli 2016<\/p>\n<p>You want to create your own social media application but don&#8217;t know how?<\/p>\n<p>Anexia would love to create it for you, visit us <a href=\"https:\/\/anexia.com\/en\/software-development\/web-development\/social-media-applications\/\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Phaser offers beginners in game development the opportunity, to create HTML5 based games. In this tutorial, I want to explain the entry in Phaser with the help of a racing game.<\/p>\n","protected":false},"author":20,"featured_media":1447,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1135],"tags":[1883,1893,1885,1329,1887,1889,1891],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Phaser Tutorial: HTML5 Racing Game - ANEXIA Blog<\/title>\n<meta name=\"description\" content=\"Phaser offers beginners in game development the opportunity, to create HTML5 based games. In this tutorial, I want to explain the entry in Phaser with the help of a racing game.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Phaser Tutorial: HTML5 Racing Game - ANEXIA Blog\" \/>\n<meta property=\"og:description\" content=\"Phaser offers beginners in game development the opportunity, to create HTML5 based games. In this tutorial, I want to explain the entry in Phaser with the help of a racing game.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/\" \/>\n<meta property=\"og:site_name\" content=\"ANEXIA Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/anexiagmbh\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-06-17T06:06:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-22T06:36:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/Phaser-Titelbild.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1600\" \/>\n\t<meta property=\"og:image:height\" content=\"1066\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Daniel Wuggenig\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@_ANEXIA\" \/>\n<meta name=\"twitter:site\" content=\"@_ANEXIA\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Daniel Wuggenig\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"10\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/\",\"url\":\"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/\",\"name\":\"Phaser Tutorial: HTML5 Racing Game - ANEXIA Blog\",\"isPartOf\":{\"@id\":\"https:\/\/anexia.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/Phaser-Titelbild.jpg\",\"datePublished\":\"2016-06-17T06:06:34+00:00\",\"dateModified\":\"2022-04-22T06:36:16+00:00\",\"author\":{\"@id\":\"https:\/\/anexia.com\/blog\/#\/schema\/person\/6f0e77d2bc1f23f7e353f1e6e2f2acfd\"},\"description\":\"Phaser offers beginners in game development the opportunity, to create HTML5 based games. In this tutorial, I want to explain the entry in Phaser with the help of a racing game.\",\"breadcrumb\":{\"@id\":\"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/#primaryimage\",\"url\":\"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/Phaser-Titelbild.jpg\",\"contentUrl\":\"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/Phaser-Titelbild.jpg\",\"width\":1600,\"height\":1066,\"caption\":\"Phaser-Titelbild\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/anexia.com\/blog\/de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Phaser Tutorial: HTML5 Racing Game\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/anexia.com\/blog\/#website\",\"url\":\"https:\/\/anexia.com\/blog\/\",\"name\":\"ANEXIA Blog\",\"description\":\"[:de] ANEXIA Blog - Technischen Themen, Anexia News und Insights [:]\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/anexia.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/anexia.com\/blog\/#\/schema\/person\/6f0e77d2bc1f23f7e353f1e6e2f2acfd\",\"name\":\"Daniel Wuggenig\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/anexia.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c60eb93ac799bb6eaada1b39ebd15b85?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c60eb93ac799bb6eaada1b39ebd15b85?s=96&d=mm&r=g\",\"caption\":\"Daniel Wuggenig\"},\"url\":\"https:\/\/anexia.com\/blog\/author\/dwuggenig\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Phaser Tutorial: HTML5 Racing Game - ANEXIA Blog","description":"Phaser offers beginners in game development the opportunity, to create HTML5 based games. In this tutorial, I want to explain the entry in Phaser with the help of a racing game.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/","og_locale":"de_DE","og_type":"article","og_title":"Phaser Tutorial: HTML5 Racing Game - ANEXIA Blog","og_description":"Phaser offers beginners in game development the opportunity, to create HTML5 based games. In this tutorial, I want to explain the entry in Phaser with the help of a racing game.","og_url":"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/","og_site_name":"ANEXIA Blog","article_publisher":"https:\/\/www.facebook.com\/anexiagmbh\/","article_published_time":"2016-06-17T06:06:34+00:00","article_modified_time":"2022-04-22T06:36:16+00:00","og_image":[{"width":1600,"height":1066,"url":"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/Phaser-Titelbild.jpg","type":"image\/jpeg"}],"author":"Daniel Wuggenig","twitter_card":"summary_large_image","twitter_creator":"@_ANEXIA","twitter_site":"@_ANEXIA","twitter_misc":{"Verfasst von":"Daniel Wuggenig","Gesch\u00e4tzte Lesezeit":"10\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/","url":"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/","name":"Phaser Tutorial: HTML5 Racing Game - ANEXIA Blog","isPartOf":{"@id":"https:\/\/anexia.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/#primaryimage"},"image":{"@id":"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/#primaryimage"},"thumbnailUrl":"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/Phaser-Titelbild.jpg","datePublished":"2016-06-17T06:06:34+00:00","dateModified":"2022-04-22T06:36:16+00:00","author":{"@id":"https:\/\/anexia.com\/blog\/#\/schema\/person\/6f0e77d2bc1f23f7e353f1e6e2f2acfd"},"description":"Phaser offers beginners in game development the opportunity, to create HTML5 based games. In this tutorial, I want to explain the entry in Phaser with the help of a racing game.","breadcrumb":{"@id":"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/"]}]},{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/#primaryimage","url":"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/Phaser-Titelbild.jpg","contentUrl":"https:\/\/anexia.com\/blog\/wp-content\/uploads\/2016\/06\/Phaser-Titelbild.jpg","width":1600,"height":1066,"caption":"Phaser-Titelbild"},{"@type":"BreadcrumbList","@id":"https:\/\/anexia.com\/blog\/en\/phaser-tutorial-html5-racing-game\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/anexia.com\/blog\/de\/"},{"@type":"ListItem","position":2,"name":"Phaser Tutorial: HTML5 Racing Game"}]},{"@type":"WebSite","@id":"https:\/\/anexia.com\/blog\/#website","url":"https:\/\/anexia.com\/blog\/","name":"ANEXIA Blog","description":"[:de] ANEXIA Blog - Technischen Themen, Anexia News und Insights [:]","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/anexia.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de"},{"@type":"Person","@id":"https:\/\/anexia.com\/blog\/#\/schema\/person\/6f0e77d2bc1f23f7e353f1e6e2f2acfd","name":"Daniel Wuggenig","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/anexia.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c60eb93ac799bb6eaada1b39ebd15b85?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c60eb93ac799bb6eaada1b39ebd15b85?s=96&d=mm&r=g","caption":"Daniel Wuggenig"},"url":"https:\/\/anexia.com\/blog\/author\/dwuggenig\/"}]}},"lang":"en","translations":{"en":6937,"de":1290},"amp_enabled":true,"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/anexia.com\/blog\/wp-json\/wp\/v2\/posts\/6937"}],"collection":[{"href":"https:\/\/anexia.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anexia.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anexia.com\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/anexia.com\/blog\/wp-json\/wp\/v2\/comments?post=6937"}],"version-history":[{"count":1,"href":"https:\/\/anexia.com\/blog\/wp-json\/wp\/v2\/posts\/6937\/revisions"}],"predecessor-version":[{"id":6940,"href":"https:\/\/anexia.com\/blog\/wp-json\/wp\/v2\/posts\/6937\/revisions\/6940"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/anexia.com\/blog\/wp-json\/wp\/v2\/media\/1447"}],"wp:attachment":[{"href":"https:\/\/anexia.com\/blog\/wp-json\/wp\/v2\/media?parent=6937"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anexia.com\/blog\/wp-json\/wp\/v2\/categories?post=6937"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anexia.com\/blog\/wp-json\/wp\/v2\/tags?post=6937"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}