PhysicsBody* PhysicsBody::create() { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; }
PhysicsBody* PhysicsBody::createBox(const Size& size, const PhysicsMaterial& material, const Vec2& offset) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeBox::create(size, material, offset)); body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; }
PhysicsBody* PhysicsBody::createPolygon(const Vec2* points, int count, const PhysicsMaterial& material, const Vec2& offset) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapePolygon::create(points, count, material, offset)); body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; }
PhysicsBody* PhysicsBody::createPolygon(Point* points, int count, PhysicsMaterial material) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapePolygon::create(points, count, material)); body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; }
PhysicsBody* PhysicsBody::createCircle(float radius, const PhysicsMaterial& material, const Vec2& offset) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeCircle::create(radius, material, offset)); body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; }
PhysicsBody* PhysicsBody::createBox(Size size, PhysicsMaterial material) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeBox::create(size, material)); body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; }
PhysicsBody* PhysicsBody::createEdgeSegment(const Vec2& a, const Vec2& b, const PhysicsMaterial& material, float border/* = 1*/) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeEdgeSegment::create(a, b, material, border)); body->_dynamic = false; body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; }
PhysicsBody* PhysicsBody::createEdgeChain(const Vec2* points, int count, const PhysicsMaterial& material, float border/* = 1*/) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeEdgeChain::create(points, count, material, border)); body->_dynamic = false; body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; }
PhysicsBody* PhysicsBody::createEdgeBox(const Size& size, const PhysicsMaterial& material, float border/* = 1*/, const Vec2& offset) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeEdgeBox::create(size, material, border, offset)); body->_dynamic = false; body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; }
PhysicsBody* PhysicsBody::createEdgeBox(Size size, PhysicsMaterial material, float border/* = 1*/) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeEdgeBox::create(size, material, border)); body->_dynamic = false; body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; }
PhysicsBody* PhysicsBody::createEdgePolygon(const Vec2* points, int count, const PhysicsMaterial& material, float border/* = 1*/) { PhysicsBody* body = new (std::nothrow) PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeEdgePolygon::create(points, count, material, border)); body->setDynamic(false); body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; }
PhysicsBody* PhysicsBody::create(float mass) { PhysicsBody* body = new PhysicsBody(); if (body) { body->_mass = mass; body->_massDefault = false; if (body->init()) { body->autorelease(); return body; } } CC_SAFE_DELETE(body); return nullptr; }
PhysicsBody* PhysicsBody::create(float mass, float moment) { PhysicsBody* body = new (std::nothrow) PhysicsBody(); if (body) { body->_mass = mass; body->_massDefault = false; body->_moment = moment; body->_momentDefault = false; if (body->init()) { body->autorelease(); return body; } } CC_SAFE_DELETE(body); return nullptr; }