8000 Tiled Image Collection support is now available and has been added to… · ITCSsDeveloper/phaser@698167a · GitHub
Skip to content

Commit 698167a

Browse files
committed
Tiled Image Collection support is now available and has been added to the TilemapParser and Tilemap classes (thanks @asyed94 phaserjs#1879)
1 parent 1f76340 commit 698167a

5 files changed

Lines changed: 31 additions & 12 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ Version 2.4 - "Katar" - in dev
319319
* maxHealth is a new property that Game Objects with the Health component receive and works in combination with the `heal` method to ensure a health limit cap.
320320
* Text.setTextBounds is a rectangular region that allows you to align your text within it, regardless of the number of lines of text or position within the world. For example in an 800x600 sized game if you set the textBounds to be 0,0,800,600 and text alignment to 'left' and vertical alignment to 'bottom' then the text will render in the bottom-right hand corner of the game, regardless of the size of font you're using or the number of lines in the text itself.
321321
* Text.autoRound allows you to control if the text is allowed to render at sub-pixel coordinates or not. Set to `true` to round the coordinates, often eliminating anti-aliasing from certain font types (#1867)
322+
* Tiled Image Collection support is now available and has been added to the TilemapParser and Tilemap classes (thanks @asyed94 #1879)
322323

323324
### Updates
324325

build/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@
366366
if ($modules['tilemap'])
367367
{
368368
echo <<<EOL
369+
<script src="$path/src/tilemap/ImageCollection.js"></script>
369370
<script src="$path/src/tilemap/Tile.js"></script>
370371
<script src="$path/src/tilemap/Tilemap.js"></script>
371372
<script src="$path/src/tilemap/TilemapLayer.js"></script>

src/tilemap/ImageCollection.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Phaser.ImageCollection = function (name, firstgid, width, height, margin, spacin
7878

7979
/**
8080
* The cached images that are a part of this collection.
81-
* @property {?object} images
81+
* @property {array} images
8282
* @readonly
8383
*/
8484
// Modified internally
@@ -94,11 +94,12 @@ Phaser.ImageCollection = function (name, firstgid, width, height, margin, spacin
9494
};
9595

9696
Phaser.ImageCollection.prototype = {
97+
9798
/**
9899
* Returns true if and only if this image collection contains the given image index.
99100
*
100101
* @method Phaser.ImageCollection#containsImageIndex
101-
* @public
102+
* @param {integer} imageIndex - The image index to search for.
102103
* @return {boolean} True if this Image Collection contains the given index.
103104
*/
104105
containsImageIndex: function (imageIndex) {
@@ -114,20 +115,16 @@ Phaser.ImageCollection.prototype = {
114115
* Add an image to this Image Collection.
115116
*
116117
* @method Phaser.ImageCollection#addImage
117-
* @public
118-
* @param {string} image - The the key of the image in the Image Collection and in the cache.
119118
* @param {integer} gid - The gid of the image in the Image Collection.
119+
* @param {string} image - The the key of the image in the Image Collection and in the cache.
120120
*/
121121
addImage: function (gid, image) {
122-
var newImage = {
123-
gid: gid,
124-
image: image
125-
};
126122

127-
this.images.push(newImage);
128-
this.total ++;
123+
this.images.push({ gid: gid, image: image });
124+
this.total++;
125+
129126
}
130-
};
131127

128+
};
132129

133-
Phaser.ImageCollection.prototype.constructor = Phaser.ImageCollection;
130+
Phaser.ImageCollection.prototype.constructor = Phaser.ImageCollection;

tasks/manifests/tilemaps.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[
2+
"src/tilemap/ImageCollection.js",
23
"src/tilemap/Tile.js",
34
"src/tilemap/Tilemap.js",
45
"src/tilemap/TilemapLayer.js",

typescript/phaser.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,25 @@ declare module Phaser {
16281628

16291629
}
16301630

1631+
class ImageCollection {
1632+
1633+
constructor(name: string, firstgid: number, width?: number, height?: number, margin?: number, spacing?: number, properties?: any);
1634+
1635+
name: string;
1636+
firstgid: number;
1637+
imageWidth: number;
1638+
imageHeight: number;
1639+
imageMargin: number;
1640+
imageSpacing: number;
1641+
properties: any;
1642+
images: array;
1643+
total: number;
1644+
1645+
addImage(gid: number, image: string): void;
1646+
containsImageIndex(imageIndex: number): boolean;
1647+
1648+
}
1649+
16311650
class Input {
16321651

16331652
constructor(game: Phaser.Game);

0 commit comments

Comments
 (0)