Warning: The magic method EDD_Blocks::__wakeup() must have public visibility in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php on line 101

Warning: The magic method EDD_Blocks::__wakeup() must have public visibility in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks/edd-blocks.php on line 101

Warning: The magic method GAINWP_Manager::__wakeup() must have public visibility in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/gainwp.php on line 78

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 555

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 585

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 617

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 651

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 686

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 745

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 785

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Deprecated: Automatic conversion of false to array is deprecated in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/publitio-offloading/includes/class-publitio-offloading.php on line 577

Deprecated: Automatic conversion of false to array is deprecated in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/publitio-offloading/includes/class-publitio-offloading.php on line 577

Deprecated: Automatic conversion of false to array is deprecated in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/publitio-offloading/includes/class-publitio-offloading.php on line 577

Deprecated: Automatic conversion of false to array is deprecated in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/publitio-offloading/includes/class-publitio-offloading.php on line 577

Deprecated: Automatic conversion of false to array is deprecated in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/publitio-offloading/includes/class-publitio-offloading.php on line 577

Deprecated: Automatic conversion of false to array is deprecated in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/publitio-offloading/includes/class-publitio-offloading.php on line 577

Deprecated: Automatic conversion of false to array is deprecated in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/publitio-offloading/includes/class-publitio-offloading.php on line 577

Deprecated: Automatic conversion of false to array is deprecated in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/publitio-offloading/includes/class-publitio-offloading.php on line 577

Deprecated: Automatic conversion of false to array is deprecated in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/publitio-offloading/includes/class-publitio-offloading.php on line 577

Deprecated: Automatic conversion of false to array is deprecated in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/publitio-offloading/includes/class-publitio-offloading.php on line 577

Deprecated: Automatic conversion of false to array is deprecated in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/publitio-offloading/includes/class-publitio-offloading.php on line 577

Deprecated: Automatic conversion of false to array is deprecated in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/publitio-offloading/includes/class-publitio-offloading.php on line 577

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831
{"id":1929,"date":"2017-09-19T00:41:49","date_gmt":"2017-09-19T00:41:49","guid":{"rendered":"https:\/\/phasergames.com\/?p=1929"},"modified":"2017-09-19T00:45:06","modified_gmt":"2017-09-19T00:45:06","slug":"using-texturepackergui-make-sprite-sheets","status":"publish","type":"post","link":"https:\/\/phasergames.com\/using-texturepackergui-make-sprite-sheets\/","title":{"rendered":"Using TexturePackerGUI to make Sprite Sheets"},"content":{"rendered":"

The hard way!<\/h3>\n

For a long time, I’ve been making sprite sheets by opening up my trusty old now discontinued Adobe fireworks (never could get the hang of photoshop). I would evenly space out individual images, resizing and repositioning until it was just right. There may be sometimes I will still do this, but more than likely I will use a brilliant piece of software called TexturePackerGUI<\/a>They have both free and paid versions.<\/p>\n

 <\/p>\n

 <\/p>\n

Free or Pro?<\/h3>\n

While I have the pro version, I mostly bought it because the artists in my office have the pro version and I needed to open their files. For my own stuff, I probably could have gotten by with the free version, the artists I work with insist on having the paid features. I won’t go into all the details between the two. I suggest starting with the free version and check it out for yourself.<\/p>\n

 <\/p>\n

How to make a sprite sheet<\/h3>\n

TexturePackerGUI is a powerful program with many options, so there are a lot of ways to set up your sprite sheet. I’m going to take you through how I do it 99% of the time.<\/p>\n

 <\/p>\n

1. Select Images<\/h3>\n

First I select my images, and always make sure they are numbered or have a number on the end. This helps when you need to refer to the frame number later in the code.<\/p>\n

\"\"<\/p>\n

2. Drag Images into the GUI<\/h3>\n

Next, open up\u00a0TexturePackerGUI and drag your images into the empty pane on the right.<\/p>\n

\"\"<\/p>\n

3. Resize if needed<\/h3>\n

When I dragged the bird images into the software it showed me that 8 frames would not fit inside one single sheet.<\/p>\n

\"\"<\/p>\n

When I looked at the size I could see that the image was much too big for my game. I took up about 80% of my screen.<\/p>\n

\"\"<\/p>\n

So I decided to resize all images to 25% of the original and they all fit fine onto one sheet.<\/p>\n

\"\"<\/p>\n

4. Select settings<\/h3>\n

There are several different layout settings but I almost always set the algorithm to basic and sort by to Name.<\/p>\n

\"\"\"\"<\/p>\n

Why do I do this? Remember that I end filename with a number? Doing it this way will keep those in order.<\/p>\n

If I am making a card game, for example, I want frame 0 to be an ace and frame 1 to be a 2. If I am making a tile-based game with letters, I want the frame 0 to be an A and frame 1 to be a B, and so forth.<\/p>\n

Your game may differ so feel free to choose the optimization\u00a0that works best for your game, but this is what works well for me.<\/p>\n

Note: It may be that things are still kept in order in the file, but not in the image. Looking into this.<\/p>\n

5. Export files<\/h3>\n

If your data settings\u00a0don’t say Phaser, then click the file format button and a selection list will appear in the middle.<\/p>\n

Select Phaser(JSONArray)<\/p>\n

\"\"<\/a><\/p>\n

Click the publish sprite sheet button<\/p>\n

\"\"<\/p>\n

The progress box appears<\/p>\n

\"\"<\/p>\n

Two files are generated, an image file that is the sprite sheet and a JSON file that contains the frame data.<\/p>\n

\"\"<\/p>\n

Place these files in your image folder of your project.<\/p>\n

6. Loading the sprite sheet.<\/h3>\n

The format for loading a JSON supported sprite sheet is a follows<\/p>\n

game.load.atlasJSONHash('key', 'path_to_sprite_sheet, 'path_to_data_file');<\/pre>\n

So for our bird, the code would be:<\/p>\n

game.load.atlasJSONHash('bird', 'images\/bird.png', 'images\/bird.json');<\/pre>\n

And then we would define the animation as normal.<\/p>\n

var StateMain = {\r\n\r\n    preload: function () {\r\n    \tgame.load.atlasJSONHash('bird', 'images\/bird.png', 'images\/bird.json');        \r\n    },\r\n\r\n    create: function () {\r\n        var bird=game.add.sprite(game.width\/2,game.height\/2,\"bird\");\r\n        bird.anchor.set(0.5,0.5);\r\n        bird.animations.add(\"fly\",[0,1,2,3,4,5,6,7],12,true);\r\n        bird.animations.play(\"fly\");\r\n    },\r\n\r\n    update: function () {\r\n\r\n    }\r\n\r\n}<\/pre>\n

Here is the result.<\/p>\n\n\n