Suggested changes to IgeCellSheet & IgeTiledComponent

A place to request and discuss new engine features / functionality

Suggested changes to IgeCellSheet & IgeTiledComponent

Postby StuartTresadern » Sat Dec 28, 2013 2:26 pm

Currently the IgeCellSheet assumes an exact division of tiles when extracting the cells. In some cases I have power of 2 sprite sheets that have additional padding to the left and bottom of the sheet which prevents the tiles being extracted by the IgeCellSheet.

Suggested change to the IgeCellSheet:
init
Code: Select all
init: function (url, horizontalCells, verticalCells, cellWidth, cellHeight) {
      var self = this;

      self.horizontalCells(Math.floor(horizontalCells) || 1);
      self.verticalCells(Math.floor(verticalCells) || 1);
        self.cellWidth = (cellWidth || 0);
        self.cellHeight = (cellHeight || 0);

      IgeTexture.prototype.init.call(this, url);
   },


_applyCells

Code: Select all
 // Store the width and height of a single cell
//                cellWidth = this._cellWidth = imgWidth / columns;
//                cellHeight = this._cellHeight = imgHeight / rows;
                if (this.cellWidth > 0 && this.cellHeight > 0){
                    cellWidth = this._cellWidth = this.cellWidth
                    cellHeight = this._cellHeight = this.cellHeight
                }
                else{
                    cellWidth = this._cellWidth = imgWidth / columns;
                    cellHeight = this._cellHeight = imgHeight / rows;
                }


this seems to work with existing sprite sheets and also allows you to specify exact cell dimensions.

(Not sure how the engine deals with fully transparent tiles, if this is not managed already then empty tiles would need to be checked for and removed).

Suggested change to IgeTiledComponent:

Code: Select all
  // cs = new IgeCellSheet(tileSetItem.image, this.width / tileSetItem.tilewidth, this.height / tileSetItem.tileheight)

                        cs = new IgeCellSheet(tileSetItem.image, this.width / tileSetItem.tilewidth, this.height / tileSetItem.tileheight, tileSetItem.tilewidth, tileSetItem.tileheight)


as tiled passes the tile height and width we can pass this on to the IgeCellSheet.

* An additional enhancement for the future would be to allow the passing of margin information around cells and manage the extraction of the tiles.
User avatar
StuartTresadern
 
Posts: 59
Joined: Sun Dec 01, 2013 5:23 pm
Location: Germany

Re: Suggested changes to IgeCellSheet & IgeTiledComponent

Postby rob » Sat Dec 28, 2013 2:35 pm

For more complex cell arrangements the IgeSpriteSheet class can handle arbitrary cell sizes and positioning, and can even *automatically* detect all the distinct cells in a sheet and split them.

Agree that maintaining power of 2 is a good idea though and will definitely look to add this functionality as I agree it is a good addition! :)
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm


Return to New Feature Discussion

Who is online

Users browsing this forum: No registered users and 1 guest
cron