charlie_says Posted February 21, 2017 Share Posted February 21, 2017 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 More sharing options...
rblopes Posted February 21, 2017 Share Posted February 21, 2017 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); samme 1 Link to comment Share on other sites More sharing options...
charlie_says Posted February 21, 2017 Author Share Posted February 21, 2017 It is that! Thanks! I'm not sure how I missed that example (I thought I'd gone through all of them.) <edit> Actually, I now wonder if I'd tried it and it hadn't worked because I just tried passing the bmd rather than the bmd.canvas.< /edit> Works exactly as you'd expect. rblopes 1 Link to comment Share on other sites More sharing options...
charlie_says Posted February 21, 2017 Author Share Posted February 21, 2017 And it improves the performance. Link to comment Share on other sites More sharing options...
Recommended Posts