Exemple #1
0
void GuoZhanLayer::ccTouchEnded(CCTouch* pTouch, CCEvent* pEvent){
    CCSprite* pBg = static_cast<CCSprite*>(m_pSBN->getChildByTag(GUOZ_BG_TAG));
    CCPoint touchPoint = pBg->convertTouchToNodeSpace(pTouch);
    int selectIdx = -1;
    for (int i = 0; i < CITY_COUNT; ++i) {
        if (m_btnEnable[i] && m_btnSprite[i][0]->boundingBox().containsPoint(touchPoint)) {
            selectIdx = i + 1;
            break;
        }
    }
    
    _initBtn();
    
    if (selectIdx > 0) {
        _onBtnSelected(selectIdx);
    }
}
Exemple #2
0
void GuoZhanLayer::ccTouchMoved(CCTouch* pTouch, CCEvent* pEvent){
    _initBtn();
    
    CCSprite* pBg = static_cast<CCSprite*>(m_pSBN->getChildByTag(GUOZ_BG_TAG));
    CCPoint touchPoint = pBg->convertTouchToNodeSpace(pTouch);
    for (int i = 0; i < CITY_COUNT; ++i) {
        if (m_btnEnable[i] && m_btnSprite[i][0]->boundingBox().containsPoint(touchPoint)) {
            m_btnSprite[i][0]->setVisible(false);/*普通*/
            m_btnSprite[i][1]->setVisible(true);/*选中*/
            CCPoint btnPos = m_btnPosition[i][0];
            btnPos.x += BTN_HIGHLIGHT_OFFSET_H;
            btnPos.y += BTN_HIGHLIGHT_OFFSET_V;
            
            m_btnSprite[i][1]->setPosition(btnPos);
            
            break;
        }
    }
}