Home Game Development Change Sprite Image Runtime programmatically – Cocos Creator

Change Sprite Image Runtime programmatically – Cocos Creator

0
Change Sprite Image Runtime programmatically – Cocos Creator

[ad_1]

I’m attempting to vary spriteframe ontouch occasion utilizing the code given in Documentation.
But on faucet the spriteframe goes clean. utilizing CocosCreator 3.5.2
Getting this error on Console.

      const self = this;
      const url="property/NewImage";
      assets.load(url, ImageAsset, (err: any, imageAsset) => {
        const sprite = this.getComponent(Sprite);
        const spriteFrame = new SpriteBody();
        const tex = new Texture2D();
        tex.picture = imageAsset;
        spriteFrame.texture = tex;
        sprite.spriteFrame = spriteFrame;
      });

https://docs.cocos.com/creator/3.5/handbook/en/asset/sprite-frame.html?h=body

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here