jdnichollsc Posted February 12, 2016 Share Posted February 12, 2016 Hi guys! How you can create different images to several sprites using a single BitmapData? Thanks in advance, Nicholls Link to comment Share on other sites More sharing options...
Zeterain Posted February 12, 2016 Share Posted February 12, 2016 You are probably looking for bitmapData.generateTexture. (http://phaser.io/docs/2.4.4/Phaser.BitmapData.html#generateTexture) You could draw an image on the bitmapData, generate a texture from that object, and then draw a new image on the bitmapData. Using their example code: var bitmapdata = this.game.add.bitmapData(width, height); // Draw to the bitmap data however you want // Create a texture using that bitmap data var texture = bitmapdata.generateTexture('nameOfTexture'); // Then you can either apply the texture to a sprite: game.add.sprite(0, 0, texture); // or by using the string based key: game.add.sprite(0, 0, 'nameOfTexture'); // You can then re-draw to the bitmapData, generate a new texture, and repeat If you want to use a single bitmapData object itself for multiple images, I don't think that's possible. Link to comment Share on other sites More sharing options...
jdnichollsc Posted February 12, 2016 Author Share Posted February 12, 2016 You're correct, it isn't possible for multiple sprites with different images. Because if the bitmapData changes, the texture of the sprite is updated for all. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts