CCTableGridCell* CCTableGridBackPackTest::tableviewDataSource(CCTableGrid* pTable, CCTableGridCell* pCell, unsigned int idx) { CCButton* pIconButton = NULL; if(!pCell) { pCell = new CCTableGridCell(); pCell->autorelease(); CC9Sprite* pBg = CC9Sprite::create("sprite9_btn1.png"); pBg->setContentSize(CCSize(70, 70)); pBg->setPosition(ccp(320 / 4 / 2, 390 / 5 / 2)); pCell->addChild(pBg); pIconButton = CCButton::create("icon.png"); pIconButton->setLongClickSelector(this, longclick_selector(CCTableGridBackPackTest::onItemLongClick)); pIconButton->getTextTTF()->setFontSize(25); pIconButton->setPosition(ccp(320 / 4 / 2, 390 / 5 / 2)); pIconButton->setTextOffset(ccp(-15, -15)); pIconButton->setTag(1); pCell->addChild(pIconButton); } else { pIconButton = (CCButton*) pCell->getChildByTag(1); } if( idx != CC_INVALID_INDEX ) { pIconButton->setVisible(true); pIconButton->getTextTTF()->setString(m_vData[idx].c_str()); pIconButton->setUserTag(idx); } else { pIconButton->setVisible(false); } return pCell; }
CCTableGridCell* CCTableGridBasicTest::tableviewDataSource(CCTableGrid* pTable, CCTableGridCell* pCell, unsigned int idx) { CCButton* pButton = NULL; if(!pCell) { pCell = new CCTableGridCell(); pCell->autorelease(); pButton = CCButton::createWith9Sprite(CCSizeMake(70, 70), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(ccp(320 / 4 / 2, 390 / 5 / 2)); pButton->getTextTTF()->setFontSize(25.0f); pButton->setTag(1); pCell->addChild(pButton); } else { pButton = (CCButton*) pCell->getChildByTag(1); } if( idx != CC_INVALID_INDEX ) { pButton->setVisible(true); char buff[64]; sprintf(buff, "%u", idx); pButton->getTextTTF()->setString(buff); pButton->setUserTag(idx); } else { pButton->setVisible(false); } return pCell; }
bool CCButton9SpriteTest::init() { CCButtonTestSceneBase::init(); setTitle("CCButtonAttributeTest"); setDescription("9PatchSprite by create"); CCButton* pButton = CCButton::createWith9Sprite(CCSize(196, 68),"sprite9_btn1.png", "sprite9_btn2.png"); pButton->getTextTTF()->initWithString("one", "", 30.0f); pButton->setPosition(ccp(480, 370)); m_pLayout->addChild(pButton); CCButton* pButton2 = CCButton::create(); pButton2->setContentSize(CCSize(196, 68)); pButton2->set9SpriteEnabled(true); pButton2->setNormalImage("sprite9_btn1.png"); pButton2->setSelectedImage("sprite9_btn2.png"); pButton2->getTextTTF()->initWithString("two", "", 30.0f); pButton2->setPosition(ccp(480, 270)); m_pLayout->addChild(pButton2); return true; }