Skip to content

Commit bb08b2c

Browse files
refactor: rename TileInfo.tile() to TileInfo.index()
The method shadowed the global tile() factory and the name did not convey that it derives a tile at an absolute index using this tile as a layout template. Renamed to index() to match the parameter-based naming of offset() and frame(), and moved it next to them. BREAKING CHANGE: TileInfo.tile() removed with no deprecated alias. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 4ba6658 commit bb08b2c

8 files changed

Lines changed: 44 additions & 44 deletions

File tree

dist/littlejs.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,17 +1692,17 @@ declare module "littlejsengine" {
16921692
*/
16931693
frame(frame: number): TileInfo;
16941694
/**
1695-
* Set this tile to use a full image in a texture info
1696-
* @param {TextureInfo} [textureInfo]
1695+
* Returns a tile info for an index using this tile as reference
1696+
* @param {Vector2|number} [index=0]
16971697
* @return {TileInfo}
16981698
*/
1699-
setFullImage(textureInfo?: TextureInfo): TileInfo;
1699+
index(index?: Vector2 | number): TileInfo;
17001700
/**
1701-
* Returns a tile info for an index using this tile as reference
1702-
* @param {Vector2|number} [index=0]
1701+
* Set this tile to use a full image in a texture info
1702+
* @param {TextureInfo} [textureInfo]
17031703
* @return {TileInfo}
17041704
*/
1705-
tile(index?: Vector2 | number): TileInfo;
1705+
setFullImage(textureInfo?: TextureInfo): TileInfo;
17061706
}
17071707
/**
17081708
* Tile Info - Stores info about each texture

dist/littlejs.esm.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4198,6 +4198,14 @@ class TileInfo
41984198
return this.offset(new Vector2(x));
41994199
}
42004200

4201+
/**
4202+
* Returns a tile info for an index using this tile as reference
4203+
* @param {Vector2|number} [index=0]
4204+
* @return {TileInfo}
4205+
*/
4206+
index(index)
4207+
{ return tile(index, this.size, this.textureInfo, this.padding, this.bleed); }
4208+
42014209
/**
42024210
* Set this tile to use a full image in a texture info
42034211
* @param {TextureInfo} [textureInfo]
@@ -4211,14 +4219,6 @@ class TileInfo
42114219
this.bleed = this.padding = 0;
42124220
return this;
42134221
}
4214-
4215-
/**
4216-
* Returns a tile info for an index using this tile as reference
4217-
* @param {Vector2|number} [index=0]
4218-
* @return {TileInfo}
4219-
*/
4220-
tile(index)
4221-
{ return tile(index, this.size, this.textureInfo, this.padding, this.bleed); }
42224222
}
42234223

42244224
/**
@@ -7934,7 +7934,7 @@ class TileLayer extends CanvasLayer
79347934
const d = this.getData(layerPos);
79357935
if (!d || !d.tile) return;
79367936

7937-
const tileInfo = this.tileInfo && this.tileInfo.tile(d.tile);
7937+
const tileInfo = this.tileInfo && this.tileInfo.index(d.tile);
79387938
this.drawLayerTile(drawPos, drawSize, tileInfo, d.color, d.direction*PI/2, d.mirror);
79397939
}
79407940

dist/littlejs.esm.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/littlejs.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4198,6 +4198,14 @@ class TileInfo
41984198
return this.offset(new Vector2(x));
41994199
}
42004200

4201+
/**
4202+
* Returns a tile info for an index using this tile as reference
4203+
* @param {Vector2|number} [index=0]
4204+
* @return {TileInfo}
4205+
*/
4206+
index(index)
4207+
{ return tile(index, this.size, this.textureInfo, this.padding, this.bleed); }
4208+
42014209
/**
42024210
* Set this tile to use a full image in a texture info
42034211
* @param {TextureInfo} [textureInfo]
@@ -4211,14 +4219,6 @@ class TileInfo
42114219
this.bleed = this.padding = 0;
42124220
return this;
42134221
}
4214-
4215-
/**
4216-
* Returns a tile info for an index using this tile as reference
4217-
* @param {Vector2|number} [index=0]
4218-
* @return {TileInfo}
4219-
*/
4220-
tile(index)
4221-
{ return tile(index, this.size, this.textureInfo, this.padding, this.bleed); }
42224222
}
42234223

42244224
/**
@@ -7934,7 +7934,7 @@ class TileLayer extends CanvasLayer
79347934
const d = this.getData(layerPos);
79357935
if (!d || !d.tile) return;
79367936

7937-
const tileInfo = this.tileInfo && this.tileInfo.tile(d.tile);
7937+
const tileInfo = this.tileInfo && this.tileInfo.index(d.tile);
79387938
this.drawLayerTile(drawPos, drawSize, tileInfo, d.color, d.direction*PI/2, d.mirror);
79397939
}
79407940

dist/littlejs.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/littlejs.release.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3507,6 +3507,14 @@ class TileInfo
35073507
return this.offset(new Vector2(x));
35083508
}
35093509

3510+
/**
3511+
* Returns a tile info for an index using this tile as reference
3512+
* @param {Vector2|number} [index=0]
3513+
* @return {TileInfo}
3514+
*/
3515+
index(index)
3516+
{ return tile(index, this.size, this.textureInfo, this.padding, this.bleed); }
3517+
35103518
/**
35113519
* Set this tile to use a full image in a texture info
35123520
* @param {TextureInfo} [textureInfo]
@@ -3520,14 +3528,6 @@ class TileInfo
35203528
this.bleed = this.padding = 0;
35213529
return this;
35223530
}
3523-
3524-
/**
3525-
* Returns a tile info for an index using this tile as reference
3526-
* @param {Vector2|number} [index=0]
3527-
* @return {TileInfo}
3528-
*/
3529-
tile(index)
3530-
{ return tile(index, this.size, this.textureInfo, this.padding, this.bleed); }
35313531
}
35323532

35333533
/**
@@ -7243,7 +7243,7 @@ class TileLayer extends CanvasLayer
72437243
const d = this.getData(layerPos);
72447244
if (!d || !d.tile) return;
72457245

7246-
const tileInfo = this.tileInfo && this.tileInfo.tile(d.tile);
7246+
const tileInfo = this.tileInfo && this.tileInfo.index(d.tile);
72477247
this.drawLayerTile(drawPos, drawSize, tileInfo, d.color, d.direction*PI/2, d.mirror);
72487248
}
72497249

src/engineDraw.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ class TileInfo
190190
return this.offset(new Vector2(x));
191191
}
192192

193+
/**
194+
* Returns a tile info for an index using this tile as reference
195+
* @param {Vector2|number} [index=0]
196+
* @return {TileInfo}
197+
*/
198+
index(index)
199+
{ return tile(index, this.size, this.textureInfo, this.padding, this.bleed); }
200+
193201
/**
194202
* Set this tile to use a full image in a texture info
195203
* @param {TextureInfo} [textureInfo]
@@ -203,14 +211,6 @@ class TileInfo
203211
this.bleed = this.padding = 0;
204212
return this;
205213
}
206-
207-
/**
208-
* Returns a tile info for an index using this tile as reference
209-
* @param {Vector2|number} [index=0]
210-
* @return {TileInfo}
211-
*/
212-
tile(index)
213-
{ return tile(index, this.size, this.textureInfo, this.padding, this.bleed); }
214214
}
215215

216216
/**

src/engineTileLayer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ class TileLayer extends CanvasLayer
483483
const d = this.getData(layerPos);
484484
if (!d || !d.tile) return;
485485

486-
const tileInfo = this.tileInfo && this.tileInfo.tile(d.tile);
486+
const tileInfo = this.tileInfo && this.tileInfo.index(d.tile);
487487
this.drawLayerTile(drawPos, drawSize, tileInfo, d.color, d.direction*PI/2, d.mirror);
488488
}
489489

0 commit comments

Comments
 (0)