'Adding an image in phaser that doesnt come out of assets

For school im trying out phaser and im having a hard time tbh. Im trying to make an infinite jumper game and everything works, but im trying to do something extra.

I want my character to be an image of yourself that you take, before the game. So far I can make a picture using javascript to call up to the webcam, but I cant load the imagine into phaser.

Can you load images that aren't in the assets folder (because you just made them in javascript using the webcam) in phaser? I tried making a new image but I don't know where I would put my src.

I put my image into a canvas where I also give my src. Using querySelector I take the src and try to load it into phaser.

this is what I have: In the create function im making a new image

playerSrc = document.querySelector('.image').src;

let playerImage = this.make.image({
    key: 'playerImage',
    src: playerSrc,
    add: true
});
player = this.physics.add.image(150, 450, 'playerImage');

but adding the src like this doesn't work.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source