CCFollow step() that Honors Scale (Code for 2.2.x)

CCFollow step() that Honors Scale (Code for 2.2.x)
0

#1

Here is what I am using in CCFollow to make it honor the ‘scale’ property on the target node.

void CCFollow::step(float dt)
{
    CC_UNUSED_PARAM(dt);

    if(m_bBoundarySet)
    {
        // whole map fits inside a single screen, no need to modify the position - unless map boundaries are increased
        if(m_bBoundaryFullyCovered)
            return;

        CCPoint tempPos = ccpSub( m_obHalfScreenSize, m_pobFollowedNode->getPosition());

        m_pTarget->setPosition(ccp(clampf(tempPos.x*m_pTarget->getScale(), m_fLeftBoundary*m_pTarget->getScale(), m_fRightBoundary*m_pTarget->getScale()), 
                                   clampf(tempPos.y*m_pTarget->getScale(), m_fBottomBoundary*m_pTarget->getScale(), m_fTopBoundary*m_pTarget->getScale())));
    }
    else
    {
		
        m_pTarget->setPosition(ccpSub(ccpMult(m_obHalfScreenSize,m_pTarget->getScale()), ccpMult(m_pobFollowedNode->getPosition(),m_pTarget->getScale())));
    }
}