The positions are updated at visit because: - using a timer is not guaranteed that it will called after all the positions were updated - overriding "draw" will only precise if the children have a z > 0 */
| 144 | - overriding "draw" will only precise if the children have a z > 0 |
| 145 | */ |
| 146 | void ParallaxNode::visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags) |
| 147 | { |
| 148 | // Vec2 pos = position_; |
| 149 | // Vec2 pos = [self convertToWorldSpace:Vec2::ZERO]; |
| 150 | Vec2 pos = this->absolutePosition(); |
| 151 | if (!pos.equals(_lastPosition)) |
| 152 | { |
| 153 | for (auto item : _parallaxArray) |
| 154 | { |
| 155 | auto point = static_cast<PointObject*>(item); |
| 156 | float x = -pos.x + pos.x * point->getRatio().x + point->getOffset().x; |
| 157 | float y = -pos.y + pos.y * point->getRatio().y + point->getOffset().y; |
| 158 | point->getChild()->setPosition(x, y); |
| 159 | } |
| 160 | _lastPosition = pos; |
| 161 | } |
| 162 | Node::visit(renderer, parentTransform, parentFlags); |
| 163 | } |
| 164 | |
| 165 | } |
nothing calls this directly
no test coverage detected