UIButton* UIButton::createWithPngNames(const char *upName,const char *downName,const char *moveName,const char *text,float fontSize) { UIButton *node = new UIButton(); if (node) { node->_up = CCSprite::create(upName); node->_down = CCSprite::create(downName); node->_move = CCSprite::create(moveName); node->_textLabel = CCLabelTTF::create(text, "Arial", fontSize); if (node->_up && node->_down && node->_move) { node->addChild(node->_up); node->addChild(node->_down ); node->addChild(node->_move); node->addChild(node->_textLabel); node->_up->setVisible(true); node->_down->setVisible(false); node->_move->setVisible(false); node->autorelease(); return node; } } CC_SAFE_DELETE(node); return NULL; }
NS_CC_BEGIN /** * 创建 */ UIButton* UIButton::create(const char *upSprite,const char *downSprite) { UIButton *node = new UIButton(); if (node) { node->_up = CCSprite::create(upSprite); node->_down = CCSprite::create(downSprite); node->upPngName = upSprite; node->downPngName = downSprite; if (node->_up && node->_down) { node->addChild(node->_up); node->addChild(node->_down ); node->_up->setVisible(true); node->_down->setVisible(false); node->autorelease(); return node; } } CC_SAFE_DELETE(node); return NULL; }