Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Manually add spritesheet to cache


charlie_says
 Share

Recommended Posts

I'd like to manually add a sprite sheet to Phaser's cache. (In case you're asking why, I'm tinting and manipulating the bitmapdata from one generic set rather than manually making the number I need.)

But, I've not been able to do this - I have manually added my manipulated bitmapdata - and I'm blitting my sprite. This works fine, but is not very optimised (or doesn't play well on old devices.) I'm hoping that using Phaser's native sprite functionality might improve this.

Can anyone guide me as to add a sprite sheet - I think where I'm falling over is the framedata, but it's not 100% clear (to me at least) from the docs how to do this.

 

Thanks!

 

 

 

Link to comment
Share on other sites

Could it be this: http://phaser.io/examples/v2/animation/dynamic-animation

    //  And now add it to the cache, so any sprite can use it
    //  The parameters can be found in the API docs, but the important parts are to leave the URL blank and pass the bmd.canvas as the data value
    //  The 22x22 is the frame size and 16 the quantity of frames
    game.cache.addSpriteSheet('dynamic', '', bmd.canvas, 22, 22, 16, 0, 0);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...