Load image from JS to Phaser Game

I'm doing a custom game which I'd like to change the background and a character picture according to a file they upload. The input file is outside phaser. If possible, I'd like to show the picture directly without uploading to the server.

Upvotes: 1

Views: 458

Answers (1)

Harry Scheuerle
Harry Scheuerle

Reputation: 446

If you use a file loader to get the base64 encoding of the image, you can use this.textures.addBase64 to load the image into the texture manager, after that loads you can create new objects with that image tag, or set existing images to that texture.

Working Example => https://stackblitz.com/edit/phaser-use-uploaded-image

Upvotes: 1

Related Questions