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);

    }

  • 相关阅读:
    .net 流读取
    c#小Tip:数字格式化显示
    VS.NET优化编译速度
    Application.Run()和Form.Show()的区别
    如何利用系统函数操作文件夹及文件
    设计优秀的用户界面
    我妈过来了
    帮你免于失业的十大软件技术(转抄)
    正试图在 OS 加载程序锁内执行托管代码
    NASA World Wind
  • 原文地址:https://www.cnblogs.com/yssgyw/p/3428789.html
Copyright © 2011-2022 走看看