Anyidea why phaser.min.js is terribly oudated? Wrong links? Everywhere? I tried downloading the zip and tar.gz files as well. Same thing. Or I am getting something wrong? Where do I get phaser.min.js version 2.6.2?
When starting the application choose Try TexturePacker Pro. In the main window use the Choose Data Formatbutton and select Phaser (JSONHash) from the list. You can usethe filter to find it faster.
Which of the two Phaser exporters you choose does not really matter. They contain the identical data with somedifferent layout. If you use the Phaser (JSONArray) you'll have to load your sprite sheetusing game.load.atlasJSONArray() instead of game.load.atlasJSONHash() .
You can get Phaser directly from their GitHub page.For a simple setup download the version you would like to use as single Javascript file:phaser/v2.6.2/build/phaser.min.js.Place the file in the location where you want the demo to run from.
This creates a sprite with the first frame of the animation: capguy/walk/0001.The next line scales the sprite down by 50% because it would otherwise be a bit too big for your scene.Phaser.Animation.generateFrameNames('capguy/walk/', 1, 8, '', 4) creates a bunchof frame names. 1 is the start index, 8 the end index and the 4 is the number of digits to usefor the animation name. The resulting names are:
For this tutorial, we will be using Node.js and Express to create our server. We will also be using NPM to install the required packages we need for the server to run. In order to follow along with this tutorial, you will need to have Node.js and NPM installed locally, or you will need access to an environment that already has them installed. We will also be using the Command Prompt (Windows) / Terminal (Mac) to install the required packages, and to start/stop our Node server.
Having a prior experience with these tools is a plus, but it is not required for this tutorial. We will not be covering how to install these tools as the focus of this tutorial is making a game with Phaser. The last thing you will need is an IDE or Text Editor for editing your code.
To install Node.js, click the link here: and choose the LTS version. You can download and use the current version with this tutorial, however, the LTS version is recommended for most users. When you install Node.js, NPM will also be installed on your computer. Once you have these tools installed, you can move on to the next part.
The first thing we are going to do is create a basic Node.js server that will serve our game files. To get started, create a new folder on your computer, it can be called anything you want. Then navigate inside this folder and create a new file called server.js. Open up server.js and add the following code to it:
Before we can run the server, we will need to install the required modules for the server. Open your terminal/command prompt, and navigate to your project folder. Once there you will need to run the following command: npm init -f. This will create a package.json file in your project folder. We will use this file to keep track of all the packages that our project depends on.
With the basic server code finished, we will now work on setting up our client-side code. In your project folder, create a new folder called public. Any file we put in this folder will be rendered by the server that we set up. So we will want to put all of our static client-side files in this folder. Now inside the public folder, create a new file called index.html. Open up index.html and add the following code to it:
In the code above, we set up a simple HTML page and we referenced two JavaScript files, phaser.min.js (the phaser game framework) and game.js (our Phaser game code). Back in the public folder, create a new folder called js , and in this folder create a new file called game.js. Open up game.js and add the following code to it:
With our basic client-side code setup, we will now test our server and make sure everything is working correctly. Back in the terminal/command prompt, run the following command: node server.js and you should see the following line appear Listening on 8081. Now, if you open up your web browser and navigate to :8081/, you should see a black box on the web page, and if you open the console in the developer tools, you should see a log with the version of Phaser your game is running.
With our server now rendering our game, we will now work on adding Socket.IO to our game. If you are not familiar with Socket.IO, it is a JavaScript library that enables real-time, bi-directional communication between web clients and servers. To use Socket.IO, we need to update our client and server code to enable the communication between the two.
For this tutorial, we will store the player data in memory on the server. Normally, we would want to store this data in some type of database, that way it would be persistent, and if the server fails, we could easily recover the state of the game.
3a8082e126