| 268 | } |
| 269 | |
| 270 | bool PhysicsJointFixed::createConstraints() |
| 271 | { |
| 272 | do |
| 273 | { |
| 274 | _bodyA->getNode()->setPosition(_anchr); |
| 275 | _bodyB->getNode()->setPosition(_anchr); |
| 276 | |
| 277 | // add a pivot joint to fixed two body together |
| 278 | auto joint = cpPivotJointNew(_bodyA->getCPBody(), _bodyB->getCPBody(), PhysicsHelper::vec22cpv(_anchr)); |
| 279 | AX_BREAK_IF(joint == nullptr); |
| 280 | _cpConstraints.emplace_back(joint); |
| 281 | |
| 282 | // add a gear joint to make two body have the same rotation. |
| 283 | joint = cpGearJointNew(_bodyA->getCPBody(), _bodyB->getCPBody(), 0, 1); |
| 284 | AX_BREAK_IF(joint == nullptr); |
| 285 | _cpConstraints.emplace_back(joint); |
| 286 | |
| 287 | _collisionEnable = false; |
| 288 | |
| 289 | return true; |
| 290 | } while (false); |
| 291 | |
| 292 | return false; |
| 293 | } |
| 294 | |
| 295 | PhysicsJointPin* PhysicsJointPin::construct(PhysicsBody* a, PhysicsBody* b, const Vec2& pivot) |
| 296 | { |
no test coverage detected