Beispiel #1
0
void LogoScene::changeLogo()
{
	auto logoSprite = vecLogo.at(nLogoNum);
	logoSprite->setPosition(visibleSize / 2);
	logoSprite->runAction(Sequence::create(
		FadeIn::create(0.5f), DelayTime::create(1.0f), FadeOut::create(0.5f),
		CallFunc::create([&]{onTouchBegan(NULL, NULL); }), NULL));
	addChild(logoSprite);
}
Beispiel #2
0
 bool AbstractScene::beginTouch(int fingerIndex, const glm::vec2& position)
 {
     glm::vec2 p = position;
     bool result = false;
     FOR_EACH_COMPONENT(onBeforeTouchEvent(TouchEvent::Begin, fingerIndex, p, result));
     if (!result)
         result = onTouchBegan(fingerIndex, position);
     FOR_EACH_COMPONENT_REVERSE(onAfterTouchEvent(TouchEvent::Begin, fingerIndex, p, result));
     return result;
 }
//触摸:开始
bool CNFServerChangeScrollLayer::onTouchBegan(Touch *pTouch, Event *pEvent)
{
    Vec2 ptTouchPoint =pTouch->getLocation();

    //设置初始触摸点
    m_fTouchPassPosX = ptTouchPoint.x;
    m_fTouchBeginPosX = ptTouchPoint.x;

    //判断是否触摸到裁切区域内
    if(m_DisPlayRect.containsPoint(ptTouchPoint))
    {
        m_bTouching = true;

        //判断是否触摸到按钮
       
//        Menu *pMenu = dynamic_cast<Menu*>(getChildByTag(enTagMenu));
         auto pMenu = static_cast<Menu*>(getChildByTag(enTagMenu));
        
        Vector<Node*> pChildren = pMenu->getChildren();
        
        if(pMenu!=NULL)
        {
            
            int i=0;
            for(const auto &pItem : pChildren) {

                
                auto pBtn= static_cast<MenuItemSprite*>(pItem);
                if(pBtn!=NULL)
                {
                    Vec2 local = pBtn->convertToNodeSpace(pTouch->getLocation());
                    Rect r = pBtn->rect();
                    r.origin = Vec2::ZERO;
                    if (r.containsPoint(local))
                    {
                        pMenu->onTouchBegan(pTouch,pEvent);
                        m_bIsTouchBtn=true;
                    }
                }
                i++;
            }
           

        }
        
        
        return true;
    }
    
    return false;
}
void MainMenu::onTouchMoved(cocos2d::Touch *touch, cocos2d::Event * event)
{
	onTouchBegan(touch, event);
}