issue #2771: change PhysicsJoint::create() to PhysicsJoint::construct()

This commit is contained in:
boyu0 2013-11-07 17:46:05 +08:00
parent 7363be0697
commit e278ad66c8
3 changed files with 19 additions and 19 deletions

View File

@ -214,7 +214,7 @@ void PhysicsJoint::destroy(PhysicsJoint* joint)
}
}
PhysicsJointFixed* PhysicsJointFixed::create(PhysicsBody* a, PhysicsBody* b, const Point& anchr)
PhysicsJointFixed* PhysicsJointFixed::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr)
{
PhysicsJointFixed* joint = new PhysicsJointFixed();
@ -255,7 +255,7 @@ bool PhysicsJointFixed::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr)
return false;
}
PhysicsJointPin* PhysicsJointPin::create(PhysicsBody* a, PhysicsBody* b, const Point& anchr)
PhysicsJointPin* PhysicsJointPin::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr)
{
PhysicsJointPin* joint = new PhysicsJointPin();
@ -296,7 +296,7 @@ float PhysicsJointPin::getMaxForce() const
return PhysicsHelper::cpfloat2float(_info->getJoints().front()->maxForce);
}
PhysicsJointSliding* PhysicsJointSliding::create(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr)
PhysicsJointSliding* PhysicsJointSliding::construct(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr)
{
PhysicsJointSliding* joint = new PhysicsJointSliding();
@ -331,7 +331,7 @@ bool PhysicsJointSliding::init(PhysicsBody* a, PhysicsBody* b, const Point& groo
}
PhysicsJointLimit* PhysicsJointLimit::create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2)
PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2)
{
PhysicsJointLimit* joint = new PhysicsJointLimit();
@ -386,7 +386,7 @@ void PhysicsJointLimit::setMax(float max)
cpSlideJointSetMax(_info->getJoints().front(), PhysicsHelper::float2cpfloat(max));
}
PhysicsJointDistance* PhysicsJointDistance::create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2)
PhysicsJointDistance* PhysicsJointDistance::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2)
{
PhysicsJointDistance* joint = new PhysicsJointDistance();

View File

@ -89,7 +89,7 @@ protected:
class PhysicsJointFixed : public PhysicsJoint
{
public:
static PhysicsJointFixed* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr);
static PhysicsJointFixed* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr);
protected:
bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr);
@ -105,7 +105,7 @@ protected:
class PhysicsJointSliding : public PhysicsJoint
{
public:
static PhysicsJointSliding* create(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr);
static PhysicsJointSliding* construct(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr);
protected:
bool init(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr);
@ -121,7 +121,7 @@ protected:
class PhysicsJointSpring : public PhysicsJoint
{
public:
PhysicsJointSpring* create();
PhysicsJointSpring* construct();
protected:
bool init();
@ -137,7 +137,7 @@ protected:
class PhysicsJointLimit : public PhysicsJoint
{
public:
PhysicsJointLimit* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2);
PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2);
float getMin() const;
void setMin(float min);
@ -158,7 +158,7 @@ protected:
class PhysicsJointPin : public PhysicsJoint
{
public:
static PhysicsJointPin* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr);
static PhysicsJointPin* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr);
void setMaxForce(float force);
float getMaxForce() const;
@ -175,7 +175,7 @@ class PhysicsJointDistance : public PhysicsJoint
{
public:
static PhysicsJointDistance* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2);
static PhysicsJointDistance* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2);
protected:
bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2);

View File

@ -403,7 +403,7 @@ bool PhysicsDemo::onTouchBegan(Touch* touch, Event* event)
mouse->getPhysicsBody()->setDynamic(false);
mouse->setPosition(location);
this->addChild(mouse);
PhysicsJointPin* joint = PhysicsJointPin::create(mouse->getPhysicsBody(), shape->getBody(), location);
PhysicsJointPin* joint = PhysicsJointPin::construct(mouse->getPhysicsBody(), shape->getBody(), location);
joint->setMaxForce(5000.0f * shape->getBody()->getMass());
_scene->getPhysicsWorld()->addJoint(joint);
_mouses.insert(std::make_pair(touch->getID(), mouse));
@ -765,7 +765,7 @@ void PhysicsDemoJoints::onEnter()
auto sp2 = makeBall(offset + Point(30, 0), 10);
sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
PhysicsJointPin* joint = PhysicsJointPin::create(sp1->getPhysicsBody(), sp2->getPhysicsBody(), offset);
PhysicsJointPin* joint = PhysicsJointPin::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), offset);
_scene->getPhysicsWorld()->addJoint(joint);
this->addChild(sp1);
@ -780,7 +780,7 @@ void PhysicsDemoJoints::onEnter()
auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10));
sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
PhysicsJointFixed* joint = PhysicsJointFixed::create(sp1->getPhysicsBody(), sp2->getPhysicsBody(), offset);
PhysicsJointFixed* joint = PhysicsJointFixed::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), offset);
_scene->getPhysicsWorld()->addJoint(joint);
this->addChild(sp1);
@ -895,7 +895,7 @@ void PhysicsDemoPump::onEnter()
sgearB->setCategoryBitmask(0x04);
sgearB->setCollisionBitmask(0x04);
sgearB->setTag(1);
_world->addJoint(PhysicsJointPin::create(body, sgearB, sgearB->getPosition()));
_world->addJoint(PhysicsJointPin::construct(body, sgearB, sgearB->getPosition()));
// big gear
@ -905,7 +905,7 @@ void PhysicsDemoPump::onEnter()
bgear->setPosition(VisibleRect::leftBottom() + Point(275, 0));
this->addChild(bgear);
bgearB->setCategoryBitmask(0x04);
_world->addJoint(PhysicsJointPin::create(body, bgearB, bgearB->getPosition()));
_world->addJoint(PhysicsJointPin::construct(body, bgearB, bgearB->getPosition()));
// pump
@ -917,7 +917,7 @@ void PhysicsDemoPump::onEnter()
this->addChild(pump);
pumpB->setCategoryBitmask(0x02);
pumpB->setGravityEnable(false);
_world->addJoint(PhysicsJointDistance::create(pumpB, sgearB, Point(0, 0), Point(0, -44)));
_world->addJoint(PhysicsJointDistance::construct(pumpB, sgearB, Point(0, 0), Point(0, -44)));
// plugger
Point seg[] = {VisibleRect::leftTop() + Point(75, -120), VisibleRect::leftBottom() + Point(75, -100)};
@ -934,8 +934,8 @@ void PhysicsDemoPump::onEnter()
this->addChild(plugger);
pluggerB->setCategoryBitmask(0x02);
sgearB->setCollisionBitmask(0x04 | 0x01);
_world->addJoint(PhysicsJointPin::create(body, pluggerB, VisibleRect::leftBottom() + Point(75, -90)));
_world->addJoint(PhysicsJointDistance::create(pluggerB, sgearB, pluggerB->world2Local(VisibleRect::leftBottom() + Point(75, 0)), Point(44, 0)));
_world->addJoint(PhysicsJointPin::construct(body, pluggerB, VisibleRect::leftBottom() + Point(75, -90)));
_world->addJoint(PhysicsJointDistance::construct(pluggerB, sgearB, pluggerB->world2Local(VisibleRect::leftBottom() + Point(75, 0)), Point(44, 0)));
}
void PhysicsDemoPump::update(float delta)