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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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