CScale9Sprite* CScale9Sprite::resizableSpriteWithCapInsets(Rect capInsets) { CScale9Sprite* pReturn = new CScale9Sprite(); if ( pReturn && pReturn->initWithBatchNode(_scale9Image, m_spriteRect, capInsets) ) { pReturn->autorelease(); return pReturn; } CC_SAFE_DELETE(pReturn); return NULL; }
CScale9Sprite* CScale9Sprite::create() { CScale9Sprite *pReturn = new CScale9Sprite(); if (pReturn && pReturn->init()) { pReturn->autorelease(); return pReturn; } CC_SAFE_DELETE(pReturn); return NULL; }
CScale9Sprite* CScale9Sprite::createWithTexture(Texture2D* pTexture, Rect capInsets) { CScale9Sprite* pReturn = new CScale9Sprite(); if ( pReturn && pReturn->initWithTexture(pTexture, capInsets) ) { pReturn->autorelease(); return pReturn; } CC_SAFE_DELETE(pReturn); return NULL; }
CScale9Sprite* CScale9Sprite::createWithSpriteFrameName(const char* spriteFrameName, Rect capInsets) { CScale9Sprite* pReturn = new CScale9Sprite(); if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName, capInsets) ) { pReturn->autorelease(); return pReturn; } CC_SAFE_DELETE(pReturn); return NULL; }
CScale9Sprite* CScale9Sprite::createWithSpriteFrame(SpriteFrame* spriteFrame) { CScale9Sprite* pReturn = new CScale9Sprite(); if ( pReturn && pReturn->initWithSpriteFrame(spriteFrame) ) { pReturn->autorelease(); return pReturn; } CC_SAFE_DELETE(pReturn); return NULL; }
CScale9Sprite* CScale9Sprite::create(const char* file) { CScale9Sprite* pReturn = new CScale9Sprite(); if ( pReturn && pReturn->initWithFile(file) ) { pReturn->autorelease(); return pReturn; } CC_SAFE_DELETE(pReturn); return NULL; }
CScale9Sprite* CScale9Sprite::createWithSpriteFrameName(const char* spriteFrameName) { CCAssert(spriteFrameName != NULL, "spriteFrameName must be non-NULL"); CScale9Sprite* pReturn = new CScale9Sprite(); if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName) ) { pReturn->autorelease(); return pReturn; } CC_SAFE_DELETE(pReturn); log("Could not allocate CScale9Sprite()"); return NULL; }
void CButton::setNormalTexture(Texture2D *pTexture) { if( pTexture ) { if( m_pNormalImage ) { if( m_bScale9Enabled ) { CScale9Sprite* pImage = (CScale9Sprite*) m_pNormalImage; pImage->setTexture(pTexture); pImage->setContentSize(_contentSize); } else { Rect rect = Rect::ZERO; rect.size = pTexture->getContentSize(); Sprite* pImage = (Sprite*) m_pNormalImage; pImage->setTexture(pTexture); pImage->setTextureRect(rect); setContentSize(pTexture->getContentSize()); } } else { if( m_bScale9Enabled ) { m_pNormalImage = CScale9Sprite::createWithTexture(pTexture); m_pNormalImage->setContentSize(_contentSize); } else { Rect rect; rect.origin = Point::ZERO; rect.size = pTexture->getContentSize(); m_pNormalImage = Sprite::createWithTexture(pTexture); setContentSize(pTexture->getContentSize()); } m_pNormalImage->setPosition(Point(_contentSize.width/2, _contentSize.height/2)); addChild(m_pNormalImage); } } updateCascadeTextSize(); }
void CButton::setNormalSpriteFrame(SpriteFrame* pFrame) { if( pFrame ) { if( m_pNormalImage ) { if( m_bScale9Enabled ) { CScale9Sprite* pImage = (CScale9Sprite*) m_pNormalImage; pImage->initWithSpriteFrame(pFrame); pImage->setContentSize(_contentSize); } else { Sprite* pImage = (Sprite*) m_pNormalImage; pImage->setSpriteFrame(pFrame); setContentSize(pImage->getContentSize()); } } else { if( m_bScale9Enabled ) { m_pNormalImage = CScale9Sprite::createWithSpriteFrame(pFrame); m_pNormalImage->setContentSize(_contentSize); } else { m_pNormalImage = Sprite::createWithSpriteFrame(pFrame); setContentSize(m_pNormalImage->getContentSize()); } m_pNormalImage->setPosition(Point(_contentSize.width/2, _contentSize.height/2)); addChild(m_pNormalImage); } } updateCascadeTextSize(); }
void CButton::setDisabledSpriteFrame(SpriteFrame* pFrame) { if( pFrame ) { if( m_pDisabledImage ) { if( m_bScale9Enabled ) { CScale9Sprite* pImage = (CScale9Sprite*) m_pDisabledImage; pImage->initWithSpriteFrame(pFrame); pImage->setContentSize(_contentSize); } else { Sprite* pImage = (Sprite*) m_pDisabledImage; pImage->setSpriteFrame(pFrame); } } else { if( m_bScale9Enabled ) { m_pDisabledImage = CScale9Sprite::createWithSpriteFrame(pFrame); m_pDisabledImage->setContentSize(_contentSize); } else { m_pDisabledImage = Sprite::createWithSpriteFrame(pFrame); } m_pDisabledImage->setPosition(Vec2(_contentSize.width/2, _contentSize.height/2)); m_pDisabledImage->setVisible(false); addChild(m_pDisabledImage); } } updateCascadeTextSize(); }