//设置数字大小 if ( num >= 0) { labelCardNumber->setFontSize (100); } if ( num >= 16) { labelCardNumber->setFontSize (90); } if ( num >= 128) { labelCardNumber->setFontSize (60); } if ( num >= 1024) { labelCardNumber->setFontSize (40); }
//判断数字的大小来调整颜色
if(number == 0){
colorBackground->setColor (Color3B( 200,190 ,180));
}
if ( number == 2) {
colorBackground->setColor (Color3B( 240,230 ,220));
}
if ( number == 4) {
colorBackground->setColor (Color3B( 240,220 ,200));
}
if ( number == 8) {
colorBackground->setColor (Color3B( 240,180 ,120));
}
if ( number == 16) {
colorBackground->setColor (Color3B( 240,140 ,90));
}
if ( number == 32) {
colorBackground->setColor (Color3B( 240,120 ,90));
}
if ( number == 64) {
colorBackground->setColor (Color3B( 240,90 ,60));
}
if ( number == 128) {
colorBackground->setColor (Color3B( 240,90 ,60));
}
if ( number == 256) {
colorBackground->setColor (Color3B( 240,200 ,70));
}
if ( number == 512) {
colorBackground->setColor (Color3B( 240,200 ,70));
}
if ( number == 1024) {
colorBackground->setColor (Color3B( 0,130 ,0));
}
if ( number == 2048) {
colorBackground->setColor (Color3B( 0,130 ,0));
}
【来写个2048吧】—— 后期优化及源码,布布扣,bubuko.com
原文地址:http://blog.csdn.net/wxk_bigworld/article/details/25207495