Jump to content

Working with BitmapData


charlie_says
 Share

Recommended Posts

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

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

 Share

  • Recently Browsing   0 members

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