Hello,
Is it possible to load an image in phaser 2 from browser local storage?
supposing that we have saved the image using this command in localstorage
localStorage.setItem('myImage', 'base64 encoded string representing the PNG image');
how can I load it in phaser2? I tried this code but it does not work:
game.cache.addImage('img', null, localStorage.getItem('myImage'));
var image = game.add.image(0, 0, 'img');
var loader = this.load.image("img", localStorage.getItem('myImage'));
loader.addOnce("onLoadComplete", function(){
var image = game.add.image(0, 0, 'img');
});
or do the whole this.load.image("img", localStorage.getItem('myImage')); on the preload state of the current state, then on the create function you should be able to load it normally with the img key.
Thanks for response, but it does not work. As a reminder in localStorage we have base64 encoded contents of image (that has been taken from camera of cell phone using cordova) not URL of image.