void ParallaxNodeExtras::incrementOffset(Point offset, Node* node){ for (int i = 0; i < _parallaxArray->num; i++) { PointObject *point = (PointObject *)_parallaxArray->arr[i]; Node * curNode = point->getChild(); if (curNode==/*->isEqual*/(node)) { point->setOffset(point->getOffset() + offset); break; } } }
void ParallaxContainer::visit(cocos2d::Renderer *renderer, const cocos2d::Mat4& parentTransform, uint32_t parentFlags) { Vec2 pos = parallaxPosition; //if (!pos.equals(_lastPosition)) { for( int i=0; i < _parallaxArray->num; i++ ) { PointObject *point = (PointObject*)_parallaxArray->arr[i]; // auto scrolling auto offset = point->getOffset(); offset.x += point->getAutoscroll().x; offset.y += point->getAutoscroll().y; point->setOffset(offset); float x = pos.x * point->getRatio().x + point->getOffset().x; float y = pos.y * point->getRatio().y + point->getOffset().y; point->getChild()->setPosition({x, y}); } _lastPosition = pos; //} Node::visit(renderer, parentTransform, parentFlags); }