Hello, I am trying to build a game for the Facebook platform and trying to create a profile picture sprite with the Facebook user photo base64 URL, but could not achieve this. please help on the same.
thanks
assetManager.loadRemote(FBInstant.player.getPhoto(), {ext : ".jfif"}, (err : any, image : SpriteFrame) => {
PlayerDataCache.Instance.avatarFrame = image;
})
Koei
November 25, 2022, 10:47am
#2
let img = new Image();
img.src = srcurl;
img.onload =function(res){
.....
}
Thanks @Koei this also works and in cocos there is way to handle like below.
`
remoteUrl = "http://unknown.org/emoji?id=124982374";
assetManager.loadRemote<ImageAsset>(remoteUrl, {ext: '.png'}, function (err, imageAsset) {
const spriteFrame = new SpriteFrame();
const texture = new Texture2D();
texture.image = imageAsset;
spriteFrame.texture = texture;
// ...
});
`
remote URL is your base64 string URL address. make sure you are adding {ext : ".png")
in options.
1 Like