Jump to content

Create different images using only one bitmapData object


jdnichollsc
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

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