本文整理汇总了C++中CCMenuItemSprite类的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemSprite类的具体用法?C++ CCMenuItemSprite怎么用?C++ CCMenuItemSprite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCMenuItemSprite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addChild
bool testEffect::init(){
if ( !CCLayer::init() ){return false;}
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("0.GeneralPart.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("MikuFight.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("SheldonFight.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("IronManFight.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("LichKingFight.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("BladeMasterFight.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("FightGeneral.plist");
ASBotFightLayer* aaa = ASBotFightLayer::createAsFightLayer(2, 4,true,1000,1,10000,6,10000,10);
aaa->setPosition(CCPointZero);
addChild(aaa,9999,9999);
CCMenu* menu = CCMenu::create();
for (int i = 1; i < 7 ; i++) {
string tmp = "card_" + int2string(i) + ".png";
CCSprite* repeatSprite = CCSprite::createWithSpriteFrameName(tmp.c_str());
CCMenuItemSprite* repeat = CCMenuItemSprite::create(repeatSprite,repeatSprite,this,menu_selector(testEffect::Repeat));
repeat->setScale(0.45);
repeat->setPosition(ccp(size.width/7 + size.width*(i-1)/7,size.height/8));
repeat->setTag(i);
menu->addChild(repeat);
}
menu->setPosition(CCPointZero);
addChild(menu,10000);
return true;
}
示例2: CCMenuItemSprite
CCMenuItemSprite * CCMenuItemSprite::itemFromNormalSprite(CCNode *normalSprite, CCNode *selectedSprite, CCNode *disabledSprite, SelectorProtocol *target, SEL_MenuHandler selector)
{
CCMenuItemSprite *pRet = new CCMenuItemSprite();
pRet->initFromNormalSprite(normalSprite, selectedSprite, disabledSprite, target, selector);
pRet->autorelease();
return pRet;
}
示例3: loadUI
void BYGameScene::loadUI() {
CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
frameCache->addSpriteFramesWithFile("ui.plist", "ui.png");
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
/// pause button
CCSprite* btnNormalSprite = CCSprite::createWithSpriteFrameName("pause.png");
CCMenuItemSprite *pauseMenuItem = CCMenuItemSprite::create(btnNormalSprite,
btnNormalSprite,
this,
menu_selector(BYGameScene::pauseButtonHandler));
/// 2 labels for goals
ccColor3B color = ccc3(220, 70, 20); /// red color
_labelBotPlayerGoalsScored = CCLabelTTF::create("0", "Marker Felt", 40);
_labelBotPlayerGoalsScored->setColor(color);
CCMenuItemLabel *labelBot = CCMenuItemLabel::create(_labelBotPlayerGoalsScored, NULL, NULL);
labelBot->setEnabled(false);
_labelTopPlayerGoalsScored = CCLabelTTF::create("0", "Marker Felt", 40);
_labelTopPlayerGoalsScored->setColor(color);
CCMenuItemLabel *labelTop = CCMenuItemLabel::create(_labelTopPlayerGoalsScored, NULL, NULL);
labelTop->setEnabled(false);
/// CCMenu doesnt support anchorPoint as of 0x00020003 version
CCMenu *menu = CCMenu::create(labelTop, pauseMenuItem, labelBot, NULL);
menu->alignItemsHorizontallyWithPadding(5);
menu->setAnchorPoint(CCPointMake(0, 0));
menu->setPosition(CCPointMake(winSize.width - pauseMenuItem->getContentSize().width / 2,
winSize.height / 2));
menu->setRotation(90);
this->addChild(menu);
}
示例4: showBuyCoin
void PrepareLayer::showBuyCoin()
{
CCSize size = ToolsFun::sharedTools()->getSceneSize();
CCSprite *bkg = CCSprite::create("DayReward/bkg.png");
this->addChild(bkg,200,12313154);
bkg->setPosition(ccp(size.width/2,size.height/2));
CCSprite *tip1 = CCSprite::create("DayReward/50000coin.png");
bkg->addChild(tip1);
tip1->setPosition(ccp(bkg->getContentSize().width/2,bkg->getContentSize().height/2-50*gScaleY));
CCMenu *menu = CCMenu::create();
bkg->addChild(menu);
menu->setPosition(CCPointZero);
CCSprite *closeNml = CCSprite::create("ui/backUI/close0.png");
CCSprite *closeSel = CCSprite::create("ui/backUI/close0.png");
closeSel->setColor(ccc3(80,80,80));
CCMenuItemSprite *itemClose = CCMenuItemSprite::create(closeNml,closeSel,NULL,this,menu_selector(PrepareLayer::showBuyCoinClose));
itemClose->setPosition(ccp(bkg->getContentSize().width-40*gScaleX ,bkg->getContentSize().height-60*gScaleY));
menu->addChild(itemClose);
CCSprite *spNml = CCSprite::create("DayReward/button.png");
CCSprite *spSel = CCSprite::create("DayReward/button.png");
spSel->setColor(ccc3(80,80,80));
CCMenuItemSprite *itemSp = CCMenuItemSprite::create(spNml,spSel,this,menu_selector(PrepareLayer::showBuyCoinSure));
itemSp->setPosition(ccp(bkg->getContentSize().width/2 ,35*gScaleY));
menu->addChild(itemSp);
}
示例5: CanleCallback
void CStoreLayer::CanleCallback( CCObject* pSender )
{
CCMenuItemSprite* pItem = ( CCMenuItemSprite* )pSender;
switch ( pItem->getTag() )
{
case TOWRMBTAG:
{
CallJni::forGet1Goal();
}
break;
case FOURRMBTAG:
{
CallJni::forGet5Goal();
}
break;
case SIXRMBTAG:
{
CallJni::forGet10Goal();
}
break;
case CANLETAG:
this->removeFromParent();
break;
default:
break;
}
}
示例6: addChild
void RankScene::BasicUIDraw(){
//1.背景
CCSprite* bg = CCSprite::createWithSpriteFrameName("bg_l.png");
bg->setPosition(ccp(winSize.width/2, winSize.height/2));
addChild(bg,0);
//2.翻转层
layerToRoll = CCLayer::create();
addChild(layerToRoll,1);
//3.金币部分
CCSprite* heartTable = CCSprite::createWithSpriteFrameName("HeartTable.png");
heartTable->setScaleX(0.5);
heartTable->setScaleY(0.417);
heartTable->setPosition(ccp(size.width*7.75/30,size.height*2100/2200+winDif*4*(2-alpha)));
addChild(heartTable,9999);
CCSprite* goldTable = CCSprite::createWithSpriteFrameName("GoldTable.png");
goldTable->setScale(0.417);
goldTable->setPosition(ccp(size.width*21.75/30,size.height*2100/2200+winDif*4*(2-alpha)));
addChild(goldTable,9999);
CCLabelTTF* goldNumber = CCLabelTTF::create(int2string(MainUser->gold).c_str(), "Arial Rounded MT bold",28,CCSizeMake(size.width/3, 0),kCCTextAlignmentRight);
goldNumber->setPosition(ccp(size.width*45.5/70, size.height*2100/2200+winDif*4*(2-alpha)));
addChild(goldNumber,10000,8);
CCSprite* buyGoldButtonSprite = CCSprite::createWithSpriteFrameName("buyGoldButton.png");
CCSprite* buyGoldButtonSprite_s = CCSprite::createWithSpriteFrameName("buyGoldButton-s.png");
CCMenuItemSprite* buyGoldButton = CCMenuItemSprite::create(buyGoldButtonSprite,buyGoldButtonSprite_s,this,menu_selector(RankScene::showShopLayer));
buyGoldButton->setPosition(ccp(size.width*60/70,size.height*2100/2200+winDif*4*(2-alpha)));
CCMenu* buyGoldMenu = CCMenu::create(buyGoldButton,NULL);
buyGoldMenu->setPosition(CCPointZero);
addChild(buyGoldMenu,10000,17);
}
示例7: CCARRAY_FOREACH
void SlidingMenuGrid::buildGrid(int cols, int rows)
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
int col = 0, row = 0;
CCArray* child = pMenu->getChildren();
CCObject* item;
CCPoint position=getPosition();
iPageCount=0;
CCARRAY_FOREACH(child, item)
{
CCMenuItemSprite* getItem = (CCMenuItemSprite*) item;
getItem->setPosition(ccp(position.x + menuOrigin.x + col * padding.x + (iPageCount * winSize.width), position.y +(winSize.height-menuOrigin.y)- row * padding.y));
++col;
if (col == cols)
{
col = 0;
++row;
if( row == rows )
{
iPageCount++;
col = 0;
row = 0;
}
}
}
示例8: unschedule
void GameLotteryLayer::onBtnRewardCallback(CCObject* pSender)
{
if (m_bTempSoundOn)
{
SoundPlayer::play(SNDI_CLICK);
}
unschedule(schedule_selector(GameLotteryLayer::removeHint));
enableBtns();
// delete hint
CCMenuItemSprite* item = static_cast<CCMenuItemSprite*> (pSender);
unRegisterMenuItem(item);
item->runAction(CCSequence::create(
CCCallFunc::create(item, callfunc_selector(CCMenuItemSprite::removeFromParent)),
NULL));
m_ptrMenuHint = NULL;
// reset circle
m_ptrCircle->setRotation(0.0f);
// delete the highLight
CCNode* ptrLight = m_ptrCircle->getChildByTag(LIGHT_TAG);
if(ptrLight)
{
ptrLight->removeFromParent();
}
chargeNewDay();
}
示例9: ccp
void MyBuildingCard::displayDetail(cocos2d::CCNode *psender){
MyBuildingCard* card = (MyBuildingCard*)psender->getParent()->getParent();
activeCard = card;
oriPosition = card->getPosition();
card->runAction(CCEaseInOut::create(CCMoveTo::create(0.2, ccp(200-card->getParent()->getPosition().x,320)),2));
card->runAction(CCEaseInOut::create(CCScaleTo::create(0.2, 1.2),2));
card->isEnabled = false;
((GXScrollView*)(card->getParent()))->setEnabled(false);
card->getParent()->reorderChild(card, 100000);
CCMenuItemSprite* gray = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("dialoggray.png"), CCSprite::createWithSpriteFrameName("dialoggray.png"));
MyPriorityMenu* grayMenu = MyPriorityMenu::create(-503,gray,NULL);
grayMenu->setTag(grayTag);
card->getParent()->addChild(grayMenu,99999);
gray->setScaleX(960/gray->getContentSize().width);
gray->setScaleY(540/gray->getContentSize().height);
grayMenu->setPosition(ccp(480-card->getParent()->getPosition().x,320));
// gray->setPosition(ccp(0,0));
CCSprite* detailBack = CCSprite::createWithSpriteFrameName("creatoruidetail.jpg"); detailBack->setPosition(ccp(634-card->getParent()->getPosition().x,-detailBack->getContentSize().height/2-100));
detailBack->setScale(1.2);
detailBack->setTag(detailBackTag);
card->getParent()->addChild(detailBack,100000);
detailBack->runAction(CCSequence::create(CCDelayTime::create(0.2),CCEaseInOut::create(CCMoveTo::create(0.2, ccp(634-card->getParent()->getPosition().x,320)),2), NULL));
CCMenuItemFont::setFontSize(24);
CCMenuItemFont* back = CCMenuItemFont::create("返回",this,menu_selector(MyBuildingCard::cancelDetail));
back->setColor(ccc3(114,66,45));
MyPriorityMenu* backMenu = MyPriorityMenu::create(-503,back,NULL);
backMenu->setPosition(ccp(detailBack->getContentSize().width-44,44));
detailBack->addChild(backMenu,NULL);
}
示例10: menu_selector
bool PanelLayer::init()
{
if (CCLayer::init()) {
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
_goldCounterLayer = GoldCounterLayer::create();
this->addChild(_goldCounterLayer);
ScheduleCountDown *scheduleCountDown = ScheduleCountDown::create(this);
_scheduleLabel = CCLabelTTF::create("60", "Thonburi", 16);
_scheduleLabel->addChild(scheduleCountDown);
this->addChild(_scheduleLabel);
CCMenuItemSprite *pause = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName(STATIC_DATA_STRING("pause_normal")), CCSprite::createWithSpriteFrameName(STATIC_DATA_STRING("pause_selected")), this, menu_selector(PanelLayer::pause));
CCMenu *menu = CCMenu::create(pause, NULL);
this->addChild(menu);
_goldCounterLayer->setPosition(CCPointMake(winSize.width*0.05f, winSize.height*0.05f));
_scheduleLabel->setPosition(CCPointMake(winSize.width*0.3f, winSize.height*0.05f));
CCSize pauseSize = pause->getContentSize();
menu->setPosition(CCPointMake(winSize.width-pauseSize.width*0.5f, pauseSize.height*0.5f));
return true;
}
return false;
}
示例11: menu_selector
void NewsScene::createListView()
{
// CCSize size = CCSize(750, 400);
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCLayerColor * fundo = CCLayerColor::create(ccc4(255, 255, 255, 255), size.width, size.height);
fundo->setAnchorPoint(ccp(0,0));
fundo->setPosition(ccp(0, 0));
this->addChild(fundo,10);
// CCLayerColor * header = CCLayerColor::create(ccc4(200, 200, 200, 255), size.width, 80);
// header->setAnchorPoint(ccp(0,0));
// header->setPosition(ccp(0, size.height -80));
// fundo->addChild(header);
CCSprite *sprHeader;
sprHeader = CCSprite::create("Header_Blue.png");
sprHeader->setAnchorPoint(ccp(0,0));
sprHeader->setScale(1);
sprHeader->setPosition(ccp(0, size.height -90));
this->addChild(sprHeader,100);
CCSprite *sprTitle;
sprTitle = CCSprite::create("tit_informacoes.png");
sprTitle->setAnchorPoint(ccp(0,0));
sprTitle->setScale(1);
sprTitle->setPosition(ccp(110, size.height -50));
this->addChild(sprTitle,101);
CCMenu* menu = CCMenu::create();
CCSprite *spriteDefault = CCSprite::create("Seta1.png");
CCSprite *spriteSelected = CCSprite::create("Seta2.png");
CCMenuItemSprite *item = CCMenuItemSprite::create(spriteDefault, spriteSelected, this, menu_selector(NewsScene::btnBack));
item->setAnchorPoint(ccp(0, 0));
item->setPosition(ccp(0, size.height -90));
menu->addChild(item, 0, 100);
menu->setPosition(ccp(10,30));
menu->setAnchorPoint(ccp(0,0));
this->addChild(menu,102);
list = CCListView::create(CCListViewModeVertical);
list = cocos2d::extension::CCListView::create(CCListViewModeVertical);
list->setDelegate(this);
list->setContentSize(CCSize(size.width, size.height-70));
list->setAnchorPoint(ccp(0,0));
list->setPosition(ccp(0, 0));
list->setColor(ccc3(50, 50, 50));
list->setSeparatorStyle(CCListViewCellSeparatorStyleNone);
fundo->addChild(list);
this->loading = new AnimatedSprite("loader_einstein1.png");
this->loading->addAnimation(AnimatedSprite::animationWithFile("loader_einstein", 24, 0.030f), "anim");//frame_count
this->addChild(this->loading,999);
this->loading->runAnimation("anim",true, true);
this->loading->setAnchorPoint(ccp(0.5f, 0.5f));
this->loading->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width/2, CCDirector::sharedDirector()->getWinSize().height/2 - 30));
this->loading->setVisible(true);
}
示例12: CCMenuItemSprite
CCMenuItemSprite * CCMenuItemSprite::create(CCNode *normalSprite, CCNode *selectedSprite, CCNode *disabledSprite, CCObject *target, SEL_MenuHandler selector)
{
CCMenuItemSprite *pRet = new CCMenuItemSprite();
pRet->initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, target, selector);
pRet->autorelease();
return pRet;
}
示例13: addChild
void GameScene::touchPauseCallBack(CCObject* obj) {
if (isGameOver) {
return;
}
CCDirector::sharedDirector()->pause();
NoTouchLayer* n = NoTouchLayer::create();
addChild(n, 10, TAG_NO_LAYER);
CCSprite* mask = CCSprite::createWithSpriteFrameName("mask.png");
mask->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.5f));
mask->setScaleX(screenSize.width / mask->getContentSize().width * 1.5f);
mask->setScaleY(screenSize.height / mask->getContentSize().height * 1.5f);
addChild(mask, 10, TAG_MASK);
CCSprite* pause = CCSprite::createWithSpriteFrameName("pause.png");
pause->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.68f));
pause->setScale(1.5f);
addChild(pause, 10, TAG_TITLE);
CCMenuItemSprite* item = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("resume.png"), NULL, this, menu_selector(GameScene::pauseResume));
item->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.3f));
CCMenu* menu = CCMenu::create(item, NULL);
menu->setPosition(CCPointZero);
menu->setTouchPriority(-200000);
addChild(menu, 10, TAG_RESUME);
}
示例14: quirkButtonTapped
void CCLayerParent::quirkButtonTapped(CCObject* obj) {
//CCLog("Quirk button tapped!");
CCMenuItemSprite * item = ( CCMenuItemSprite * )obj;
int index = item->getTag();
CCLog("%d button tapped!",index);
if(!decks[index].cooldown) return;
PlayerComponent* humanPlayer = _humanPlayer->player();
if(!_playerSystem->handleEconomic(humanPlayer,&decks[index])) return;
if(decks[index].cooldown)
{
decks[index].cooldown = false;
decks[index].potentio->setValue(0.1f);
decks[index].potentio->setVisible(true);
}
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("spawn.wav");
Entity* entity = _entityFactory->createMonsterWithTeam(MonsterType(index),1);
RenderComponent* render =entity->render();
if (render) {
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
float randomOffset = CCRANDOM_X_Y(-winSize.height * 0.25, winSize.height * 0.25);
render->node->setPosition ( ccp(winSize.width * 0.25, winSize.height * 0.5 + randomOffset));
}
}
示例15: size
CCMenuItemSprite * CCMenuItemDynamic::dynamicItemWithText(const char* text, const char* font, const CCSize &minSize, const char*normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector, const CCRect& centerRegion, GLubyte opacity) {
//Create the label
CCLabelBMFont *label = CCLabelBMFont ::labelWithString(text ,font);
label ->setOpacity(opacity);
//Calculate the Dynamic Button size
float minWidth = label->getContentSize().width>minSize.width?label->getContentSize().width:minSize.width;
float minHeight = label->getContentSize().height>minSize.height?label->getContentSize().height:minSize.height;
CCSize size(minWidth+30,minHeight+24);
label->setPosition(ccp(size.width*0.5f, size.height*0.5f));
//Sprite normal
CCScale9Sprite *normalSprite = CCScale9Sprite::scale9SpriteWithFile(normalImage, centerRegion);
normalSprite ->setContentSize(size);
normalSprite ->setOpacity(opacity);
//Sprite selected
CCScale9Sprite *selectedSprite = NULL;
if(selectedImage){
selectedSprite = CCScale9Sprite::scale9SpriteWithFile(selectedImage, centerRegion);
selectedSprite ->setContentSize(size);
selectedSprite->setOpacity(opacity);
}
//Create the CCMenuItemSprite
CCMenuItemSprite* returnItem = CCMenuItemSprite::itemFromNormalSprite(normalSprite,selectedSprite,target, selector);
returnItem->addChild(label);
return returnItem;
}