本文整理汇总了C++中CCMenuItemImage::selected方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemImage::selected方法的具体用法?C++ CCMenuItemImage::selected怎么用?C++ CCMenuItemImage::selected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemImage
的用法示例。
在下文中一共展示了CCMenuItemImage::selected方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void CNetworkPlayerNumberLayer::update(float dt)
{
// ¿Ã ∞‘¿”¿ª ∏Ó ∏Ì¿Ã «œ¥¬¡ˆ ∞°¡ÆøÕº≠ «ÿ¥Á πˆ∆∞¿ª º±≈√µ» ªÛ≈¬∑Œ ∏∏µÁ¥Ÿ.
CCMenuItemImage* pTempPlayerNumber;
for (int i = 2; i <= MAX_PLAYER_NUM; ++i)
{
// «ˆ¿Á ¿Œø¯ºˆø° «ÿ¥Á«œ¥¬ πˆ∆∞ ∆˜¿Œ≈Õ∏¶ ∞°¡Æø¬¥Ÿ.
pTempPlayerNumber = static_cast<CCMenuItemImage*>( this->getChildByTag(PLAYER_SELECT_TABLE_TAG)->getChildByTag(i - 1) );
// πÊæÓƒ⁄µÂ
if ( pTempPlayerNumber == nullptr )
{
return;
}
// PLAYER NUMBER == i
// PLAYER NUMBER 2 == TAG (1), 3 == TAG (2), 4 == TAG (3) ¿Ãπ«∑Œ
// TAG == i - 1
if (CGameManager::GetInstance()->GetStatusPlayerNumber(i) )
{
pTempPlayerNumber->selected();
}
else
{
pTempPlayerNumber->unselected();
}
}
}
示例2: answerCallback
void SoloGameScene::answerCallback( CCObject* pSender )
{
this->unschedule(schedule_selector(SoloGameScene::scheduleClock));
CCMenuItemImage* it = (CCMenuItemImage*) pSender;
it->selected();
int tag = it->getTag();
if (tag == m_curRightAnswer)
{
PLAY_GET_BOMB_EFFECT;
m_curScore += DataManager::sharedDataManager()->GetSoloAddScore();
m_isRight = true;
}
else
{
PLAY_OUT_PORP_EFFECT;
m_curScore += DataManager::sharedDataManager()->GetSoloSubScore();
if(m_curScore < 0) m_curScore = 0;
m_isRight = false;
}
animationRightChoose();
m_lbScore->setString(CCString::createWithFormat("%d", m_curScore)->getCString());
DataManager::sharedDataManager()->SetSoloScore(m_curScore);
}
示例3: init
// on "init" you need to initialize your instance
bool ChooseMap::init()
{
//////////////////////////////
// 1. super init first
if (!Layer::init())
{
return false;
}
CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(ChooseMap::getArray), "2PMessage", NULL);
CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(ChooseMap::storymode), "storyMessage", NULL);
string path = "images/newGame/";
char *mapName[6] = { "chibi", "guandu", "hanzhong", "hulaoguan", "xuzhou", "yiling"};
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
//平铺背景
auto *bg = CCSprite::create("images/background/bg_fight.png");
bg->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
this->addChild(bg, -1);
//标题
auto *title = CCSprite::create(path + "map_choose.png");
title->setPosition(ccp(visibleSize.width * 0.1, visibleSize.height * 0.9));
this->addChild(title);
title->setScale(1.4f, 1.4f);
//hint
string hints = XMLParser::parseXML("hintStrings", 3);
CCLabelTTF *ttf = CCLabelTTF::create(hints, "【朦胧补】水黑体", 35);
ttf->setPosition(ccp(visibleSize.width * 0.85, visibleSize.height * 0.87));
this->addChild(ttf);
//上一步
auto* last = CCSprite::create(path+"last.png");
last->setScale(1.4f, 1.4f);
auto* last_selected = CCSprite::create(path + "last_selected.png");
last_selected->setScale(1.4f, 1.4f);
auto *Last = CCMenuItemSprite::create(last, last_selected, last, this, menu_selector(ChooseMap::backto));
Last->setPosition(ccp(visibleSize.width - 200, 50));
//开始游戏
auto* begin = CCSprite::create(path + "begin.png");
begin->setScale(1.4f, 1.4f);
auto* begin_selected = CCSprite::create(path + "begin_selected.png");
begin_selected->setScale(1.4f, 1.4f);
auto *Begin = CCMenuItemSprite::create(begin, begin_selected, begin, this, menu_selector(ChooseMap::startGame));
Begin->setPosition(ccp(visibleSize.width - 80, 50));
auto *menu = CCMenu::create(Begin, NULL);
menu->addChild(Last, NULL);
menu->setPosition(Point::ZERO);
this->addChild(menu, 2);
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = [](Touch* touch, Event* event)->bool{
CCLOG("listener1 onTouchBegan");
auto target = static_cast<Sprite*>(event->getCurrentTarget());
Point locationInNode = target->convertToNodeSpace(touch->getLocation());
Size s = target->getContentSize();
Rect rect = Rect(0, 0, s.width, s.height);
if (rect.containsPoint(locationInNode)){//判断触摸点是否在目标的范围内
return true;
}
else
return false;
};
listener->onTouchMoved = [](Touch* touch, Event* event){CCLOG("listener1 onTouchMoved"); };
listener->onTouchEnded = [](Touch* touch, Event* event){
CCMenuItemImage *target = static_cast< CCMenuItemImage*>(event->getCurrentTarget());
if (target->isSelected()){
target->unselected();
}
else {
SimpleAudioEngine::sharedEngine()->playEffect("select.wav",false);//开始播放背景音效,false表示不循环
target->selected();
}
};
for (int k = 0; k < 2; k++){
double f;
if (k == 0){
f = 0.58;
}
else {
f = 0.23;
}
for (int j = 0; j < 3; j++){
int i = 3 * k + j;
Sprite *sprite = Sprite::create(path + mapName[i] + ".png");
sprite->setScale(0.5f, 0.5f);
map[i] = CCMenuItemImage::create(path + mapName[i] + "zhizhan.png", path + mapName[i] + "zhizhan_selected.png");
map[i]->setScale(0.5f, 0.5f);
sprite->setPosition(ccp(visibleSize.width * 0.3 * j + 280, visibleSize.height * f - 50));
map[i]->setPosition(ccp(visibleSize.width * 0.3 * j + 280, visibleSize.height * f + 80));
this->addChild(sprite);
this->addChild(map[i], 1);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), map[i]);
}
}
return true;
}
示例4: init
// on "init" you need to initialize your instance
bool ChooseCharacter::init()
{
//////////////////////////////
// 1. super init first
if (!Layer::init())
{
return false;
}
string path = "images/newGame/";
string heropath = "images/country/";
char *heroName[40] = { "caocao", "caiwenji", "caoren", "dianwei", "guojia", "xiahoudun", "xiahouyuan",
"xuchu", "zhangliao", "zhenbi", "sunquan", "chengpu", "daqiao", "huanggai", "lusu", "luxun", "sunce",
"taishici", "xiaoqiao", "zhouyu", "liubei", "guanyinping", "guanyu", "huangzhong", "machao", "weiyan",
"zhangfei", "zhangxingcai", "zhaoyun", "zhugeliang", "lvbu", "diaochan", "dongzhuo", "gongsunzan",
"liubiao", "liuzhang", "mateng", "yuanshao", "yuanshu", "zhanglu" };
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
//平铺背景
auto *bg = CCSprite::create("images/background/bg_fight.png");
bg->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
this->addChild(bg, -1);
//标题
auto *title = CCSprite::create(path+"character_choose.png");
title->setPosition(ccp(visibleSize.width * 0.1, visibleSize.height * 0.9));
this->addChild(title);
title->setScale(1.4f, 1.4f);
auto *player = CCSprite::create(path + "1P.png");
player->setPosition(ccp(visibleSize.width * 0.25, visibleSize.height * 0.9));
this->addChild(player);
player->setScale(1.2f, 1.2f);
string hints = XMLParser::parseXML("hintStrings", 2);
CCLabelTTF *ttf = CCLabelTTF::create(hints, "【朦胧补】水黑体", 35);
ttf->setPosition(ccp(visibleSize.width * 0.85, visibleSize.height * 0.9));
this->addChild(ttf);
//确认
auto* back = CCSprite::create("back.png");
back->setScale(1.4f, 1.4f);
auto* back_selected = CCSprite::create("back_selected.png");
back_selected->setScale(1.4f, 1.4f);
auto *Back = CCMenuItemSprite::create(back, back_selected, back, this, menu_selector(ChooseCharacter::backto));
Back->setPosition(ccp(visibleSize.width - 240, 50));
//退出
auto* next = CCSprite::create(path+"next.png");
next->setScale(1.4f, 1.4f);
auto* next_selected = CCSprite::create(path + "next_selected.png");
next_selected->setScale(1.4f, 1.4f);
auto *Next = CCMenuItemSprite::create(next, next_selected, next, this, menu_selector(ChooseCharacter::nextto));
Next->setPosition(ccp(visibleSize.width - 100, 50));
auto *menu = CCMenu::create(Next, NULL);
menu->addChild(Back, NULL);
menu->setPosition(Point::ZERO);
this->addChild(menu, 2);
auto *wei = CCSprite::create(path + "wei.png");
wei->setPosition(ccp(visibleSize.width * 0.17, visibleSize.height * 0.75));
this->addChild(wei);
wei->setScale(3.0f, 3.0f);
auto *shu = CCSprite::create(path + "shu.png");
shu->setPosition(ccp(visibleSize.width * 0.61, visibleSize.height * 0.75));
this->addChild(shu);
shu->setScale(3.0f, 3.0f);
auto *wu = CCSprite::create(path + "wu.png");
wu->setPosition(ccp(visibleSize.width * 0.39, visibleSize.height * 0.75));
this->addChild(wu);
wu->setScale(3.0f, 3.0f);
auto *qun = CCSprite::create(path + "qun.png");
qun->setPosition(ccp(visibleSize.width * 0.83, visibleSize.height * 0.75));
this->addChild(qun);
qun->setScale(3.0f, 3.0f);
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = [](Touch* touch, Event* event)->bool{
CCLOG("listener1 onTouchBegan");
auto target = static_cast<Sprite*>(event->getCurrentTarget());
Point locationInNode = target->convertToNodeSpace(touch->getLocation());
Size s = target->getContentSize();
Rect rect = Rect(0, 0, s.width, s.height);
if (rect.containsPoint(locationInNode)){//判断触摸点是否在目标的范围内
return true;
}
else
return false;
};
listener->onTouchMoved = [](Touch* touch, Event* event){CCLOG("listener1 onTouchMoved"); };
listener->onTouchEnded = [](Touch* touch, Event* event){
CCMenuItemImage *target = static_cast< CCMenuItemImage*>(event->getCurrentTarget());
if (target->isSelected()){
target->unselected();
}
else {
//.........这里部分代码省略.........