zoukankan      html  css  js  c++  java
  • 未命名 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);

    }

  • 相关阅读:
    GridView点击行触发SelectedIndexChanged事件
    javascript 功能大全
    scrollHeight、offsetHeight、clientHeight
    鸟哥的 Linux 私房菜
    谈谈对程序员的培养
    UTF8编码中的BOM字符 引起Session/Cookies失效
    “Request 对象 错误 'ASP 0104 : 80004005' 不允许操作
    生成网站,如何不生成.pdb文件?
    小心swfupload 的cookie Bug
    使用vbs脚本检查网站是否使用asp.net
  • 原文地址:https://www.cnblogs.com/yssgyw/p/3428789.html
Copyright © 2011-2022 走看看