Load remote image and display it – Cocos Creator

Hi guys, I want to load remote image and display it in my game. I have refer intro to the following instructions Asset Loading · Cocos Creator.

And, I got the content about, then create Texture2D, SpriteFrame and set spriteFrame for node. But I got an error:

Uncaught TypeError: WebGLRenderingContext.texSubImage2D: Argument 7 is not valid for any of the 7-argument overloads.

Here my code:

async start () {
        let assetManager = new AssetManager();
        let remoteUrl = "http://***/image/favicon.jpeg";
        let self = this;
        assetManager.loadRemote<ImageAsset>(remoteUrl, function (err, imageAsset) {
            const spriteFrame = new SpriteFrame();
            const texture = new Texture2D();
            texture.image = imageAsset;
            spriteFrame.texture = texture;
            self.node.getComponent(Sprite).spriteFrame = spriteFrame;

Do you have solution fix it? Please help me, thank you.

Source link

More To Explore

Using Stock Content for Safe Productions

Guidelines for safe filming practices and making your production pop with stock   It’s been an unquestionably challenging time in the film and entertainment industry.

Share on facebook
Share on twitter
Share on linkedin
Share on email