本文整理汇总了C++中CCControlButton类的典型用法代码示例。如果您正苦于以下问题:C++ CCControlButton类的具体用法?C++ CCControlButton怎么用?C++ CCControlButton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCControlButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CCControlButton
CCControlButton* CCControlButton::create(CCNode* label, CCScale9Sprite* backgroundSprite)
{
CCControlButton *pRet = new CCControlButton();
pRet->initWithLabelAndBackgroundSprite(label, backgroundSprite);
CC_SAFE_AUTORELEASE(pRet);
return pRet;
}
示例2: expandAvatars
void FMMapAvatarNode::clickAvatarBtn(cocos2d::CCObject *object, CCControlEvent event)
{
FMSound::playEffect("click.mp3", 0.1f, 0.1f);
int t = 1;
if (m_includeSelf) {
t--;
}
if (!m_isExpand && m_avatarList->count() > t) {
expandAvatars(true);
}else{
FMDataManager* manager = FMDataManager::sharedManager();
expandAvatars(false);
CCControlButton * button = (CCControlButton *)object;
int index = button->getParent()->getTag();
if (m_dicList) {
if (index < m_dicList->count()) {
FMUIFriendProfile * window = (FMUIFriendProfile *)manager->getUI(kUI_FriendProfile);
GAMEUI_Scene::uiSystem()->nextWindow(window);
CCDictionary * dic = (CCDictionary *)m_dicList->objectAtIndex(index);
window->setProfile(dic);
}
}
}
}
示例3: if
void HRootLayer::updateAndAdjust(CCNode *node, float scaleX, float scaleY) {
CCArray *children = node->getChildren();
if (children) {
for (int i = children->count() - 1; i >= 0; --i) {
CCNode *child = (CCNode *)children->objectAtIndex(i);
if (dynamic_cast<CCLabelTTF *>(child)) {
CCLabelTTF *label = (CCLabelTTF *)child;
label->setString(HLocalizedString(label->getString()));
} else if (dynamic_cast<CCEditBox *>(child)) {
// CCEditBox *editBox = (CCEditBox *)child;
// editBox->setScaleX(scaleX);
// editBox->setScaleY(scaleY);
} else if (dynamic_cast<CCControlButton *>(child)) {
CCControlButton *button = (CCControlButton *)child;
CCString *title = button->getTitleForState(CCControlStateNormal);
button->setTitleForState(CCString::create(HLocalizedString(title->getCString())), CCControlStateNormal);
} else if (dynamic_cast<CCScrollView *>(child)) {
// CCScrollView *scrollview = (CCScrollView *)child;
// scrollview->setScaleX(scaleX);
// scrollview->setScaleY(scaleY);
updateAndAdjust(child, scaleX, scaleY);
} else {
updateAndAdjust(child, scaleX, scaleY);
}
}
}
}
示例4: toolBarTouchDownAction
void AddFriendScene::toolBarTouchDownAction(CCObject *pSender, CCControlEvent pCCControlEvent) {
CCControlButton *button = (CCControlButton *)pSender;
if (pCCControlEvent==CCControlEventTouchDown)
{
btnTouched = true;
}
else if (pCCControlEvent==CCControlEventTouchUpInside)
{
switch (button->getTag()) {
case 128:
{
btnTouched = false;
MainGameScene *mainScene = (MainGameScene *)this->getParent();
mainScene->PushLayer((CCLayer *)this->GetLayer("NewMailScene"));
}
break;
case 129:
{
btnTouched = false;
CCMessageDialog *box = CCMessageDialog::create();
box->setTitle(GlobalData::getLocalString("friend_add_confirm")->getCString());
box->setDelegate(this);
this->addChild(box);
}
break;
default:
break;
}
}
}
示例5: init
bool GeneralDialogTest::init()
{
if (CCLayer::init())
{
//正常状态按钮
CCScale9Sprite *backgroundButton = CCScale9Sprite::create("button.png");
//按下效果
CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create("buttonHighlighted.png");
//按钮的大小根据标题变化
CCLabelTTF *titleButton = CCLabelTTF::create("Touch Me!", "Marker Felt", 30);
//按钮颜色
titleButton->setColor(ccc3(159, 168, 176));
CCControlButton* controlButton = CCControlButton::create(titleButton, backgroundButton);
controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted);
controlButton->setTitleColorForState(ccWHITE, CCControlStateHighlighted);
// controlButton->setAnchorPoint(ccp(0.5f, 1));
controlButton->setPosition(ccp(640/2, 960/5));
addChild(controlButton);
/* 当鼠标处于按下并曾经点中按钮的状态下,鼠标松开且在按钮范围内,则触发一次 */
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(GeneralDialogTest::touchUpInside), CCControlEventTouchUpInside);
return true;
}
return false;
}
示例6: CCControlButton
CCControlButton* CCControlButton::create(string title, const char * fontName, float fontSize)
{
CCControlButton *pRet = new CCControlButton();
pRet->initWithTitleAndFontNameAndFontSize(title, fontName, fontSize);
pRet->autorelease();
return pRet;
}
示例7: CCTableViewCell
CCTableViewCell* RPGMapItemsMenuLayer::tableCellAtIndex(CCTableView *tableView, unsigned int idx)
{
CCTableViewCell *cell = tableView->dequeueCell();
if (!cell)
{
cell = new CCTableViewCell();
cell->autorelease();
}
else
cell->removeAllChildrenWithCleanup(true);
float x = 100;
for (int i = 0; i < 4; i++)
{
int index = idx * 4 + i;
if(index >= this->m_itemsList->count())
break;
RPGExistingItems *itemsData = (RPGExistingItems*)this->m_itemsList->objectAtIndex(index);
CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_total)->getCString(), "Arial", 22);
itemBtn->setPosition(ccp(x, 0));
itemBtn->setTag(itemsData->m_dataId);
itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGMapItemsMenuLayer::onButton), CCControlEventTouchUpInside);
cell->addChild(itemBtn);
x += 200;
}
return cell;
}
示例8: menuCloseCallBack
//根据按钮跳转到相应的场景中
void MenuScene::menuCloseCallBack(CCObject* pSender)
{
//点击音效
SimpleAudioEngine::sharedEngine()->playEffect("ZF_Shoot_Effects_touchButton.wav");
CCControlButton* button = (CCControlButton*)pSender;
CCTransitionFade* transition;
switch (button->getTag()) {
case 1:
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
transition = CCTransitionFade::create(0.2, Popularize::scene());
CCDirector::sharedDirector()->pushScene(transition);
#endif
break;
case 2:
{
MallMarkets* mallMarketsLayer = MallMarkets::create();
mallMarketsLayer->setPosition(CCPointZero);
this->addChild(mallMarketsLayer,4);
this->setMenuButtonTouchFasle();
break;
}
case 4:
break;
case 6:
break;
}
}
示例9: selected
void QimiAlipayView::selected(cocos2d::CCNode* pSender, cocos2d::extension::CCControlEvent* pCCControlEvent)
{
CCControlButton* btn = dynamic_cast<CCControlButton*>(pSender);
int pay = btn->getTag();
CCLog("%d", pay);
upDataView(pay);
upSelectState(btn);
}
示例10: menu_selector
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback));
pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
origin.y + pCloseItem->getContentSize().height/2));
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1);
/////////////////////////////
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
// position the label on the center of the screen
pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - pLabel->getContentSize().height));
// add the label as a child to this layer
this->addChild(pLabel, 1);
CCRect rect1(133, 333, 42, 46);
CCScale9Sprite* btnNormal = CCScale9Sprite::create("char_bluelight.png",rect1);
CCScale9Sprite* btnDown = CCScale9Sprite::create("char_bluelight.png",rect1);
CCControlButton* controlBtn = CCControlButton::create(btnNormal);
controlBtn->setBackgroundSpriteForState(btnDown, CCControlStateSelected);
controlBtn->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
controlBtn->setPreferredSize(CCSize(60, 50));
controlBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDownAction), CCControlEventTouchDown);
this->addChild(controlBtn);
return true;
}
示例11: init
bool ParticleTest::init(){
CCControlButton *btn = CCControlButton::create("particle ", "Arial", 24);
btn->setPosition(ccp(320, 1000));
this->addChild(btn);
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(ParticleTest::btnClick), CCControlEventTouchDown);
return true;
}
示例12: createRootButton
CCControlButton* PluginLayerContent::createRootButton( const char* btnTitle, int btnTag )
{
CCControlButton* ctrlBtn = nl::ControlUtils::createButton(btnTitle);
ctrlBtn->setTag(btnTag);
ctrlBtn->addTargetWithActionForControlEvents(
this,
cccontrol_selector(PluginLayerContent::onUIAction),
CCControlEventTouchUpInside);
return ctrlBtn;
}
示例13: jumpBtn
void guankaScene::jumpBtn() {
CCSize screenSize = CCDirector::sharedDirector()->getVisibleSize();
CCLabelTTF* jumptext = CCLabelTTF::create("Jump!!", "Arial", 40);
CCScale9Sprite* noDownbtn = CCScale9Sprite::create("button.png");
CCScale9Sprite* downbtn = CCScale9Sprite::create("buttonDown.png");
CCControlButton* Btnjump = CCControlButton::create(jumptext, noDownbtn);
Btnjump->setPosition(ccp(screenSize.width-80, 50));
Btnjump->setBackgroundSpriteForState(downbtn, extension::CCControlStateHighlighted);
Btnjump->addTargetWithActionForControlEvents(this, cccontrol_selector(guankaScene::jumpEvent),CCControlEventTouchDown);
this->addChild(Btnjump,1);
}
示例14: addTouchEventListener
void IBBTouchElement::addTouchEventListener(cocos2d::CCNode *target)
{
if(!target) return;
if(m_touchListeners->containsObject(target)) return;
//如果目标是一个ControlButton, 则关闭它自己的touch处理机制
CCControlButton* b = dynamic_cast<CCControlButton*>(target);
if(b)
{
b->setTouchEnabled(false);
}
m_touchListeners->addObject(target);
};
示例15: atoi
void QimiAlipayView::changePrie()
{
std::string p = m_pEditName->getText();
int price = atoi(p.c_str());
for (int i =0; i < m_pButtonList->count() ; i++) {
CCControlButton* b = dynamic_cast<CCControlButton*>(m_pButtonList->objectAtIndex(i));
b->setEnabled(true);
}
CCControlButton* btn = dynamic_cast<CCControlButton*>(this->getChildByTag(100)->getChildByTag(price));
if (btn!=NULL)
{
btn->setEnabled(false);
}
upDataView(price);
}