本文整理汇总了C++中CCMenu::setTouchPriority方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenu::setTouchPriority方法的具体用法?C++ CCMenu::setTouchPriority怎么用?C++ CCMenu::setTouchPriority使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenu
的用法示例。
在下文中一共展示了CCMenu::setTouchPriority方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setPriority
void HTouchEnabledLayerColor::setPriority(CCNode *node, int priority) {
if (dynamic_cast<CCControl *>(node)) {
CCControl *control = (CCControl *)node;
control->setTouchPriority(priority);
if (control->isTouchEnabled()) {
control->setTouchEnabled(false);
control->setTouchEnabled(true);
}
} else if (dynamic_cast<CCScrollView *>(node)) {
CCScrollView *scrollView = (CCScrollView *)node;
scrollView->setTouchPriority(priority);
if (scrollView->isTouchEnabled()) {
scrollView->setTouchEnabled(false);
scrollView->setTouchEnabled(true);
}
} else if (dynamic_cast<CCMenu *>(node)) {
CCMenu *menu = (CCMenu *)node;
menu->setTouchPriority(priority);
if (menu->isTouchEnabled()) {
menu->setTouchEnabled(false);
menu->setTouchEnabled(true);
}
} else if (dynamic_cast<CCLayer *>(node)) {
CCLayer *layer = (CCLayer *)node;
layer->setTouchPriority(priority);
if (layer->isTouchEnabled()) {
layer->setTouchEnabled(false);
layer->setTouchEnabled(true);
}
}
}
示例2: touchPauseCallBack
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);
}
示例3: init
bool BaseModalLayer::init()
{
if ( !CCLayer::init() )
{
return false;
}
this->setTouchPriority(kModalLayerPriority);
this->setTouchEnabled(true);
this->setTouchMode(kCCTouchesOneByOne);
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCSprite* frame = CCSprite::create("frame.png");
frame->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
this->addChild(frame);
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"tg_close_1.png",
"tg_close_2.png",
this,
menu_selector(BaseModalLayer::menuCloseCallback) );
pCloseItem->setPosition(ccp(
visibleSize.width/2+frame->getContentSize().width/2-pCloseItem->getContentSize().width/2-10,
visibleSize.height/2+frame->getContentSize().height/2-pCloseItem->getContentSize().height/2-10));
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setTouchPriority(kModalLayerMenuPriority);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu);
return true;
}
示例4: makeLabels
void GameClearPopup::makeLabels()
{
//背景
CCSprite* frame = CCSprite::createWithSpriteFrameName(PNG_POPUP_BG2);
frame->setScale(2.5f);
frame->setPosition(GHelper::convI720toCC(g_visibleSize.width / 2, g_visibleSize.height / 2));
this->addChild(frame);
//タイトル
CCString *s = NULL;
if (UserSettings::getSelectedLevel() >= 15) {
s = CCString::create("All Clear!");
} else {
s = CCString::create("You Win!");
}
CCLabelBMFont* title = CCLabelBMFont::create(s->getCString(), FONT_YELLOW);
title->setScale(0.6);
title->setPosition( GHelper::convI720toCC(g_visibleSize.width * 0.5, g_visibleSize.height * 0.3));
this->addChild(title);
//女の子
CCSprite *obj = CCSprite::createWithSpriteFrameName(PNG_MINI2_1);
obj->setPosition(GHelper::convI720toCC(g_visibleSize.width * 0.5, g_visibleSize.height * 0.35));
obj->runAction(Animations::winMiniAnimation());
this->addChild(obj);
//Next Stage?
if (UserSettings::getSelectedLevel() >= 15) {
s = CCString::create("");
} else {
s = CCString::create("Next Stage?");
}
CCLabelBMFont* disc1 = CCLabelBMFont::create(s->getCString(), FONT_GREEN);
disc1->setScale(0.5);
CCMenuItemLabel* item1 = CCMenuItemLabel::create(disc1, this, menu_selector(GameClearPopup::onTapNextStage));
//Again?
CCLabelBMFont* disc2 = CCLabelBMFont::create("Again?", FONT_WHITE);
disc2->setScale(0.5);
CCMenuItemLabel* item2 = CCMenuItemLabel::create(disc2, this, menu_selector(GameClearPopup::onTapAgain));
//Menu
CCLabelBMFont* disc3 = CCLabelBMFont::create("Menu", FONT_WHITE);
disc3->setScale(0.5);
CCMenuItemLabel* item3 = CCMenuItemLabel::create(disc3, this, menu_selector(GameClearPopup::onTapMenu));
//Quit
CCLabelBMFont* disc4 = CCLabelBMFont::create("Quit", FONT_WHITE);
disc4->setScale(0.5);
CCMenuItemLabel* item4 = CCMenuItemLabel::create(disc4, this, menu_selector(GameClearPopup::onTapQuit));
CCMenu* menu = CCMenu::create( item1, item2, item3, item4, NULL );
menu->setTouchPriority(-128);
menu->alignItemsVerticallyWithPadding(1.0);
menu->setPosition(ccp(g_visibleSize.width / 1.5, g_visibleSize.height / 2 - 50));
this->addChild(menu);
}
示例5: init
bool MainMenu::init()
{
if ( !CCLayerColor::initWithColor(ccc4(0, 0, 0, 200)) )
{
return false;
}
CCLabelTTF *title = CCLabelTTF::create("Rabbit Run", FONT_NAME, 70);
title->setPosition(ccp(SCREEN_CX, SCREEN_HEIGHT - 80));
this->addChild(title);
CCMenuItemFont::setFontName(FONT_NAME);
CCMenuItemFont::setFontSize(50);
char* text[] = {"Score", "Power", "Effect",
"+10", "+20%", "--",
"+20", "+40%", "grow up",
"+10", "+0", "lose weight",
"+0", "+0","hiding"};
for(int i = 0; i < 15; i++)
{
CCLabelTTF *label = CCLabelTTF::create(text[i], FONT_NAME, 50);
label->setPosition(ccp(400 + i%3*300, 550 - i/3*85));
this->addChild(label);
}
char* img[] = {"cabbage.png", "carrot.png", "carrot_ice.png", "carrot_sterlth.png"};
for(int i = 0; i < 4; i++)
{
CCSprite *sprite = CCSprite::create(img[i]);
sprite->setScale(0.2f);
sprite->setPosition(ccp(250, 450 - i*80));
this->addChild(sprite);
}
CCMenuItemFont *startGame = CCMenuItemFont::create("Play", this, menu_selector(MainMenu::startGame));
startGame->setColor(ccc3(0, 255,51));
startGame->setPositionX(-90);
CCMenuItemFont *exitGame = CCMenuItemFont::create("Exit", this, menu_selector(MainMenu::exitGame));
exitGame->setColor(ccc3(255, 0, 0));
exitGame->setPositionX(110);
CCMenu *menu = CCMenu::create(startGame, exitGame, NULL);
menu->setPositionY(120);
menu->setTouchPriority(-201);
this->addChild(menu);
CCLabelTTF *powerBy = CCLabelTTF::create("Power by cocos2d-x", FONT_NAME, 50);
powerBy->setAnchorPoint(ccp(1, 0));
powerBy->setPosition(ccp(SCREEN_WIDTH, 0));
this->addChild(powerBy);
this->setTouchPriority(-200);
this->setTouchMode(kCCTouchesOneByOne);
this->setTouchEnabled(true);
return true;
}
示例6: getTouchPriority
CCObject *HTouchEnabledLayerColor::updatePriorityEx(int command, CCNode *node) {
int iBasePriority = getTouchPriority();
if (dynamic_cast<CCControl *>(node)) {
CCControl *control = (CCControl *)node;
int priority = control->getTouchPriority();
priority = iBasePriority - 9;
control->setTouchPriority(priority);
if (control->isTouchEnabled()) {
control->setTouchEnabled(false);
control->setTouchEnabled(true);
}
} else if (dynamic_cast<CCScrollView *>(node)) {
CCScrollView *scrollView = (CCScrollView *)node;
int priority = scrollView->getTouchPriority();
priority = iBasePriority - 11;
scrollView->setTouchPriority(priority);
if (scrollView->isTouchEnabled()) {
scrollView->setTouchEnabled(false);
scrollView->setTouchEnabled(true);
}
} else if (dynamic_cast<CCMenu *>(node)) {
CCMenu *menu = (CCMenu *)node;
int priority = menu->getTouchPriority();
priority = iBasePriority - 128;
menu->setTouchPriority(priority);
if (menu->isTouchEnabled()) {
menu->setTouchEnabled(false);
menu->setTouchEnabled(true);
}
} else if (dynamic_cast<CCLayer *>(node)) {
CCLayer *layer = (CCLayer *)node;
int priority = layer->getTouchPriority();
priority = iBasePriority;
layer->setTouchPriority(priority);
if (layer->isTouchEnabled()) {
layer->setTouchEnabled(false);
layer->setTouchEnabled(true);
}
}
CCArray *children = node->getChildren();
if (children) {
int count = children->count();
for (int i = 0; i < count; ++i) {
CCNode *child = (CCNode *)children->objectAtIndex(i);
updatePriorityEx(command, child);
}
}
return NULL;
}
示例7: initPopup
void Popup::initPopup(float w,
float h,
std::vector<std::string> buttonsImages,
std::vector<std::shared_ptr<Delegate>> callbacks,
const std::string message,
const int textSize,
const std::string images
)
{
if (buttonsImages.size() != callbacks.size())
{
std::cout << "Error for popup initialisation : number of buttons not equal to number of callbacks" << std::endl;
return;
}
this->onquitCallback = 0;
this->nbButtons = buttonsImages.size();
this->width = w;
this->height = h;
this->createBackGround();
//->create the buttons
CCMenu* pMenu ;
for (int i = 0; i< buttonsImages.size() ; i++)
{
if (i==0)
pMenu= CCMenu::create( this->createButton( buttonsImages[i], callbacks [i], i) , NULL);
else
pMenu->addChild(this->createButton( buttonsImages[i], callbacks [i], i));
}
pMenu->setPosition(CCPointZero);
this->addChild(pMenu);
pMenu->setTouchPriority(-201);
//-> add the text
CCLabelTTF* pLabel = CCLabelTTF::create(message.c_str(), "Arial", textSize);
// position the label on the center of the screen
pLabel->setPosition(ccp(0,this->height/4));
// add the label as a child to this layer
this->addChild(pLabel, 1);
}
示例8: initCVarAndCCmd
bool ConsoleCocos2dxLayer::init()
{
if (CCLayer::init())
{
// first we create console view
m_consoleView = ConsoleViewCocos2dx::create();
if (!m_consoleView) return false;
m_consoleView->retain();
// then create console controller
m_consoleController = new ConsoleControllerBase();
if (!m_consoleController->Init())
{
CC_SAFE_DELETE(m_consoleController);
return false;
}
// bind view to controller
m_consoleController->SetView(m_consoleView);
// then we create console menu
CCSize visualSize = CCDirector::sharedDirector()->getVisibleSize();
CCMenuItemImage* consoleButton = CCMenuItemImage::create("Console/Terminal.png", "Console/Terminal.png", this, menu_selector(ConsoleCocos2dxLayer::onConsoleButtonClick));
if (!consoleButton) return false;
consoleButton->setScale(0.45f);
consoleButton->setOpacity(128);
consoleButton->setPosition(ccp(visualSize.width * 0.05f, visualSize.height * 0.88f));
CCMenu* consoleMenu = CCMenu::create(consoleButton, NULL);
consoleMenu->setPosition(ccp(0, 0));
consoleMenu->setTouchPriority(kCCMenuHandlerPriority - 2); // NOTE: pay attention to this
addChild(consoleMenu, 1); // NOTE: should at top
// at last, we init cvars and ccmds
// and that's it :)
return initCVarAndCCmd();
}
return false;
}
示例9: init
bool LayerSetup::init()
{
CCLayer::init();
CCSprite *bg = CCSprite::create("Set_Music.png");
bg->setPosition(ccp(winSize.width / 2, winSize.height / 2));
addChild(bg);
bg->setScale(0.75f);
setTouchMode(kCCTouchesOneByOne);
setTouchEnabled(true);
setTouchPriority(kCCMenuHandlerPriority << 1);
CCMenu *menu = CCMenu::create();
CCSprite *sp1 = CCSprite::create("music_on.png");
CCSprite *sp2 = CCSprite::create("music_off.png");
CCSprite *sp3 = CCSprite::create("sound_effect_on.png");
CCSprite *sp4 = CCSprite::create("sound_effect_off.png");
sp1->setScale(0.9f);
sp2->setScale(0.9f);
sp3->setScale(0.9f);
sp4->setScale(0.9f);
CCMenuItemSprite *_bgON = CCMenuItemSprite::create(sp1, sp1);
CCMenuItemSprite *_bgOFF = CCMenuItemSprite::create(sp2, sp2);
CCMenuItemSprite *_effectON = CCMenuItemSprite::create(sp3, sp3);
CCMenuItemSprite *_effectOFF = CCMenuItemSprite::create(sp4, sp4);
bool isBg = CCUserDefault::sharedUserDefault()->getBoolForKey("BGStatus", true);
bool isEff = CCUserDefault::sharedUserDefault()->getBoolForKey("EffectStatus", true);
isBg ? _bg = CCMenuItemToggle::createWithTarget(this, menu_selector(LayerSetup::setBG), _bgON, _bgOFF, NULL) :
_bg = CCMenuItemToggle::createWithTarget(this, menu_selector(LayerSetup::setBG), _bgOFF, _bgON, NULL);
isEff ? _effect = CCMenuItemToggle::createWithTarget(this, menu_selector(LayerSetup::setEffect), _effectON, _effectOFF, NULL) :
_effect = CCMenuItemToggle::createWithTarget(this, menu_selector(LayerSetup::setEffect), _effectOFF, _effectON, NULL);
CCScale9Sprite *bgButton = CCScale9Sprite::create("button.png");
CCScale9Sprite *bgButtonLighted = CCScale9Sprite::create("buttonHighlighted.png");
CCScale9Sprite *bgButton2 = CCScale9Sprite::create("button.png");
CCScale9Sprite *bgButtonLighted2 = CCScale9Sprite::create("buttonHighlighted.png");
CCLabelTTF * text1 = CCLabelTTF::create("back", "verdana", 20);
CCLabelTTF * text2 = CCLabelTTF::create("home", "verdana", 20);
_back = CCControlButton::create(text1, bgButton);
_home = CCControlButton::create(text2, bgButton2);
_back->setBackgroundSpriteForState(bgButtonLighted, CCControlStateHighlighted);
_back->addTargetWithActionForControlEvents(this,
cccontrol_selector(LayerSetup::backGame),
CCControlEventTouchDown);
_home->setBackgroundSpriteForState(bgButtonLighted2, CCControlStateHighlighted);
_home->addTargetWithActionForControlEvents(this,
cccontrol_selector(LayerSetup::backHome),
CCControlEventTouchDown);
_bg->setPosition(ccp(60, -20));
_effect->setPosition(ccp(60, 40));
_home->setPosition(ccp(winSize.width / 2 - 70, winSize.height / 2 - 70));
_back->setPosition(ccp(winSize.width / 2 + 70, winSize.height / 2 - 70));
menu->setTouchPriority(kCCMenuHandlerPriority << 2);
_home->setTouchPriority(kCCMenuHandlerPriority << 2);
_back->setTouchPriority(kCCMenuHandlerPriority << 2);
menu->addChild(_bg);
menu->addChild(_effect);
addChild(menu);
addChild(_home);
addChild(_back);
return true;
}
示例10: ccp
//创建一个对应的简单的button,代表具体的章
CCLayerColor *SGSpecialBattleLayer::createChapButton(int buttonTag, SpecialBattleData *data)
{
CCLayerColor *layerColor = CCLayerColor::create(ccc4(0, 255, 0, 0), 160, 160);
layerColor->setTag(111);
layerColor->setAnchorPoint(ccp(0.5, 0.5));
if (data)
{
CCSprite *headIcon = SGDrawCards::createPureSprite(data->itemId, data->itemType, sg_specialBattleLayer);
CCSprite *borderIcon = CCSprite::createWithSpriteFrameName("equipPinzhi_5_0.png");
headIcon->addChild(borderIcon, 1);
borderIcon->setPosition(ccpAdd(ccp(headIcon->getContentSize().width / 2, headIcon->getContentSize().height / 2), ccp(0, 0)));
CCSprite *headIcon1 = SGDrawCards::createPureSprite(data->itemId, data->itemType, sg_specialBattleLayer);
CCSprite *borderIcon1 = CCSprite::createWithSpriteFrameName("equipPinzhi_5_0.png");
headIcon1->addChild(borderIcon1, 1);
borderIcon1->setPosition(ccpAdd(ccp(headIcon1->getContentSize().width / 2, headIcon1->getContentSize().height / 2), ccp(0, 0)));
//章节的按钮
SGButton *chapButton = SGButton::createFromSprite(headIcon, headIcon1, this, menu_selector(SGSpecialBattleLayer::enterSpBattleSection));
chapButton->setTag(buttonTag);
//章节的名称 //250 197 68
SGCCLabelTTF *chapNameTTF = SGCCLabelTTF::create(data->chapName.c_str(), FONT_PANGWA, 24);
chapButton->addChild(chapNameTTF, 2);
chapNameTTF->setInsideColor(ccc3(250, 197, 68));
chapNameTTF->setPosition(ccpAdd(ccp(chapNameTTF->getContentSize().width / 2, chapNameTTF->getContentSize().height / 3.5), ccp(0, 0)));
//如果没有开启,蒙灰
if (!data->isOpen)
{
CCSprite *greyMask = CCSprite::createWithSpriteFrameName("sp_battle_entry_mask.png");
greyMask->setOpacity(150);
chapButton->addChild(greyMask, 10);
greyMask->setPosition(ccpAdd(ccp(greyMask->getContentSize().width / 2 - 5, greyMask->getContentSize().height / 2 - 5), ccp(0, 0)));
//未开启,不可用
chapButton->setEnabled(false);
}
CCMenu *menu = CCMenu::create();
menu->setTouchPriority(10);
menu->setPosition(CCPointZero);
menu->addChild(chapButton);
layerColor->addChild(menu);
chapButton->setPosition(ccpAdd(ccp(0, 0), ccp(layerColor->getContentSize().width / 2, layerColor->getContentSize().height / 1.5)));
//显示描述的背景
CCSprite *descBg = CCSprite::createWithSpriteFrameName("sp_battle_infobg.png");
layerColor->addChild(descBg, 1);
descBg->setPosition(ccpAdd(chapButton->getPosition(), ccp(0, -descBg->getContentSize().height / 2 - chapButton->getContentSize().height / 1.7)));
//下方对应的描述
std::string desc;
if (data->isOpen)
{
desc = data->chapOpenDesc;
//如果是开启的,加上光效
ResourceManager::sharedInstance()->bindTexture("animationFile/ms_niubility.plist", RES_TYPE_LAYER_UI, sg_specialBattleLayer);
CCSpriterX *newRewardEffect = CCSpriterX::create("animationFile/ms_niubility.scml", true, true);
layerColor->addChild(newRewardEffect, -1);
newRewardEffect->setanimaID(0);
newRewardEffect->setisloop(true);
newRewardEffect->setScale(1.15);
newRewardEffect->setPosition(ccpAdd(chapButton->getPosition(), ccp(0, 0)));
newRewardEffect->play();
}
else
{
desc = data->chapClosedDesc;
}
SGCCLabelTTF *chapDescTTF = SGCCLabelTTF::create(desc.c_str(), FONT_PANGWA, 21);
descBg->addChild(chapDescTTF, 1);
chapDescTTF->setPosition(ccpAdd(ccp(descBg->getContentSize().width / 2, descBg->getContentSize().height / 2), ccp(0, 0)));
//如果开启状态,显示剩余次数
if (data->isOpen)
{
SGCCLabelTTF *residueTimeTTF = SGCCLabelTTF::create(CCString::createWithFormat(str_SpecailBattleResidueCoint, data->freePlayTimes)->getCString(), FONT_PANGWA, 20);
residueTimeTTF->setInsideColor(ccGREEN);
layerColor->addChild(residueTimeTTF, 1);
residueTimeTTF->setPosition(ccpAdd(descBg->getPosition(), ccp(0, -residueTimeTTF->getContentSize().height * 1.2)));
}
}
else
{
//没有的,直接问号显示
SGButton *chapButton = SGButton::create("sp_battle_unlock.png", "equipPinzhi_5_0.png", this, NULL);
chapButton->setEnabled(false);
layerColor->addChild(chapButton);
chapButton->setPosition(ccpAdd(ccp(0, 0), ccp(layerColor->getContentSize().width / 2, layerColor->getContentSize().height / 1.5)));
//.........这里部分代码省略.........
示例11: zhenping
void LayerLogin::zhenping(){
pSpriteDialogLogin = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("login_input.png"));//CCSprite::create("login_bg_en.png");
pSpriteDialogLogin->setPosition(ccp(winSize.width*0.5,winSize.height *0.5-100));
this->addChild(pSpriteDialogLogin);
CCMenuItemImage* btn_login = CCMenuItemImage::create();
btn_login->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("login_login_1.png"));
btn_login->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("login_login_2.png"));
btn_login->setTarget(this, SEL_MenuHandler(&LayerLogin::menuItemCallbackLogin));
CCMenu *pMenu = CCMenu::create();
pMenu->alignItemsHorizontally();
pMenu->addChild(btn_login);
//pMenu->setPosition(pSpriteDialogLogin->getContentSize().width-75,pSpriteDialogLogin->getContentSize().height/2-10);
pMenu->setPosition(ccp(winSize.width/2-30, winSize.height/2-460));
pMenu->setTouchPriority(1);
pSpriteDialogLogin->addChild(pMenu);
CCScale9Sprite* editbkg = CCScale9Sprite::create();
editBoxUsername = CCEditBox::create(CCSizeMake(210,50),editbkg);
editBoxUsername->setReturnType(kKeyboardReturnTypeDone);
//editBoxUsername->setFontSize(12);
editBoxUsername->setText("");
editBoxUsername->setFontColor(ccc3(158, 122, 83));
editBoxUsername->setMaxLength(8);
editBoxUsername->setPosition(ccp(winSize.width/2-10,96));//160,100
pSpriteDialogLogin->addChild(editBoxUsername,2);
CCScale9Sprite* editbkg1 = CCScale9Sprite::create();
editBoxPassword = CCEditBox::create(CCSizeMake(185, 50),editbkg1);
editBoxPassword->setReturnType(kKeyboardReturnTypeDone);
editBoxPassword->setInputFlag(kEditBoxInputFlagPassword);
editBoxPassword->setFontColor(ccc3(158, 122, 83));
editBoxPassword->setMaxLength(8);
// editBoxPassword->setFontSize(12);
editBoxPassword->setText("");
editBoxPassword->setPosition(ccp(winSize.width/2-17,45));//160,60
pSpriteDialogLogin->addChild(editBoxPassword,2);
// CCSprite* bs = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("login_bs.png"));
// bs->setPosition(ccp(pSpriteDialogLogin->getContentSize().width, 0));
// pSpriteDialogLogin->addChild(bs);
// logo->setAtlasIndex(0);
// CCScene * f = CCDirector::sharedDirector()->getRunningScene();
// CCPoint size =ccp(308, 756);
// CCActionInterval * left1 = CCMoveTo::create(0.05,ccp(size.x+5,size.y));
// CCActionInterval * right1 = CCMoveTo::create(0.05,ccp(size.x-5,size.y));
// CCActionInterval * top1 = CCMoveTo::create(0.05,ccp(size.x,size.y+5));
// CCActionInterval * rom1 = CCMoveTo::create(0.05,ccp(size.x,size.y-5));
// CCFiniteTimeAction* action3 = CCSequence::create(left1,right1,top1,rom1,NULL);
// f->getChildByTag(2807)->getChildByTag(9021)->runAction(CCRepeat::create(action3, 1));
}
示例12: initUI
void HelpLayer::initUI()
{
CCSize size = ToolsFun::sharedTools()->getSceneSize();
//背景
CCSprite * bkg = CCSprite::create("ui/shared/bkg.png");
this->addChild(bkg, -4);
bkg->setPosition(size / 2);
//头部
CCSprite *spBkgTop = CCSprite::create("ui/shared/top.png");
this->addChild(spBkgTop, 0);
spBkgTop->setPosition(ccp(size.width / 2, size.height - spBkgTop->getContentSize().height / 2));
//金币放置最上方商城
CCSprite *coinIcon = CCSprite::create("ui/shared/coin.png");
this->addChild(coinIcon, 2, 1429);
coinIcon->setPosition(ccp(280*gScaleX, size.height - 30*gScaleY));
m_coinLabel = CCLabelBMFont::create("10000000", GOLD_FONT);
this->addChild(m_coinLabel, 4);
m_coinLabel->setAnchorPoint(ccp(0, 0.5f));
m_coinLabel->setPosition(ccp(300*gScaleX, size.height - 25*gScaleY));
m_coinLabel->setScale(0.6F);
setCoin();
CCMenu *menu = CCMenu::create();
this->addChild(menu, 10);
menu->setTouchPriority(-130);
menu->setPosition(CCPointZero);
CCSprite *spNml = CCSprite::create("ui/shared/back.png");
CCSprite *spSel = CCSprite::create("ui/shared/back.png");
spSel->setColor(ccc3(100, 100, 100));
CCMenuItemSprite *spItem = CCMenuItemSprite::create(spNml, spSel, this, menu_selector(HelpLayer::back));
menu->addChild(spItem);
spItem->setPosition(ccp(37*gScaleX, size.height - 37*gScaleY));
//show shop
spNml = CCSprite::create("ui/shared/coinplus.png");
spSel = CCSprite::create("ui/shared/coinplus.png");
spSel->setColor(ccc3(100, 100, 100));
spItem = CCMenuItemSprite::create(spNml, spSel, this, menu_selector(HelpLayer::showShopLayer));
menu->addChild(spItem);
spItem->setPosition(ccp(430*gScaleX, size.height - 30*gScaleY));
//初始化宠物界面
m_menu = CCMenu::create();
m_uiNode->addChild(m_menu, 2);
m_uiNode->setPosition(CCPointZero);
m_menu->setPosition(CCPointZero);
SK::StringKey nameKey[5] = {K.ITEM_NAME0, K.ITEM_NAME1, K.ITEM_NAME2, K.ITEM_NAME3, K.ITEM_NAME4};
SK::StringKey desKey[5] = {K.ITEM_DES0, K.ITEM_DES1, K.ITEM_DES2, K.ITEM_DES3, K.ITEM_DES4};
const char *fileName[5] = {"item/item2_0.png","item/item0_0.png","item/item1_0.png",
"item/item3_0.png","item4_3.png"};
for(int i = 0; i != 5; ++i)
{
CCSprite *petSprite = NULL;
if(i ==4)
{
petSprite = CCSprite::createWithSpriteFrameName(fileName[i]);
}
else
{
petSprite = CCSprite::create(fileName[i]);
}
m_uiNode->addChild(petSprite, 1);
petSprite->setPosition(ccp(120*gScaleX, 130*gScaleY)+ccp(0,180*i));
CCSprite* petDes = CCSprite::create("ui/petUI/pet_describe.png");
m_uiNode->addChild(petDes, 1);
petDes->setPosition(ccp(330*gScaleX, 140*gScaleY)+ccp(0,180*i));
m_desFont[i] = CCLabelBMFont::create(gGetLanguageDesc(desKey[i]).c_str(), "font/item_des.fnt");
m_uiNode->addChild(m_desFont[i], 10);
m_desFont[i]->setPosition(ccp(240*gScaleX, 130*gScaleY)+ccp(0,180*i));
m_desFont[i]->setAnchorPoint(CCPointZero);
m_nameFont[i] = CCLabelBMFont::create(gGetLanguageDesc(nameKey[i]).c_str(), "font/item_des.fnt");
m_uiNode->addChild(m_nameFont[i], 10);
m_nameFont[i]->setPosition(ccp(240*gScaleX, 160*gScaleY)+ccp(0,180*i));
m_nameFont[i]->setAnchorPoint(CCPointZero);
CCLabelBMFont *nameLabel = m_nameFont[i];
nameLabel->setScale(0.6f);
nameLabel->setString(gGetLanguageDesc(nameKey[i]).c_str());
CCLabelBMFont *desLabel = m_desFont[i];
desLabel->setScale(0.6f);
desLabel->setString(gGetLanguageDesc(desKey[i]).c_str());
}
}
示例13: onShow
void ChallengeAgainLayer::onShow(int round, int need)
{
float totalWidth = 0.0;
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCSprite *app1 = CCSprite::create(g_sRelifeBGImage);
app1->setAnchorPoint(ccp(0,0));
app1->setPositionX(30);
app1->setPositionY(s.height*0.5);
this->addChild(app1);
totalWidth += app1->getContentSize().width;
NumberSprite * roundTip = NumberSprite::create("green60",round);
roundTip->setAnchorPoint(ccp(0,0));
roundTip->setPositionX(app1->getPositionX()+app1->getContentSize().width+4);
roundTip->setPositionY(app1->getPositionY());
this->addChild(roundTip);
totalWidth += 4;
totalWidth += roundTip->realWidth;
CCSprite *app2 = CCSprite::create(g_sGuanBGImage);
app2->setAnchorPoint(ccp(0,0));
app2->setPositionX(roundTip->getPositionX()+roundTip->realWidth+4);
app2->setPositionY(roundTip->getPositionY());
this->addChild(app2);
totalWidth += 4;
totalWidth += app2->getContentSize().width;
float bx = (s.width - totalWidth)*0.5;
app1->setPositionX(bx);
roundTip->setPositionX(app1->getPositionX()+app1->getContentSize().width+4);
app2->setPositionX(roundTip->getPositionX()+roundTip->realWidth+4);
CCSprite *app3 = CCSprite::create(g_sLifeNeedBGImage);
app3->setAnchorPoint(ccp(0,0));
app3->setPositionX(app1->getPositionX());
app3->setPositionY(app2->getPositionY()-app2->getContentSize().height-20);
this->addChild(app3);
NumberSprite * needTip = NumberSprite::create("green60",need);
needTip->setAnchorPoint(ccp(0,0));
needTip->setPositionX(app3->getPositionX()+app3->getContentSize().width+4);
needTip->setPositionY(app3->getPositionY());
this->addChild(needTip);
CCSprite *app4 = CCSprite::create(g_sLifeValueBGImage);
app4->setAnchorPoint(ccp(0,0));
app4->setPositionX(needTip->getPositionX()+needTip->realWidth+4);
app4->setPositionY(needTip->getPositionY());
this->addChild(app4);
CCMenuItemImage* pSureMenu = CCMenuItemImage::create(
g_sSureBGImage,
g_sSureBGImage,
this,
menu_selector(ChallengeAgainLayer::onCommandSure));
pSureMenu->setAnchorPoint(ccp(0,0));
CCMenu* pMenu = CCMenu::create(pSureMenu, NULL);
this->addChild(pMenu);
pMenu->setTouchPriority(-1000);
pMenu->setAnchorPoint(ccp(0,0));
pMenu->setPositionY(app4->getPositionY()-app4->getTextureRect().size.height-40);
pMenu->setPositionX(100);
CCSprite * img = CCSprite::create(g_sReturnBGImage);
CCMenuItemImage* pReturnMenu = CCMenuItemImage::create(
g_sReturnBGImage,
g_sReturnBGImage,
this,
menu_selector(ChallengeAgainLayer::onCommandReturn));
pReturnMenu->setAnchorPoint(ccp(0,0));
CCMenu* pMenu2 = CCMenu::create(pReturnMenu, NULL);
this->addChild(pMenu2);
pMenu2->setTouchPriority(-1000);
pMenu2->setAnchorPoint(ccp(0,0));
pMenu2->setPositionY(pMenu->getPositionY());
pMenu2->setPositionX(s.width-img->getTextureRect().size.width-100);
}
示例14: showItemsNode
//.........这里部分代码省略.........
iTotalCount = this->getKaiBaoxiangRsqData().size();
if (iTotalCount >= 11)
{
xcount = 6;
}
if (iTotalCount == 2)
{
xcount = 2;
size = CCSizeMake(140*2, 190);
}
IOSStoreLayerScrollView* pView = IOSStoreLayerScrollView::createView(size, iTotalCount, xcount, ycount);
m_pGetItemNode->addChild(pView);
pView->ignoreAnchorPointForPosition(false);
pView->setAnchorPoint(ccp(0.5f, 0.5f));
pView->setPosition(ccp(this->getContentSize().width/2, this->getContentSize().height/2 - 60));
pView->setClickableCreater(pView);
pView->prepareToDisplay();
pView->setTouchEnabled(false);
pView->setTag(getitem_scrollview_tag);
//显示
CCSprite* pSmallbg = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"main_shangdian_anniu_zaikaishici_fujia.png").c_str());
m_pGetItemNode->addChild(pSmallbg, 1);
pSmallbg->setPosition(ccp(200, 100));
//添加菜单
CCMenu* pMenu = CCMenu::create();
pMenu->setPosition(CCPointZero);
m_pGetItemNode->addChild(pMenu, 2);
//再开按钮
CCMenuItemImage* pItem = NULL;
int iStarCount = GameInforEditer::getGameInfor()->getTotalFreeScore();
if (m_bBaoxiangBuyTenTimes)
{
pItem = CCMenuItemImage::create(
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaishici.png").c_str(),
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaishici_select.png").c_str(),
this, menu_selector(IOSStoreLayer::menuBtnCallBack));
pItem->setTag(buy_ten_again);
}
else
{
pItem = CCMenuItemImage::create(
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaiyici.png").c_str(),
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaiyici_select.png").c_str(),
this, menu_selector(IOSStoreLayer::menuBtnCallBack));
pItem->setTag(buy_one_again);
}
pItem->setPosition(ccp(pSmallbg->getPositionX() + pSmallbg->getContentSize().width/2 + pItem->getContentSize().width/2 - 30,
pSmallbg->getPositionY()));
pMenu->addChild(pItem);
//星星数量
CCLabelAtlas* lable = CCLabelAtlas::create(
"0123456789",
ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"season_star_amount.png").c_str(),
30, 47,//24
'0');
m_pGetItemNode->addChild(lable, 1, star_count_str_tag);
lable->setAnchorPoint(ccp(0, 0.5));
lable->setScale(0.6f);
int iCount = 10;
if (m_bBaoxiangBuyTenTimes)
{
iCount = 95;
}
char charStarCount[10] = {};
sprintf(charStarCount, "%d", iCount);
lable->setString(charStarCount);
lable->setPosition(ccp(pItem->getPositionX()-pItem->getContentSize().width/2-lable->getContentSize().width/2 - 40, pSmallbg->getPositionY() - 3));
//右边星星图标
CCSprite* pXingxing = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_xiaogk+"YX_start.png").c_str());
m_pGetItemNode->addChild(pXingxing, 1);
pXingxing->setPosition(ccp(lable->getPositionX() - 30, pSmallbg->getPositionY()));
//星星数不够时,只显示确定按钮
//确定按钮
CCMenuItemImage* pOKItem = CCMenuItemImage::create(
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_quedingi.png").c_str(),
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_quedingi_select.png").c_str(),
this, menu_selector(IOSStoreLayer::menuBtnCallBack));
pOKItem->setTag(ok_btn_tag);
pOKItem->setPosition(ccp(this->getContentSize().width/2 + pOKItem->getContentSize().width, pSmallbg->getPositionY()));
pMenu->addChild(pOKItem);
if (iStarCount < iPrice)
{
lable->setVisible(false);
pXingxing->setVisible(false);
pSmallbg->setVisible(false);
pItem->setVisible(false);
pOKItem->setPosition(ccp(this->getContentSize().width/2, pSmallbg->getPositionY()));
}
pMenu->setTouchPriority(kCCMenuHandlerPriority-5);
}
示例15: createCellSpr
CCSprite* IOSStoreLayer::createCellSpr(int index, CellInfo* daojuInfo)
{
CCSprite* pDaoju = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"main_shangdian_daoju_bg.png").c_str());
//显示道具的名字
CCLabelTTF* pTitle = CCLabelTTF::create(daojuInfo->nameStr.c_str(), fontStr_katong, 24);
pDaoju->addChild(pTitle);
pTitle->setColor(fontColor_Store);
pTitle->setPosition(ccp(pDaoju->getContentSize().width/2, pDaoju->getContentSize().height - 40));
//显示道具的描述
CCLabelTTF* pDescribe = CCLabelTTF::create(daojuInfo->describeStr.c_str(), fontStr_katong, 24, CCSizeMake(200, 60), kCCTextAlignmentLeft);
pDaoju->addChild(pDescribe);
pDescribe->setAnchorPoint(ccp(0, 0.5f));
pDescribe->setHorizontalAlignment(kCCTextAlignmentLeft);
pDescribe->setPosition(ccp(10, 85));
if (daojuInfo->bBaoxiang)
{
pDescribe->setPosition(ccp(10, 65));
}
//显示图标
CCSprite* pIcon = CCSprite::create(daojuInfo->iconNameStr.c_str());
// if (pIcon)
{
pIcon->setPosition(ccp(pDaoju->getContentSize().width/2, pDaoju->getContentSize().height/2+20));
pDaoju->addChild(pIcon, 1);
CCSprite *mask = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"main_shangdian_daoju_fugai.png").c_str());
pDaoju->addChild(mask, 2);
mask->setPosition(ccp(pIcon->getPositionX(), pIcon->getPositionY()+20));
}
//宝箱需要设置缩放为35%
if (daojuInfo->bBaoxiang)
{
pIcon->setScale(0.35f);
}
//底部按钮
CCMenuItemImage* pMenuItem = CCMenuItemImage::create(
daojuInfo->btnIconNorNameStr.c_str(),
daojuInfo->btnIconSelNameStr.c_str(),
this,
menu_selector(IOSStoreLayer::menuBtnCallBack));
//星星数不够就显示文字,够的话就显示开宝箱按钮
if (pMenuItem)
{
bool bMore = false;
int iStarCount = GameInforEditer::getGameInfor()->getTotalFreeScore();
if (daojuInfo->bBaoxiang)
{
if (daojuInfo->iBaoxiangCount == 10)
{
if (iStarCount >= 95)
{
bMore = true;
}
}
else if (daojuInfo->iBaoxiangCount == 1)
{
if (iStarCount >= 10)
{
bMore = true;
}
}
}
else
{
bMore = true;
}
CCMenu* pMenu = CCMenu::create();
pMenu->setPosition(CCPointZero);
pDaoju->addChild(pMenu, 1);
pMenu->addChild(pMenuItem);
pMenuItem->setPosition(ccp(pDaoju->getContentSize().width/2, pMenuItem->getContentSize().height/2));
pMenu->setTouchPriority(kCCMenuHandlerPriority-3);
pMenuItem->setVisible(false);
if (bMore)
{
pMenuItem->setVisible(true);
}
else if (daojuInfo->bBaoxiang)
{
//星星不足时,显示的字符串
CCLabelTTF* pTip = CCLabelTTF::create(LFStrings::getValue("Starless").c_str(), fontStr_katong, 24, CCSizeMake(200, 60), kCCTextAlignmentCenter);
pDaoju->addChild(pTip,1);
pTip->setPosition(ccp(pDaoju->getContentSize().width/2, pMenuItem->getContentSize().height/2+5));
}
}
//宝箱和购买星星区别加载
if (daojuInfo->bBaoxiang)
{
//十个宝箱
if (daojuInfo->iBaoxiangCount == 10)
//.........这里部分代码省略.........