Beispiel #1
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;
}
CCEaseOut* CCEaseOut::create ( CCActionInterval* pAction, KDfloat fRate )
{
	CCEaseOut*  pRet = new CCEaseOut ( );

    if ( pRet && pRet->initWithAction ( pAction, fRate ) )
    {
        pRet->autorelease ( );
    }
    else
    {
        CC_SAFE_DELETE ( pRet );
    }

	return pRet;      
}
Beispiel #3
0
	//
	// EaseOut
	//
	CCEaseOut* CCEaseOut::actionWithAction(cocos2d::CCIntervalAction *pAction, float fRate)
	{
		CCEaseOut *pRet = new CCEaseOut();
		if (pRet)
		{
			if (pRet->initWithAction(pAction, fRate))
			{
				pRet->autorelease();
			}
			else
			{
				CCX_SAFE_RELEASE_NULL(pRet);
			}
		}

		return pRet;      
	}
Beispiel #4
0
CCEaseOut* CCEaseOut::create(CCActionInterval *pAction, float fRate)
{
    CCEaseOut *pRet = new CCEaseOut();
    if (pRet)
    {
        if (pRet->initWithAction(pAction, fRate))
        {
            pRet->autorelease();
        }
        else
        {
            CC_SAFE_RELEASE_NULL(pRet);
        }
    }

    return pRet;   
}
Beispiel #5
0
	NSObject* CCEaseOut::copyWithZone(cocos2d::NSZone *pZone)
	{
		NSZone* pNewZone = NULL;
		CCEaseOut* pCopy = NULL;
		if(pZone && pZone->m_pCopyObject) 
		{
			//in case of being called at sub class
			pCopy = (CCEaseOut*)(pZone->m_pCopyObject);
		}
		else
		{
			pCopy = new CCEaseOut();
			pZone = pNewZone = new NSZone(pCopy);
		}

		pCopy->initWithAction((CCIntervalAction*)(m_pOther->copy()->autorelease()), m_fRate);

		CCX_SAFE_DELETE(pNewZone);
		return pCopy;
	}
Beispiel #6
0
CCObject* CCEaseOut::copyWithZone(CCZone *pZone)
{
    CCZone* pNewZone = NULL;
    CCEaseOut* pCopy = NULL;
    if(pZone && pZone->m_pCopyObject) 
    {
        //in case of being called at sub class
        pCopy = (CCEaseOut*)(pZone->m_pCopyObject);
    }
    else
    {
        pCopy = new CCEaseOut();
        pNewZone = new CCZone(pCopy);
    }

    pCopy->initWithAction((CCActionInterval*)(m_pInner->copy()->autorelease()), m_fRate);

    CC_SAFE_DELETE(pNewZone);
    return pCopy;
}