Jump to content

Adding existing image.


Recommended Posts

You can use the canvas' toDataURL-method to generate data URL for your image, and than use the Phaser.Cache's addImage() method to apply it to your game:

var image = document.getElementById("fez");var canvas = document.createElement('canvas');canvas.width = image.width;canvas.height = image.height;var context = canvas.getContext('2d');context.drawImage(image, 0, 0);var dataURI = canvas.toDataURL("image/png");var data = new Image();data.src = dataURI;game.cache.addImage('myImage', dataURI, data);
Link to comment
Share on other sites


  • Recently Browsing   0 members

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