• 未命名 1


    void MarketShopListLayer::registerWithTouchDispatcher(){

    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, false);//优先级设为0,就不会出现按到按钮,不能进行滑动

    }


    bool MarketShopListLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent){

    startPoint=this->convertTouchToNodeSpace(pTouch);

    starTime=millisecondNow();

    return true;

    }


    void MarketShopListLayer::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent){

    CCPoint movePoint=this->convertTouchToNodeSpace(pTouch);

    CCPoint disPoint= ccpSub(movePoint, startPoint);

    float disX=disPoint.x;

    float disY=disPoint.y;

      

    if (fabsf(disX)>fabsf(disY)) {

    leftRight=true;

    tableView->setTouchEnabled(false);//左右滑动

    tableView->setPosition(ccp(tbPoint.x+disX,tbPoint.y));

    }else{

    leftRight=false;

    tableView->setTouchEnabled(true);//上下滑动

    }

    // ******************************************

    bool isDragingDown=movePoint.y<startPoint.y;

    float difference=fabsf(movePoint.y-startPoint.y);

    if (isRefreshShow&&isDragingDown&&(difference>420)) {

    CCLog(“refresh”);

    ((SwitchView *)_delegate)->postNotificationName(MARKET_SHOP_LISTC, CCInteger::create(_currentPage));

    }

    }


    void MarketShopListLayer::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent){

    if (leftRight) {

    CCPoint endPoint=this->convertTouchToNodeSpace(pTouch);

    float dis=fabsf(ccpSub(endPoint, startPoint).x);

    long endTime=millisecondNow();

    std::cout<<差值:<<fabs(starTime-endTime)<<std::endl;

      

    if (dis>=tableView->getContentSize().width/2||(fabs(starTime-endTime)>49)) {

    if (dis>0) {//向右

    _currentPage—;

    _currentPage=MAX(_currentPage, 1);

    }else{//向左

    _currentPage++;

    _currentPage=MIN(_currentPage, _totalPage);

    }

    ((SwitchView*)_delegate)->postNotificationName(MARKET_SHOP_LISTC, CCInteger::create(_currentPage));

    pageLabel->setString(CCString::createWithFormat(“%d/%d”,_currentPage,_totalPage)->getCString());

    }

    }

    tableView->runAction(CCMoveTo::create(0.5,tbPoint));

    }

    //****************************************************************************

    long MarketShopListLayer::millisecondNow(){

    struct cc_timeval now;

    CCTime::gettimeofdayCocos2d(&now, NULL);

    return (now.tv_sec * 1000 + now.tv_usec / 1000);

    }


    void MarketShopListLayer::setDelegate(CCObject* delegate){

    _delegate=delegate;

    CC_SAFE_RETAIN(_delegate);

    }

  • 相关阅读:
    佛學概要十四講表
    冰川时代4中英台词全集
    Linux Mysql 每天定时备份
    zabbix拓扑图
    搭建zabbix 3.4
    ★日常工作保养电脑及设备★
    宽带突然断网了,需要做如下应急措施
    预防这几点,可以让你的电脑长久耐用!!!!
    搭建简易的 DISCUZ论坛
    format 的常见用法
  • 原文地址:https://www.cnblogs.com/yssgyw/p/3428789.html
Copyright © 2020-2023  润新知