Ejemplo n.º 1
0
void DocumentLoader::unschedule(SchedulePair& pair)
{
    if (mainResourceLoader())
        mainResourceLoader()->unschedule(pair);
    unscheduleAll(m_subresourceLoaders, pair);
    unscheduleAll(m_plugInStreamLoaders, pair);
    unscheduleAll(m_multipartSubresourceLoaders, pair);
}
Ejemplo n.º 2
0
void HFViewport::scrollToSmooth(const CCPoint& targetPoint, CCCallFunc* callbackFunc,float time)
{
    unscheduleAll();
    mIsProcessingScroll = true;
    do
    {
        this->mTouchMode = TouchMode_Fling;
        CCPoint curPos = this->m_TargetNode->getPosition();
        CCPoint targetPos = targetPoint;
        CCSize winsize = CCDirector::sharedDirector()->getWinSize();
        if (targetPos.x >0.0f) {
            targetPos.x = curPos.x;
        }
        if (targetPos.x <winsize.width-MAP_WIDTH*this->m_TargetNode->getScaleX()){
            targetPos.x = winsize.width-MAP_WIDTH*this->m_TargetNode->getScaleX();
        }
        if (targetPos.y >0.0f) {
            targetPos.y = curPos.y;
        }
        if (targetPos.y <winsize.height-MAP_HEIGHT*this->m_TargetNode->getScaleY()){
            targetPos.y =winsize.height-MAP_HEIGHT*this->m_TargetNode->getScaleY();
        }
        CCMoveTo* move = CCMoveTo::create(time, targetPos);
        CCAction* action = CCSequence::create(move,callbackFunc,NULL);
        action->setTag(FLINGACTION_TAG);
        this->m_TargetNode->runAction(action);
    }
    while(0);
    mIsProcessingScroll = false;
}
Ejemplo n.º 3
0
void HFViewport::scrollBy(const CCPoint& targetPoint, CCCallFunc* callbackFunc,float time)
{
    unscheduleAll();
    mIsProcessingScroll = true;
    do
    {
        this->mTouchMode = TouchMode_Fling;
        CCPoint curPos = this->m_TargetNode->getPosition();
        CCPoint targetPos = ccpSub(curPos,targetPoint);
        CCSize winsize = CCDirector::sharedDirector()->getWinSize();
        if (targetPos.x >0.0f) {
            targetPos.x = curPos.x;
        }
        if (targetPos.x <winsize.width-MAP_WIDTH*this->m_TargetNode->getScaleX()){
            targetPos.x = winsize.width-MAP_WIDTH*this->m_TargetNode->getScaleX();
        }
        if (targetPos.y >0.0f) {
            targetPos.y = curPos.y;
        }
        if (targetPos.y <winsize.height-MAP_HEIGHT*this->m_TargetNode->getScaleY()){
            targetPos.y =winsize.height-MAP_HEIGHT*this->m_TargetNode->getScaleY();
        }        if(time <0.0f)
        {
            this->m_TargetNode->setPosition(targetPos);
            return;
        }
        CCMoveBy* moveTo = CCMoveBy::create(time, targetPos);
        CCEaseOut* ease = CCEaseOut::create(moveTo, 3);
        ease->setTag(FLINGACTION_TAG);
        this->m_TargetNode->runAction(CCRepeat::create(CCSequence::create(ease, callbackFunc, NULL), 1));
        this->mTouchMode = TouchMode_Fling;
    }
    while(0);
    mIsProcessingScroll = false;
}
Ejemplo n.º 4
0
void Viewport::scrollToSmooth(const Vec2& targetPoint, CallFunc* callbackFunc,float time)
{
    unscheduleAll();
    mIsProcessingScroll = true;
    do
    {
        this->mTouchMode = TouchMode_Fling;
        Vec2 curPos = this->m_TargetNode->getPosition();
        Vec2 targetPos = targetPoint;
        Size winsize = Director::getInstance()->getWinSize();
        if (targetPos.x >0.0f) {
            targetPos.x = curPos.x;
        }
        if (targetPos.x <winsize.width-mMapSize.width*this->m_TargetNode->getScaleX()){
            targetPos.x = winsize.width-mMapSize.width*this->m_TargetNode->getScaleX();
        }
        if (targetPos.y >0.0f) {
            targetPos.y = curPos.y;
        }
        if (targetPos.y <winsize.height-mMapSize.height*this->m_TargetNode->getScaleY()){
            targetPos.y =winsize.height-mMapSize.height*this->m_TargetNode->getScaleY();
        }
        MoveTo* move = MoveTo::create(time, targetPos);
        Action* action = Sequence::create(move,callbackFunc,NULL);
        action->setTag(FLINGACTION_TAG);
        this->m_TargetNode->runAction(action);
    }
    while(0);
    mIsProcessingScroll = false;
}
Ejemplo n.º 5
0
void Viewport::scrollBy(const Vec2& targetPoint, CallFunc* callbackFunc,float time)
{
    unscheduleAll();
    mIsProcessingScroll = true;
    do
    {
        this->mTouchMode = TouchMode_Fling;
        Vec2 curPos = this->m_TargetNode->getPosition();
        Vec2 targetPos = ccpSub(curPos,targetPoint);
        Size winsize = Director::getInstance()->getWinSize();
        if (targetPos.x >0.0f) {
            targetPos.x = curPos.x;
        }
        if (targetPos.x <winsize.width-mMapSize.width*this->m_TargetNode->getScaleX()){
            targetPos.x = winsize.width-mMapSize.width*this->m_TargetNode->getScaleX();
        }
        if (targetPos.y >0.0f) {
            targetPos.y = curPos.y;
        }
        if (targetPos.y <winsize.height-mMapSize.height*this->m_TargetNode->getScaleY()){
            targetPos.y =winsize.height-mMapSize.height*this->m_TargetNode->getScaleY();
        }        if(time <0.0f)
        {
            this->m_TargetNode->setPosition(targetPos);
            return;
        }
        MoveBy* moveTo = MoveBy::create(time, targetPos);
        EaseOut* ease = EaseOut::create(moveTo, 3);
        ease->setTag(FLINGACTION_TAG);
        this->m_TargetNode->runAction(CCRepeat::create(CCSequence::create(ease, callbackFunc, NULL), 1));
        this->mTouchMode = TouchMode_Fling;
    }
    while(0);
    mIsProcessingScroll = false;
}
Ejemplo n.º 6
0
// 移动场景到指定的坐标点
void Viewport::scrollTo(const Vec2& targetPoint, CallFunc* callbackFunc, bool Flying)
{
    unscheduleAll();
    mIsProcessingScroll = true;
    do
    {
        this->mTouchMode = TouchMode_Fling;
        Vec2 curPos = this->m_TargetNode->getPosition();
        Vec2 targetPos = targetPoint;
        Size winsize = Director::getInstance()->getWinSize();
        if (targetPos.x >0.0f) {
            targetPos.x = curPos.x;
        }
        if (targetPos.x <winsize.width-mMapSize.width*this->m_TargetNode->getScaleX()){
            targetPos.x = winsize.width-mMapSize.width*this->m_TargetNode->getScaleX();
        }
        if (targetPos.y >0.0f) {
            targetPos.y = curPos.y;
        }
        if (targetPos.y <winsize.height-mMapSize.height*this->m_TargetNode->getScaleY()){
            targetPos.y =winsize.height-mMapSize.height*this->m_TargetNode->getScaleY();
        }
        if (Flying) {
            MoveTo* moveTo = MoveTo::create(0.4f, targetPos);
            EaseOut* ease = EaseOut::create(moveTo, 3);
            ease->setTag(FLINGACTION_TAG);
            this->m_TargetNode->runAction(Repeat::create(Sequence::create(ease, callbackFunc, NULL), 1));
        }
        else{
            this->m_TargetNode->setPosition(targetPos);
        }
    }
    while(0);
    mIsProcessingScroll = false;
}
Ejemplo n.º 7
0
void HFViewport::onTouchesBegan(const std::vector<Touch*>& pTouches, Event *pEvent)
{
    unscheduleAll();
    CC_ASSERT(this->m_TargetNode);
    
    //tao.yu 为解决batch不跟随自定义摄像机走的问题,增加此行代码
    if (m_TargetNode->getTag() == IMPERIAL_SCENE_TOUCH_LAYER_TAG)
    {
        m_TargetNode->setCameraMask((unsigned short)CameraFlag::USER4, true);
        auto node3d = m_TargetNode->getChildByTag(JUST3D_NODE_TAG);
        if (node3d) {
            node3d->setCameraMask((unsigned short)CameraFlag::USER2, true);
        }
    }
    
//    CC_ASSERT(pTouches);
    
    if (mFingerMap.size() >= 2) {
        isMove = true;
        return;
    }
    
    if( this->mTouchMode == TouchMode_Fling )
    {
        this->m_TargetNode->stopActionByTag(FLINGACTION_TAG);
    }
    this->mTouchMode = TouchMode_None;
    
    
    for ( auto &item: pTouches )
    {
        CCTouch* curTouch = dynamic_cast<CCTouch*>(item);
        CC_ASSERT(curTouch);
        if (mFingerMap.size() <= 2) {
            mFingerMap[curTouch->getID()] = curTouch->getLocation();
        }
    }
//    
//    CCSetIterator iter = pTouches->begin();
//    
//    while( iter != pTouches->end() )
//    {
//        CCTouch* curTouch = dynamic_cast<CCTouch*>(*iter);
//        CC_ASSERT(curTouch);
//        if (mFingerMap.size() <= 2) {
//            mFingerMap[curTouch->getID()] = curTouch->getLocation();
//        }
//        iter++;
//    }
    
    switch(mFingerMap.size())
    {
        case 1:            
        {
            m_bTouchMoved = false;
            if (this->mTouchMode != TouchMode_ZoomFling) {
                this->mTouchMode = TouchMode_Scroll;
            }

            if (!mForceStopScroll && mMovable && !pTouches.empty()) {
                CCTouch* objTouch = dynamic_cast<CCTouch*>(*pTouches.begin());
                CC_ASSERT(objTouch);
                // let "beginScroll" fired by first step scroll , make single touch not fire this
                //                beginScroll(objTouch);
                if (mTouchDelegate) {
                    mTouchDelegate->onSingleTouchBegin(this->m_TargetNode->convertToNodeSpace(objTouch->getLocation()));
                    mTouchDelegate->onSingleTouchBegin(objTouch);
                }
            }
            
            CCTouch* ptouch =getAnyTouchObject(pTouches);
            mPreviewPos = ptouch->getLocation();
        }
            break;
        case 2:
            if (this->mTouchMode != TouchMode_ZoomFling) {
                this->mTouchMode = TouchMode_Zoom;
            }
            if(!allowZoom){
                return;
            }
            do
            {
                FingerMap::iterator iter = mFingerMap.begin();
                CC_BREAK_IF(iter == mFingerMap.end());
                CCPoint pos1 = (*iter).second;
                CC_BREAK_IF(++iter == mFingerMap.end());
                CCPoint pos2 = (*iter).second;
                beginZoom(pos1, pos2);
            }
            while(0);
            isMove = true;
            break;
        default:
            isMove = true;
            CCLOG("begin:Touch not support with %d fingers", pTouches.size());
    }
}
Ejemplo n.º 8
0
void Dashboard::reset()
{
    unscheduleAll();
    scheduleEventIn(SIM_EVENT_DO_FRAME, ms_to_sim_time(20));
}
Ejemplo n.º 9
0
void VirtualNetwork::reset(void)
{
    unscheduleAll();
    scheduleEventIn(SIM_EVENT_CHECK_FRAMES, DEFAULT_CHECK_FRAMES_INTERVAL);
}
Ejemplo n.º 10
0
void Viewport::onTouchesBegan(const std::vector<Touch*>& pTouches, Event *pEvent)
{
    unscheduleAll();
    CC_ASSERT(this->m_TargetNode);
//    CC_ASSERT(pTouches);
    
    if (mFingerMap.size() >= 2) {
        isMove = true;
        return;
    }
    
    if( this->mTouchMode == TouchMode_Fling )
    {
        this->m_TargetNode->stopActionByTag(FLINGACTION_TAG);
    }
    this->mTouchMode = TouchMode_None;
    
    
    for ( auto &item: pTouches )
    {
        Touch* curTouch = dynamic_cast<Touch*>(item);
        CC_ASSERT(curTouch);
        if (mFingerMap.size() <= 2) {
            mFingerMap[curTouch->getID()] = curTouch->getLocation();
        }
    }
    
    switch(mFingerMap.size())
    {
        case 1:            
        {
            m_bTouchMoved = false;
            if (this->mTouchMode != TouchMode_ZoomFling) {
                this->mTouchMode = TouchMode_Scroll;
            }

            if (!mForceStopScroll && mMovable) {
                Touch* objTouch = dynamic_cast<Touch*>(*pTouches.begin());
                CC_ASSERT(objTouch);
                // let "beginScroll" fired by first step scroll , make single touch not fire this
                //                beginScroll(objTouch);
                if (mTouchBeginHandler) {
                    pushValueToLua(mTouchBeginHandler, objTouch);
                }
            }
            
            Touch* ptouch =getAnyTouchObject(pTouches);
            mPreviewPos = ptouch->getLocation();
        }
            break;
        case 2:
            if (this->mTouchMode != TouchMode_ZoomFling) {
                this->mTouchMode = TouchMode_Zoom;
            }
            if(!allowZoom){
                return;
            }
            do
            {
                FingerMap::iterator iter = mFingerMap.begin();
                CC_BREAK_IF(iter == mFingerMap.end());
                Vec2 pos1 = (*iter).second;
                CC_BREAK_IF(++iter == mFingerMap.end());
                Vec2 pos2 = (*iter).second;
                beginZoom(pos1, pos2);
            }
            while(0);
            isMove = true;
            break;
        default:
            isMove = true;
            CCLOG("begin:Touch not support with %lu fingers", pTouches.size());
    }
}