Skip to content

Commit 723ac25

Browse files
committed
Clarify spacing argument in Loader#spritesheet
Add example spritesheet Closes #559. Thanks @FostUK #448
1 parent ab17194 commit 723ac25

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

resources/Spritesheet/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
![mummy](mummy.png)
2+
3+
```javascript
4+
this.load.spritesheet('mummy', 'mummy.png',
5+
37, // frameWidth
6+
45, // frameHeight
7+
-1, // frameMax
8+
2, // margin
9+
4 // spacing
10+
);
11+
```

resources/Spritesheet/mummy.png

1.51 KB
Loading

src/animation/AnimationParser.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Phaser.AnimationParser = {
2525
* @param {number} [spacing=0] - If the frames have been drawn with spacing between them, specify the amount here.
2626
* @param {number} [skipFrames=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one image.
2727
* @return {Phaser.FrameData} A FrameData object containing the parsed frames.
28+
*
29+
* @see Phaser.Loader#spritesheet
2830
*/
2931
spriteSheet: function (game, key, frameWidth, frameHeight, frameMax, margin, spacing, skipFrames)
3032
{

src/loader/Loader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,8 @@ Phaser.Loader.prototype = {
11511151
* # sprite frame
11521152
* ```
11531153
*
1154+
* `spacing` must be on only the right and bottom edges of each frame, including the last row and column.
1155+
*
11541156
* The first sprite frame is found at (margin) px from the left of the image.
11551157
* The second sprite frame is found at (margin + frameWidth + spacing) px from the left of the image, and so on.
11561158
*
@@ -1161,7 +1163,7 @@ Phaser.Loader.prototype = {
11611163
* @param {number} frameHeight - Height in pixels of a single frame in the sprite sheet.
11621164
* @param {number} [frameMax=-1] - How many frames in this sprite sheet. If not specified it will divide the whole image into frames.
11631165
* @param {number} [margin=0] - The distance from the top-left of the image to the top-left of the first frame, if any.
1164-
* @param {number} [spacing=0] - The distance from the right edge of a frame to the left edge of the next frame on the same row; or the distance from the bottom edge of a frame to the top edge of the next frame on the same column.
1166+
* @param {number} [spacing=0] - The distance from the right edge of a frame to the left edge of the next frame on the same row, from the right edge of the last frame of a row to the margin, from the bottom edge of a frame to the top edge of the next frame on the same column, and from the bottom edge of the last frame of a column to the margin.
11651167
* @param {number} [skipFrames=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one image.
11661168
* @return {Phaser.Loader} This Loader instance.
11671169
*/

0 commit comments

Comments
 (0)