My friend modify the library file and allow the use of 2D sprite in the jquery.gamequery-0.7.0.js
Around line 230-240
Around line 200
under the "var defaults = {", add in :
columnsCount: 0, rowHeight: 0, startFrame: 0 |
And then at the bottom of "// "public" attributes:", add in :
this.columnsCount = options.columnsCount; this.rowHeight = options.rowHeight; this.startFrame = options.startFrame; |
Around line 390-400
Add in the else-if code for the animation.
//CUSTOM FUNCTION else if((gameQuery.animation.type & $.gameQuery.ANIMATION_GRID) && (gameQuery.animation.numberOfFrame > 1)) { var column = (gameQuery.animation.startFrame + gameQuery.currentFrame) % gameQuery.animation.columnsCount; var row = Math.floor((gameQuery.animation.startFrame + gameQuery.currentFrame) / gameQuery.animation.columnsCount); //console.log(column + " " + row); $(this).css("background-position",""+(-gameQuery.animation.offsetx-gameQuery.animation.delta*column)+"px "+(-gameQuery.animation.offsety-gameQuery.animation.rowHeight*row)+"px"); } |
Comments
The new build function is still associate well with other function.
The calculation need to capture more information.
rowHeight : it's the row height for each sprite display
startFrame : the startFrame is to determine where sprite frame start. It can optimize the use of sprite in the sprite sheet.
columnCount : capture the number of column in the sprite sheet.
Hope the developer can put this code in, for the next update.