UINumber* UINumber::numberWithStyle(NumStyle style){ UINumber* n = new UINumber; if(n && n->initWithStyle(style)){ n->autorelease(); return n; } CC_SAFE_DELETE(n); return NULL; }
/* * initWithStyle 初始化 */ UINumber* UINumber::initWithStyle(NumStyle style) { //if( (self=[super init])) { UINumber* self = UINumber::create(); self->init(style); self->autorelease(); //} return self; }
void UIRollNum::clearEffect(){ for(unsigned int i = 0; i < numArray->count(); i++){ UINumber* pNumber = (UINumber*)numArray->objectAtIndex(i); this->removeChild(pNumber, true); } numArray->removeAllObjects(); for(int i = 0; i < m_maxCol; i++){ UINumber* pNumber = UINumber::numberWithStyle(style); numArray->addObject(pNumber); pNumber->setNumber(0); pNumber->setPosition(ccp(m_point.x - i * NUM_WIDTH, m_point.y)); pNumber->setAnchorPoint(ccp(1.0f, 0.5f)); this->addChild(pNumber, 100); } }
void UIRollNum::rebuildEffect(){ int i = 0; int num = m_nNumber; while(1){ if(num <= 0){ if(m_maxCol <= i && zeroFill){ break; } } int showNum = num % 10; UINumber* pNumber = (UINumber*)numArray->objectAtIndex(i); pNumber->setNumber(showNum); i++; num = num / 10; } }