cocos2d-x pix

    const int w = 100;
    const int h = 100;
    const int size = w * h * 4;
    unsigned char data[size] = { 0 };
    for (int i = 0; i < size; i += 4)
    {
        data[i] = 255;//r
        data[i + 1] = 0;//g
        data[i + 2] = 0;//b
        data[i + 3] = 80;//a
    }


    auto texture = new (std::nothrow) Texture2D();
    texture->initWithData(data, size, Texture2D::PixelFormat::RGBA8888, w, h, Size(100, 100));

posted @ 2020-09-27 23:33  YZFHKMS-X  阅读(126)  评论(0编辑  收藏  举报