[cocos2d-x]string 转 Color

[cocos2d-x]string 转 Color,第1张

概述static int toColor (const char* value, int index) { char digits[3]; char *error; int color; if (strlen(value) != 8) return -1;
static int tocolor (const char* value,int index) {            char digits[3];            char *error;            int color;                        if (strlen(value) != 8) return -1;            value += index * 2;                        digits[0] = *value;            digits[1] = *(value + 1);            digits[2] = '';            color = (int)strtoul(digits,&error,16);            if (*error != 0) return -1;            return color;        }                cocos2d::color4B stringTocolor(std::string &str)        {            if (str.length() != 8)            {                return cocos2d::color4B::WHITE;            }            const char *ch = str.c_str();            glubyte r = (glubyte)tocolor(ch,0);            glubyte g = (glubyte)tocolor(ch,1);            glubyte b = (glubyte)tocolor(ch,2);            glubyte a = (glubyte)tocolor(ch,3);                        return cocos2d::color4B(r,g,b,a);        }
总结

以上是内存溢出为你收集整理的[cocos2d-x]string 转 Color全部内容,希望文章能够帮你解决[cocos2d-x]string 转 Color所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1034853.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-24
下一篇2022-05-24

发表评论

登录后才能评论

评论列表(0条)

    保存