New Code For 2D sprite.
  • 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
    ANIMATION_GRID:		  64,


    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");
     
    }

  • For Usage:
    var IrvineAnimation = new $.gameQuery.Animation({ 
    imageURL: "FF8Sprites.png",
    numberOfFrame: 12,
    delta: 50,
    rowHeight: 64,
    startFrame: 0,
    columnsCount: 3,
    rate: 120,
    offsetx: 0,
    offsety: 258,
    type: $.gameQuery.ANIMATION_GRID | $.gameQuery.ANIMATION_PINGPONG});


    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 this can help :)
    Hope the developer can put this code in, for the next update.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!