| 172 | } |
| 173 | |
| 174 | void GameToolbox::alignItemsHorizontally(ax::Vector<Node*> children, float padding, Point location) |
| 175 | { |
| 176 | auto totalWidth = -padding; |
| 177 | |
| 178 | if (children.size()) |
| 179 | { |
| 180 | for (Node* child : children) |
| 181 | { |
| 182 | totalWidth += padding + (child->getContentSize().width * child->getScaleX()); |
| 183 | } |
| 184 | |
| 185 | float xPos = -(float)(totalWidth * 0.5); |
| 186 | for (Node* child : children) |
| 187 | { |
| 188 | auto width = child->getContentSize().width; |
| 189 | auto scale = child->getScaleX(); |
| 190 | |
| 191 | child->setPosition({ xPos + (width * scale) * 0.5f, 0 }); |
| 192 | child->setPosition(child->getPosition() + location); |
| 193 | |
| 194 | xPos = xPos + (float)(padding + (float)(width * child->getScaleX())); |
| 195 | } |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | void GameToolbox::alignItemsHorizontallyWithPadding(ax::Vector<ax::Node*> _children, float padding) { |
| 200 | float width = -padding; |
no test coverage detected