void CCParallaxScrollNode::updateWithVelocity(const CCPoint &vel, float dt) {
        CCSize screen = CCDirector::sharedDirector()->getWinSize();
        
        CCPoint vel2 = ccpMult(vel, PTM_RATIO);
        
        for (int i=scrollOffsets->num - 1; i >= 0; i--) {
            CCParallaxScrollOffset *scrollOffset = (CCParallaxScrollOffset*)scrollOffsets->arr[i];
            CCNode *child = scrollOffset->getChild();
            
            CCPoint relVel = ccpMult(scrollOffset->getRelVelocity(), PTM_RATIO);
            CCPoint totalVel = ccpAdd(vel2, relVel);
            CCPoint tmp = ccpMult(totalVel, dt);
            CCPoint offset = ccpCompMult(tmp, scrollOffset->getRatio());

            
            child->setPosition(ccpAdd(child->getPosition(), offset));
            
            if ( (vel2.x < 0 && child->getPosition().x + child->getContentSize().width < 0) ||
                (vel2.x > 0 && child->getPosition().x > screen.width) ) {
                
                child->setPosition(ccpAdd(child->getPosition(), ccp(-SIGN(vel2.x) * fabs(scrollOffset->getScrollOffset().x), 0)));
            }
            
            // Positive y indicates upward movement in cocos2d
            if ( (vel2.y < 0 && child->getPosition().y + child->getContentSize().height < 0) ||
                (vel2.y > 0 && child->getPosition().y > screen.height) ) {
                child->setPosition(ccpAdd(child->getPosition(), ccp(0, -SIGN(vel2.y) * fabs(scrollOffset->getScrollOffset().y))));
            }
        }
    }
 void CCParallaxScrollNode::updateWithYPosition(float y, float dt)
 {
     for (int i=scrollOffsets->num - 1; i >= 0; i--) {
         CCParallaxScrollOffset *scrollOffset = (CCParallaxScrollOffset*)scrollOffsets->arr[i];
         CCNode *child = scrollOffset->getChild();
         float offset = y * scrollOffset->getRatio().y;//ccpCompMult(pos, scrollOffset.ratio);
         child->setPosition(ccp(child->getPosition().x, scrollOffset->getOrigPosition().y + offset));
     }
 }
 void CCParallaxScrollNode::removeChild(CCSprite *node, bool cleanup)
 {
     for (int i=0; i < scrollOffsets->num; i++) {
         CCParallaxScrollOffset *scrollOffset = (CCParallaxScrollOffset*)scrollOffsets->arr[i];
         if(scrollOffset->getChild()->isEqual(node)) {
             ccArrayRemoveObjectAtIndex(scrollOffsets, i);
             break;
         }
     }
     if (batch) {
         batch->removeChild(node, cleanup);
     }
 }