Jump to content

Cache sprite created from Phaser.Graphics


Recommended Posts

Hi there.

I was able to create an image from Phaser.Graphics instance in such way:

var graphics = new Phaser.Graphics(this.game, 0, 0);

graphics.drawRect(0, 0, len, len);

var img = new Phaser.Image(this.game);

Now I'd like to cache this image so I could easily create sprites using its key. Unfortunately I'm unable to find a way to do so. Is that possible?

Link to comment
Share on other sites

You're right, I was thinking of the BitmapData method.

You can do 

game.cache.addItem('name', Phaser.Cache.TEXTURE);
// …
game.cache.getItem('name', Phaser.Cache.TEXTURE);

But I don't think you'd be able to use the string key alone, because that searches the image cache only.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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