From 4efacdbcf3456d9efbb3cd1a787b62d75c816059 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 8 Nov 2013 16:17:56 +0800 Subject: [PATCH] issue #2771: rename PhysicsWorld::create() to PhysicsWorld::construct(), fix some bugs --- cocos/2d/CCScene.cpp | 2 +- cocos/physics/CCPhysicsWorld.cpp | 2 +- cocos/physics/CCPhysicsWorld.h | 5 ++--- cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index 3f05e43c83..6c2a0db436 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -102,7 +102,7 @@ bool Scene::initWithPhysics() Director * pDirector; CC_BREAK_IF( ! (pDirector = Director::getInstance()) ); this->setContentSize(pDirector->getWinSize()); - CC_BREAK_IF(! (_physicsWorld = PhysicsWorld::create(*this))); + CC_BREAK_IF(! (_physicsWorld = PhysicsWorld::construct(*this))); this->scheduleUpdate(); // success diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index 5630137dc4..814bc8924b 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -987,7 +987,7 @@ void PhysicsDebugDraw::drawContact() #endif -PhysicsWorld* PhysicsWorld::create(Scene& scene) +PhysicsWorld* PhysicsWorld::construct(Scene& scene) { PhysicsWorld * world = new PhysicsWorld(); if(world && world->init(scene)) diff --git a/cocos/physics/CCPhysicsWorld.h b/cocos/physics/CCPhysicsWorld.h index b77a927df7..fc3692d9df 100644 --- a/cocos/physics/CCPhysicsWorld.h +++ b/cocos/physics/CCPhysicsWorld.h @@ -121,7 +121,7 @@ public: inline int getDebugDrawMask() { return _debugDrawMask; } protected: - static PhysicsWorld* create(Scene& scene); + static PhysicsWorld* construct(Scene& scene); bool init(Scene& scene); virtual void addBody(PhysicsBody* body); @@ -182,10 +182,9 @@ protected: class PhysicsDebugDraw { -public: +protected: virtual bool begin(); virtual void end(); - void close(); virtual void drawShape(PhysicsShape& shape); virtual void drawJoint(PhysicsJoint& joint); virtual void drawContact(); diff --git a/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h index 094a6b6c35..1b4c6ac82d 100644 --- a/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h +++ b/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h @@ -44,7 +44,7 @@ public: static float cpfloat2float(cpFloat f) { return f; } static cpFloat float2cpfloat(float f) { return f; } static cpBB rect2cpbb(const Rect& rect) { return cpBBNew(rect.origin.x, rect.origin.y, rect.origin.x + rect.size.width, rect.origin.y + rect.size.height); } - static Rect cpbb2rect(const cpBB& bb) { return Rect(bb.l, bb.b, bb.r, bb.t); } + static Rect cpbb2rect(const cpBB& bb) { return Rect(bb.l, bb.b, bb.r - bb.l, bb.t - bb.b); } static Point* cpvs2points(const cpVect* cpvs, Point* out, int count) {