charlie_says Posted May 15, 2014 Share Posted May 15, 2014 I'm trying a few things with bitmapdata, and keep running up against the same problem, which is, that I can't use copyPixels/draw to "add" one bitmapData to another (both methods require an image from the game.cache or an HTML image). Is there a way of adding bitmapdata to the cache? Or creating an HTML image that I can then use with the above methods? Link to comment Share on other sites More sharing options...
charlie_says Posted May 15, 2014 Author Share Posted May 15, 2014 Ok I read a bit more, and foundgame.cache.addBitmapData('foo', barBMD );but this doesn't work and generates the error: Phaser.Cache.getImage: Invalid key: "foo" Link to comment Share on other sites More sharing options...
charlie_says Posted May 16, 2014 Author Share Posted May 16, 2014 Apologies for answering my own question, but just in case someone else might find it helpful. The BitmapData object created has a number of properties, one being canvas, which means that you can copy (or manipulate) it to an another BitmapData object.var bmd1 = game.make.bitmapData(50, 50);var rect = new Phaser.Rectangle(0,0,50,50);bmd1.fill(255,0,0,1);bmd2.copyPixels(bmd1.canvas, rect, 20, 20); Link to comment Share on other sites More sharing options...
Recommended Posts