zoukankan      html  css  js  c++  java
  • CocosCreator Texture2d.initWithData方法

    var imgWidth = 200;
            var imgHeight = 200;
            var count = imgWidth * imgHeight * 4;
            var imgData =new Uint8Array(count);
            for (var j = 0; j < count; j += 4) {
                imgData[j] = Util.randomNum(0, 255);
                imgData[j + 1] = Util.randomNum(0, 255);
                imgData[j + 2] = Util.randomNum(0, 255);
                imgData[j + 3] = 255;
            }
     
            var myTexture2D =new cc.Texture2D();
            myTexture2D.initWithData(imgData, cc.Texture2D.PixelFormat.RGBA8888, imgWidth, imgHeight);
     
            var node =new cc.Node('测试图片');
            node.width = imgWidth;
            node.height = imgHeight;
            node.parent = Main.node;
             
            var sprite = node.addComponent(cc.Sprite);
            sprite.spriteFrame =new cc.SpriteFrame();
            sprite.spriteFrame.setTexture(myTexture2D)
    
  • 相关阅读:
    axios baseURL
    TP5 nginx 配置
    Vue
    key
    curl openssl error
    vue use bulma
    《平凡的世界》
    《听听那冷雨》余光中
    心烦意乱
    祝你19岁生日快乐
  • 原文地址:https://www.cnblogs.com/kingBook/p/13432323.html
Copyright © 2011-2022 走看看