From 2e01b532f450155e223cace26a97f82335c4159a Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 11 Oct 2013 13:47:15 +0800 Subject: [PATCH 01/48] issue #2771: add updatePhysicsTransform to Node. --- cocos2dx/base_nodes/CCNode.cpp | 39 +++++++++++++++--------------- cocos2dx/base_nodes/CCNode.h | 9 ++++--- cocos2dx/sprite_nodes/CCSprite.cpp | 7 +++++- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 4db892fdd6..47174c5790 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -134,8 +134,6 @@ Node::Node(void) , _oldEventPriority(0) #ifdef CC_USE_PHYSICS , _physicsBody(nullptr) -, _physicsPositionMark(true) -, _physicsRotationMark(true) #endif { // set default scheduler and actionManager @@ -272,12 +270,10 @@ void Node::setRotation(float newRotation) _transformDirty = _inverseDirty = true; #ifdef CC_USE_PHYSICS - if (_physicsBody && _physicsRotationMark) + if (_physicsBody) { _physicsBody->setRotation(newRotation); } - - _physicsRotationMark = true; #endif } @@ -364,12 +360,10 @@ void Node::setPosition(const Point& newPosition) _transformDirty = _inverseDirty = true; #ifdef CC_USE_PHYSICS - if (_physicsBody && _physicsPositionMark) + if (_physicsBody) { _physicsBody->setPosition(newPosition); } - - _physicsPositionMark = true; #endif } @@ -900,8 +894,25 @@ void Node::transformAncestors() } } +#ifdef CC_USE_PHYSICS +void Node::updatePhysicsTransform() +{ + if (_physicsBody) + { + _position = _physicsBody->getPosition(); + _rotationX = _rotationY = _physicsBody->getRotation(); + _transformDirty = _inverseDirty = true; + } +} +#endif + + void Node::transform() -{ +{ +#ifdef CC_USE_PHYSICS + updatePhysicsTransform(); +#endif + kmMat4 transfrom4x4; // Convert 3x3 into 4x4 matrix @@ -1300,16 +1311,6 @@ Point Node::convertTouchToNodeSpaceAR(Touch *touch) const void Node::updateTransform() { -#ifdef CC_USE_PHYSICS - if (_physicsBody) - { - _physicsPositionMark = false; - _physicsRotationMark = false; - setPosition(_physicsBody->getPosition()); - setRotation(_physicsBody->getRotation()); - } -#endif - // Recursively iterate over children arrayMakeObjectsPerformSelector(_children, updateTransform, Node*); } diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index 605b178bbf..575e4b5cfb 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -1384,12 +1384,17 @@ public: /** * set the PhysicsBody that let the sprite effect with physics */ - virtual void setPhysicsBody(PhysicsBody* body); + void setPhysicsBody(PhysicsBody* body); /** * get the PhysicsBody the sprite have */ PhysicsBody* getPhysicsBody() const; + + /** + * update rotation and position from physics body + */ + virtual void updatePhysicsTransform(); #endif @@ -1506,8 +1511,6 @@ protected: #ifdef CC_USE_PHYSICS PhysicsBody* _physicsBody; ///< the physicsBody the node have - bool _physicsPositionMark; ///< set this mark to false will skip the setRotation to physicsBody one time - bool _physicsRotationMark; ///< set this mark to false will skip the setPosition to physicsBody one time #endif }; diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index e1cfd9b5da..f9bb30df89 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -449,7 +449,12 @@ void Sprite::setTextureCoords(Rect rect) void Sprite::updateTransform(void) { CCASSERT(_batchNode, "updateTransform is only valid when Sprite is being rendered using an SpriteBatchNode"); - + +#ifdef CC_USE_PHYSICS + updatePhysicsTransform(); + setDirty(true); +#endif + // recalculate matrix only if it is dirty if( isDirty() ) { From 5c7603e0ce940992732214867d1f75c4f446fed2 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Mon, 14 Oct 2013 13:56:08 +0800 Subject: [PATCH 02/48] issue #2771: change angular damping to moment. (these two have different meaning, change to the correct one) --- cocos2dx/physics/CCPhysicsBody.cpp | 178 ++++++++++++------ cocos2dx/physics/CCPhysicsBody.h | 38 +++- cocos2dx/physics/CCPhysicsShape.cpp | 16 +- cocos2dx/physics/CCPhysicsShape.h | 6 +- .../Classes/PhysicsTest/PhysicsTest.cpp | 3 +- 5 files changed, 162 insertions(+), 79 deletions(-) diff --git a/cocos2dx/physics/CCPhysicsBody.cpp b/cocos2dx/physics/CCPhysicsBody.cpp index 2dc38bf286..eb98bef258 100644 --- a/cocos2dx/physics/CCPhysicsBody.cpp +++ b/cocos2dx/physics/CCPhysicsBody.cpp @@ -56,8 +56,7 @@ NS_CC_BEGIN namespace { static const float MASS_DEFAULT = 1.0; - static const float DENSITY_DEFAULT = 1.0; - static const float ANGULARDAMPING_DEFAULT = 200; + static const float MOMENT_DEFAULT = 200; } PhysicsBody::PhysicsBody() @@ -67,11 +66,11 @@ PhysicsBody::PhysicsBody() , _dynamic(true) , _enable(true) , _massDefault(true) -, _angularDampingDefault(true) +, _momentDefault(true) , _mass(MASS_DEFAULT) , _area(0.0) -, _density(DENSITY_DEFAULT) -, _angularDamping(ANGULARDAMPING_DEFAULT) +, _density(0) +, _moment(MOMENT_DEFAULT) , _tag(0) { } @@ -217,7 +216,7 @@ bool PhysicsBody::init() _info = new PhysicsBodyInfo(); CC_BREAK_IF(_info == nullptr); - _info->body = cpBodyNew(PhysicsHelper::float2cpfloat(_mass), PhysicsHelper::float2cpfloat(_angularDamping)); + _info->body = cpBodyNew(PhysicsHelper::float2cpfloat(_mass), PhysicsHelper::float2cpfloat(_moment)); CC_BREAK_IF(_info->body == nullptr); return true; @@ -233,7 +232,7 @@ void PhysicsBody::setDynamic(bool dynamic) if (dynamic) { cpBodySetMass(_info->body, PhysicsHelper::float2cpfloat(_mass)); - cpBodySetMoment(_info->body, PhysicsHelper::float2cpfloat(_angularDamping)); + cpBodySetMoment(_info->body, PhysicsHelper::float2cpfloat(_moment)); }else { cpBodySetMass(_info->body, PHYSICS_INFINITY); @@ -322,21 +321,7 @@ void PhysicsBody::addShape(PhysicsShape* shape) } } - if (shape->getAngularDumping() > 0) - { - if (shape->getAngularDumping() == INFINITY) - { - _angularDamping = INFINITY; - _angularDampingDefault = false; - cpBodySetMoment(_info->body, _angularDamping); - } - else if (_angularDamping != INFINITY) - { - _angularDamping = (_angularDampingDefault ? 0 : _angularDamping) + shape->getAngularDumping(); - _angularDampingDefault = false; - cpBodySetMoment(_info->body, _angularDamping); - } - } + addMoment(shape->getMoment()); if (_world != nullptr) _world->addShape(shape); @@ -371,12 +356,112 @@ void PhysicsBody::applyTorque(float torque) void PhysicsBody::setMass(float mass) { + if (mass <= 0) + { + return; + } + _mass = mass; _massDefault = false; + // update density + if (_mass == PHYSICS_INFINITY) + { + _density = PHYSICS_INFINITY; + } + else + { + if (_area > 0) + { + _density = _mass / _area; + }else + { + _density = 0; + } + } + cpBodySetMass(_info->body, PhysicsHelper::float2cpfloat(_mass)); } +void PhysicsBody::addMass(float mass) +{ + if (mass == PHYSICS_INFINITY) + { + mass = PHYSICS_INFINITY; + _massDefault = false; + _density = PHYSICS_INFINITY; + } + else if (mass == -PHYSICS_INFINITY) + { + return; + } + else if (_mass != PHYSICS_INFINITY) + { + if (_massDefault) + { + _mass = 0; + _massDefault = false; + } + + if (_mass + mass > 0) + { + _mass += mass; + }else + { + _mass = MASS_DEFAULT; + _massDefault = true; + } + + if (_area > 0) + { + _density = _mass / _area; + } + else + { + _density = 0; + } + } +} + +void PhysicsBody::addMoment(float moment) +{ + if (moment == PHYSICS_INFINITY) + { + // if moment is INFINITY, the moment of the body will become INFINITY + _moment = PHYSICS_INFINITY; + _momentDefault = false; + } + else if (moment == -PHYSICS_INFINITY) + { + // if moment is -INFINITY, it won't change + return; + } + else + { + // if moment of the body is INFINITY is has no effect + if (_moment != PHYSICS_INFINITY) + { + if (_momentDefault) + { + _moment = 0; + _momentDefault = false; + } + + if (_moment + moment > 0) + { + _moment += moment; + } + else + { + _moment = MOMENT_DEFAULT; + _momentDefault = true; + } + } + } + + cpBodySetMoment(_info->body, moment); +} + void PhysicsBody::setVelocity(Point velocity) { cpBodySetVel(_info->body, PhysicsHelper::point2cpv(velocity)); @@ -387,12 +472,12 @@ Point PhysicsBody::getVelocity() return PhysicsHelper::cpv2point(cpBodyGetVel(_info->body)); } -void PhysicsBody::setAngularDamping(float angularDamping) +void PhysicsBody::setMoment(float moment) { - _angularDamping = angularDamping; - _angularDampingDefault = false; + _moment = moment; + _momentDefault = false; - cpBodySetMoment(_info->body, _angularDamping); + cpBodySetMoment(_info->body, _moment); } PhysicsShape* PhysicsBody::getShapeByTag(int tag) @@ -434,42 +519,11 @@ void PhysicsBody::removeShape(PhysicsShape* shape) _shapes.erase(it); - // deduce the mass, area and angularDamping - if (_mass != PHYSICS_INFINITY && shape->getMass() != PHYSICS_INFINITY) - { - if (_mass - shape->getMass() <= 0) - { - _mass = MASS_DEFAULT; - _massDefault = true; - }else - { - _mass = _mass = shape->getMass(); - } - - _area -= shape->getArea(); - - if (_mass == PHYSICS_INFINITY) - { - _density = PHYSICS_INFINITY; - } - else if (_area > 0) - { - _density = _mass / _area; - } - else - { - _density = DENSITY_DEFAULT; - } - - if (_angularDamping - shape->getAngularDumping() > 0) - { - _angularDamping -= shape->getAngularDumping(); - }else - { - _angularDamping = ANGULARDAMPING_DEFAULT; - _angularDampingDefault = true; - } - } + // deduce the area, mass and moment + // area must update before mass, because the density changes depend on it. + _area -= shape->getArea(); + addMass(-shape->getMass()); + addMoment(-shape->getMoment()); shape->release(); } diff --git a/cocos2dx/physics/CCPhysicsBody.h b/cocos2dx/physics/CCPhysicsBody.h index 9bfd9ece3e..84507cfb00 100644 --- a/cocos2dx/physics/CCPhysicsBody.h +++ b/cocos2dx/physics/CCPhysicsBody.h @@ -172,21 +172,49 @@ public: /* * @brief set the body mass. + * @note if you need add/subtract mass to body, don't use setMass(getMass() +/- mass), because the mass of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMass() instead. */ void setMass(float mass); /* * @brief get the body mass. */ inline float getMass() { return _mass; } + /* + * @brief add mass to body. + * if _mass(mass of the body) == PHYSICS_INFINITY, it remains. + * if mass == PHYSICS_INFINITY, _mass will be PHYSICS_INFINITY. + * if mass == -PHYSICS_INFINITY, _mass will not change. + * if mass + _mass <= 0, _mass will equal to MASS_DEFAULT(1.0) + * other wise, mass = mass + _mass; + */ + void addMass(float mass); + /* + * @brief set the body moment of inertia. + * @note if you need add/subtract moment to body, don't use setMoment(getMoment() +/- moment), because the moment of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMoment() instead. + */ + void setMoment(float moment); + /* + * @brief get the body moment of inertia. + */ + inline float getMoment(float moment) { return _moment; } + /* + * @brief add moment of inertia to body. + * if _moment(moment of the body) == PHYSICS_INFINITY, it remains. + * if moment == PHYSICS_INFINITY, _moment will be PHYSICS_INFINITY. + * if moment == -PHYSICS_INFINITY, _moment will not change. + * if moment + _moment <= 0, _moment will equal to MASS_DEFAULT(1.0) + * other wise, moment = moment + _moment; + */ + void addMoment(float moment); /* * @brief set angular damping. */ - void setAngularDamping(float angularDamping); + //void setAngularDamping(float angularDamping); /* * @brief get angular damping. */ - inline float getAngularDamping() { return _angularDamping; } + //inline float getAngularDamping() { return _angularDamping; } //virtual Clonable* clone() const override; @@ -196,6 +224,7 @@ public: inline int getTag() { return _tag; } inline void setTag(int tag) { _tag = tag; } + protected: bool init(); @@ -216,11 +245,12 @@ protected: bool _dynamic; bool _enable; bool _massDefault; - bool _angularDampingDefault; + bool _momentDefault; float _mass; float _area; float _density; - float _angularDamping; + float _moment; + //float _angularDamping; int _tag; int _categoryBitmask; diff --git a/cocos2dx/physics/CCPhysicsShape.cpp b/cocos2dx/physics/CCPhysicsShape.cpp index b373e0710e..05bf303f91 100644 --- a/cocos2dx/physics/CCPhysicsShape.cpp +++ b/cocos2dx/physics/CCPhysicsShape.cpp @@ -48,7 +48,7 @@ PhysicsShape::PhysicsShape() , _type(Type::UNKNOWN) , _area(0) , _mass(0) -, _angularDamping(0) +, _moment(0) , _tag(0) , _enable(true) { @@ -234,7 +234,7 @@ bool PhysicsShapeCircle::init(float radius, PhysicsMaterial material/* = Materia _area = PhysicsHelper::cpfloat2float(cpAreaForCircle(0, radius)); _mass = _material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : _material.density * _area; - _angularDamping = _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : cpMomentForCircle(_mass, 0, radius, PhysicsHelper::point2cpv(offset)); + _moment = _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : cpMomentForCircle(_mass, 0, radius, PhysicsHelper::point2cpv(offset)); _info->add(shape); @@ -273,7 +273,7 @@ bool PhysicsShapeEdgeSegment::init(Point a, Point b, PhysicsMaterial material/* CC_BREAK_IF(shape == nullptr); _mass = PHYSICS_INFINITY; - _angularDamping = PHYSICS_INFINITY; + _moment = PHYSICS_INFINITY; _info->add(shape); @@ -311,7 +311,7 @@ bool PhysicsShapeBox::init(Size size, PhysicsMaterial material/* = MaterialDefau _area = PhysicsHelper::cpfloat2float(cpAreaForPoly(4, ((cpPolyShape*)shape)->verts)); _mass = _material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : _material.density * _area; - _angularDamping = _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : cpMomentForBox(_mass, PhysicsHelper::float2cpfloat(size.width), PhysicsHelper::float2cpfloat(size.height)); + _moment = _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : cpMomentForBox(_mass, PhysicsHelper::float2cpfloat(size.width), PhysicsHelper::float2cpfloat(size.height)); _info->add(shape); @@ -352,7 +352,7 @@ bool PhysicsShapePolygon::init(Point* points, int count, PhysicsMaterial materia _area = PhysicsHelper::cpfloat2float(cpAreaForPoly(((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts)); _mass = _material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : _material.density * _area; - _angularDamping = _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : cpMomentForPoly(_mass, ((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts, PhysicsHelper::point2cpv(offset)); + _moment = _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : cpMomentForPoly(_mass, ((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts, PhysicsHelper::point2cpv(offset)); _info->add(shape); @@ -401,7 +401,7 @@ bool PhysicsShapeEdgeBox::init(Size size, PhysicsMaterial material/* = MaterialD CC_BREAK_IF(i < 4); _mass = PHYSICS_INFINITY; - _angularDamping = PHYSICS_INFINITY; + _moment = PHYSICS_INFINITY; initEnd(); @@ -450,7 +450,7 @@ bool PhysicsShapeEdgePolygon::init(Point* points, int count, PhysicsMaterial mat CC_BREAK_IF(i < count); _mass = PHYSICS_INFINITY; - _angularDamping = PHYSICS_INFINITY; + _moment = PHYSICS_INFINITY; initEnd(); @@ -500,7 +500,7 @@ bool PhysicsShapeEdgeChain::init(Point* points, int count, PhysicsMaterial mater CC_BREAK_IF(i < count); _mass = PHYSICS_INFINITY; - _angularDamping = PHYSICS_INFINITY; + _moment = PHYSICS_INFINITY; initEnd(); diff --git a/cocos2dx/physics/CCPhysicsShape.h b/cocos2dx/physics/CCPhysicsShape.h index d754f6030b..688ccad2a6 100644 --- a/cocos2dx/physics/CCPhysicsShape.h +++ b/cocos2dx/physics/CCPhysicsShape.h @@ -79,8 +79,8 @@ public: inline PhysicsBody* getBody(){ return _body; } inline Type getType() { return _type; } inline float getArea() { return _area; } - inline float getAngularDumping() { return _angularDamping; } - void setAngularDumping(float angularDumping); + inline float getMoment() { return _moment; } + void setMoment(float moment); inline void setTag(int tag) { _tag = tag; } inline int getTag() { return _tag; } void setEnable(bool enable); @@ -115,7 +115,7 @@ protected: Type _type; float _area; float _mass; - float _angularDamping; + float _moment; PhysicsMaterial _material; int _tag; bool _enable; diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index 0ab5ba4ae4..91c67da54d 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -311,9 +311,8 @@ Node* PhysicsDemoLogoSmash::makeBall(float x, float y) auto body = PhysicsBody::createCircle(0.95, PhysicsMaterial(1, 0, 0)); body->setMass(1.0); - body->setAngularDamping(PHYSICS_INFINITY); + body->setMoment(PHYSICS_INFINITY); - //body->setDynamic(false); ball->setPhysicsBody(body); ball->setPosition(Point(x, y)); From c5a4addf97a36d7ff63fdc81d7edfc40a2432e9a Mon Sep 17 00:00:00 2001 From: boyu0 Date: Mon, 14 Oct 2013 14:05:57 +0800 Subject: [PATCH 03/48] issue #2771: add addMass() and addMoment() to body. --- cocos2dx/physics/CCPhysicsBody.cpp | 29 +++------------------- cocos2dx/physics/CCPhysicsShape.cpp | 38 +++++++++++++++++++++++------ cocos2dx/physics/CCPhysicsShape.h | 1 - 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/cocos2dx/physics/CCPhysicsBody.cpp b/cocos2dx/physics/CCPhysicsBody.cpp index eb98bef258..3d963922eb 100644 --- a/cocos2dx/physics/CCPhysicsBody.cpp +++ b/cocos2dx/physics/CCPhysicsBody.cpp @@ -294,33 +294,10 @@ void PhysicsBody::addShape(PhysicsShape* shape) shape->setBody(this); _shapes.push_back(shape); - // calculate the mass, area and desity + // calculate the area, mass, and desity + // area must update before mass, because the density changes depend on it. _area += shape->getArea(); - if (_mass == PHYSICS_INFINITY || shape->getMass() == PHYSICS_INFINITY) - { - _mass = PHYSICS_INFINITY; - _massDefault = false; - }else - { - if (shape->getMass() > 0) - { - _mass = (_massDefault ? 0 : _mass) + shape->getMass(); - _massDefault = false; - } - } - cpBodySetMass(_info->body, _mass); - - if (!_massDefault) - { - if (_mass == PHYSICS_INFINITY) - { - _density = PHYSICS_INFINITY; - }else - { - _density = _mass / _area; - } - } - + addMass(shape->getMass()); addMoment(shape->getMoment()); if (_world != nullptr) _world->addShape(shape); diff --git a/cocos2dx/physics/CCPhysicsShape.cpp b/cocos2dx/physics/CCPhysicsShape.cpp index 05bf303f91..bdfc931101 100644 --- a/cocos2dx/physics/CCPhysicsShape.cpp +++ b/cocos2dx/physics/CCPhysicsShape.cpp @@ -71,11 +71,6 @@ bool PhysicsShape::init(Type type, PhysicsMaterial material/* = MaterialDefault* return true; } -void PhysicsShape::setMass(float mass) -{ - -} - void PhysicsShape::setEnable(bool enable) { if (_enable != enable) @@ -95,9 +90,38 @@ void PhysicsShape::setEnable(bool enable) } } -void PhysicsShape::addToBody() +void PhysicsShape::setMass(float mass) { - if(_body != nullptr) _body->addShape(this); + if (mass < 0) + { + return; + } + + + if (_body) + { + _body->addMass(-_mass); + _body->addMass(mass); + }; + + _mass = mass; +} + +void PhysicsShape::setMoment(float moment) +{ + if (moment < 0) + { + return; + } + + + if (_body) + { + _body->addMoment(-_moment); + _body->addMoment(moment); + }; + + _moment = moment; } PhysicsBodyInfo* PhysicsShape::bodyInfo() const diff --git a/cocos2dx/physics/CCPhysicsShape.h b/cocos2dx/physics/CCPhysicsShape.h index 688ccad2a6..0aa7a160b6 100644 --- a/cocos2dx/physics/CCPhysicsShape.h +++ b/cocos2dx/physics/CCPhysicsShape.h @@ -85,7 +85,6 @@ public: inline int getTag() { return _tag; } void setEnable(bool enable); inline bool isEnable() { return _enable; } - void addToBody(); inline float getMass() { return _mass; } void setMass(float mass); From 613bb8912030ebc67d0d4ce49300b3d89145e9db Mon Sep 17 00:00:00 2001 From: Toru Matsuoka Date: Mon, 14 Oct 2013 20:19:21 +0900 Subject: [PATCH 04/48] Make "rename" setting usable. --- tools/project-creator/create_project.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/project-creator/create_project.py b/tools/project-creator/create_project.py index 966baaeaff..e55d7aa081 100755 --- a/tools/project-creator/create_project.py +++ b/tools/project-creator/create_project.py @@ -111,6 +111,14 @@ def processPlatformProjects(context, platform): java_package_path = os.path.join(*dst_pkg) + # rename files and folders + for item in data["rename"]: + tmp = item.replace("PACKAGE_PATH", java_package_path) + src = tmp.replace("PROJECT_NAME", context["src_project_name"]) + dst = tmp.replace("PROJECT_NAME", context["dst_project_name"]) + if os.path.exists(os.path.join(proj_path, src)): + os.rename(os.path.join(proj_path, src), os.path.join(proj_path, dst)) + # remove useless files and folders for item in data["remove"]: dst = item.replace("PROJECT_NAME", context["dst_project_name"]) From de9e831e350f9625e33c08092384756058716aec Mon Sep 17 00:00:00 2001 From: Toru Matsuoka Date: Mon, 14 Oct 2013 20:24:28 +0900 Subject: [PATCH 05/48] Fix definition of platform for ios and mac. Remove unnecessary files --- tools/project-creator/create_project.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/project-creator/create_project.py b/tools/project-creator/create_project.py index e55d7aa081..be6e38babc 100755 --- a/tools/project-creator/create_project.py +++ b/tools/project-creator/create_project.py @@ -6,9 +6,9 @@ # define global variables PLATFORMS = { - "cpp" : ["ios", "android", "win32", "mac", "linux"], - "lua" : ["ios", "android", "win32", "mac", "linux"], - "javascript" : ["ios", "android", "win32", "mac"] + "cpp" : ["ios_mac", "android", "win32", "linux"], + "lua" : ["ios_mac", "android", "win32", "linux"], + "javascript" : ["ios_mac", "android", "win32"] } From 2865ad798ba10d2971ad46522a6bc0e16350970f Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Tue, 15 Oct 2013 10:18:37 +0800 Subject: [PATCH 09/48] issues #2905:Updating project configuration for folder change. --- build/cocos2d-win32.vc2012.sln | 176 +- cocos/2d/cocos2d.vcxproj | 658 +++--- cocos/2d/cocos2d.vcxproj.filters | 1849 ++++++++--------- cocos/2d/platform/win32/CCEGLView.cpp | 2 +- cocos/2d/platform/win32/CCEGLView.h | 2 +- cocos/audio/proj.win32/CocosDenshion.vcxproj | 4 +- extensions/proj.win32/libExtensions.vcxproj | 194 +- .../proj.win32/libExtensions.vcxproj.filters | 535 +++-- .../Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj | 15 +- .../Cpp/TestCpp/proj.win32/TestCpp.vcxproj | 10 +- 10 files changed, 1654 insertions(+), 1791 deletions(-) diff --git a/build/cocos2d-win32.vc2012.sln b/build/cocos2d-win32.vc2012.sln index 497a1d991c..d8c443ec6d 100644 --- a/build/cocos2d-win32.vc2012.sln +++ b/build/cocos2d-win32.vc2012.sln @@ -1,98 +1,19 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio", "..\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio", "audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" - ProjectSection(ProjectDependencies) = postProject - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp", "..\samples\Cpp\HelloCpp\proj.win32\HelloCpp.vcxproj", "{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "cocos2dx\proj.win32\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "..\external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "scripting\lua\proj.win32\liblua.vcxproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}" - ProjectSection(ProjectDependencies) = postProject - {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" - ProjectSection(ProjectDependencies) = postProject - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp", "samples\Cpp\HelloCpp\proj.win32\HelloCpp.vcxproj", "{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCpp", "samples\Cpp\TestCpp\proj.win32\TestCpp.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CocosDragonJS", "samples\Javascript\CocosDragonJS\proj.win32\CocosDragonJS.vcxproj", "{68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}" - ProjectSection(ProjectDependencies) = postProject - {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} - {39379840-825A-45A0-B363-C09FFEF864BD} = {39379840-825A-45A0-B363-C09FFEF864BD} - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} - {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MoonWarriors", "samples\Javascript\MoonWarriors\proj.win32\MoonWarriors.vcxproj", "{1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}" - ProjectSection(ProjectDependencies) = postProject - {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} - {39379840-825A-45A0-B363-C09FFEF864BD} = {39379840-825A-45A0-B363-C09FFEF864BD} - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} - {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestJavascript", "samples\Javascript\TestJavascript\proj.win32\TestJavascript.vcxproj", "{D0F06A44-A245-4D13-A498-0120C203B539}" - ProjectSection(ProjectDependencies) = postProject - {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} - {39379840-825A-45A0-B363-C09FFEF864BD} = {39379840-825A-45A0-B363-C09FFEF864BD} - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} - {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WatermelonWithMe", "samples\Javascript\WatermelonWithMe\proj.win32\WatermelonWithMe.vcxproj", "{BE092D9E-95AE-4F86-84CE-F4519E4F3F15}" - ProjectSection(ProjectDependencies) = postProject - {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} - {39379840-825A-45A0-B363-C09FFEF864BD} = {39379840-825A-45A0-B363-C09FFEF864BD} - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} - {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "samples\Lua\HelloLua\proj.win32\HelloLua.vcxproj", "{13E55395-94A2-4CD9-BFC2-1A051F80C17D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLua", "samples\Lua\TestLua\proj.win32\TestLua.win32.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}" - ProjectSection(ProjectDependencies) = postProject - {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} - {DDC3E27F-004D-4DD4-9DD3-931A013D2159} = {DDC3E27F-004D-4DD4-9DD3-931A013D2159} - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} - {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "scripting\javascript\bindings\proj.win32\libJSBinding.vcxproj", "{39379840-825A-45A0-B363-C09FFEF864BD}" - ProjectSection(ProjectDependencies) = postProject - {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrystalCraze", "samples\Javascript\CrystalCraze\proj.win32\CrystalCraze.vcxproj", "{9A17D9A4-4B11-4E32-94F6-895FF4909EC5}" - ProjectSection(ProjectDependencies) = postProject - {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} - {39379840-825A-45A0-B363-C09FFEF864BD} = {39379840-825A-45A0-B363-C09FFEF864BD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetsManagerTest", "samples\Cpp\AssetsManagerTest\proj.win32\AssetsManagerTest.vcxproj", "{6D37505F-A890-441D-BD3F-A61E2C0469CE}" - ProjectSection(ProjectDependencies) = postProject - {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} - {39379840-825A-45A0-B363-C09FFEF864BD} = {39379840-825A-45A0-B363-C09FFEF864BD} - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCpp", "..\samples\Cpp\TestCpp\proj.win32\TestCpp.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -100,14 +21,6 @@ Global Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32 - {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32 - {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32 - {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32 - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.ActiveCfg = Debug|Win32 - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.Build.0 = Debug|Win32 - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.ActiveCfg = Release|Win32 - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.Build.0 = Release|Win32 {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.ActiveCfg = Debug|Win32 {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.Build.0 = Debug|Win32 {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.ActiveCfg = Release|Win32 @@ -116,81 +29,30 @@ Global {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32 - {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.ActiveCfg = Debug|Win32 - {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.Build.0 = Debug|Win32 - {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.ActiveCfg = Release|Win32 - {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.Build.0 = Release|Win32 - {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.ActiveCfg = Debug|Win32 - {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32 - {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32 - {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.ActiveCfg = Debug|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.Build.0 = Debug|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.ActiveCfg = Release|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.Build.0 = Release|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32 + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.ActiveCfg = Debug|Win32 + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.Build.0 = Debug|Win32 + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.ActiveCfg = Release|Win32 + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.Build.0 = Release|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.ActiveCfg = Debug|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.ActiveCfg = Debug|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.Build.0 = Debug|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.ActiveCfg = Release|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.Build.0 = Release|Win32 - {68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}.Debug|Win32.ActiveCfg = Debug|Win32 - {68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}.Debug|Win32.Build.0 = Debug|Win32 - {68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}.Release|Win32.ActiveCfg = Release|Win32 - {68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}.Release|Win32.Build.0 = Release|Win32 - {1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}.Debug|Win32.ActiveCfg = Debug|Win32 - {1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}.Debug|Win32.Build.0 = Debug|Win32 - {1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}.Release|Win32.ActiveCfg = Release|Win32 - {1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}.Release|Win32.Build.0 = Release|Win32 - {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.ActiveCfg = Debug|Win32 - {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.Build.0 = Debug|Win32 - {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.ActiveCfg = Release|Win32 - {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.Build.0 = Release|Win32 - {BE092D9E-95AE-4F86-84CE-F4519E4F3F15}.Debug|Win32.ActiveCfg = Debug|Win32 - {BE092D9E-95AE-4F86-84CE-F4519E4F3F15}.Debug|Win32.Build.0 = Debug|Win32 - {BE092D9E-95AE-4F86-84CE-F4519E4F3F15}.Release|Win32.ActiveCfg = Release|Win32 - {BE092D9E-95AE-4F86-84CE-F4519E4F3F15}.Release|Win32.Build.0 = Release|Win32 - {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.ActiveCfg = Debug|Win32 - {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.Build.0 = Debug|Win32 - {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.ActiveCfg = Release|Win32 - {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.Build.0 = Release|Win32 - {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.ActiveCfg = Debug|Win32 - {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.Build.0 = Debug|Win32 - {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.ActiveCfg = Release|Win32 - {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.Build.0 = Release|Win32 - {39379840-825A-45A0-B363-C09FFEF864BD}.Debug|Win32.ActiveCfg = Debug|Win32 - {39379840-825A-45A0-B363-C09FFEF864BD}.Debug|Win32.Build.0 = Debug|Win32 - {39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.ActiveCfg = Release|Win32 - {39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.Build.0 = Release|Win32 - {9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Debug|Win32.ActiveCfg = Debug|Win32 - {9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Debug|Win32.Build.0 = Debug|Win32 - {9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Release|Win32.ActiveCfg = Release|Win32 - {9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Release|Win32.Build.0 = Release|Win32 - {6D37505F-A890-441D-BD3F-A61E2C0469CE}.Debug|Win32.ActiveCfg = Debug|Win32 - {6D37505F-A890-441D-BD3F-A61E2C0469CE}.Debug|Win32.Build.0 = Debug|Win32 - {6D37505F-A890-441D-BD3F-A61E2C0469CE}.Release|Win32.ActiveCfg = Release|Win32 - {6D37505F-A890-441D-BD3F-A61E2C0469CE}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {F51B8DCB-62CD-441F-B85D-43BD8EA432F1} - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F51B8DCB-62CD-441F-B85D-43BD8EA432F1} - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {F51B8DCB-62CD-441F-B85D-43BD8EA432F1} - {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {F51B8DCB-62CD-441F-B85D-43BD8EA432F1} - {929480E7-23C0-4DF6-8456-096D71547116} = {F51B8DCB-62CD-441F-B85D-43BD8EA432F1} - {13E55395-94A2-4CD9-BFC2-1A051F80C17D} = {69C8AC8E-8B5C-474C-950D-1DB7F367E22C} - {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED} = {69C8AC8E-8B5C-474C-950D-1DB7F367E22C} - {DDC3E27F-004D-4DD4-9DD3-931A013D2159} = {69C8AC8E-8B5C-474C-950D-1DB7F367E22C} - {76A39BB2-9B84-4C65-98A5-654D86B86F2A} = {8DFE8821-1A1A-4894-9EA1-2A211F8CEDEA} - {B8BF9E81-35FD-4582-BA1C-B85FA365BABB} = {8DFE8821-1A1A-4894-9EA1-2A211F8CEDEA} - {6D37505F-A890-441D-BD3F-A61E2C0469CE} = {8DFE8821-1A1A-4894-9EA1-2A211F8CEDEA} - {1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2} = {42FCBD79-852E-4A68-9C3F-51200BAF5732} - {D0F06A44-A245-4D13-A498-0120C203B539} = {42FCBD79-852E-4A68-9C3F-51200BAF5732} - {BE092D9E-95AE-4F86-84CE-F4519E4F3F15} = {42FCBD79-852E-4A68-9C3F-51200BAF5732} - {68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7} = {42FCBD79-852E-4A68-9C3F-51200BAF5732} - {39379840-825A-45A0-B363-C09FFEF864BD} = {42FCBD79-852E-4A68-9C3F-51200BAF5732} - {9A17D9A4-4B11-4E32-94F6-895FF4909EC5} = {42FCBD79-852E-4A68-9C3F-51200BAF5732} - EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} EndGlobalSection diff --git a/cocos/2d/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj index 46a695d1e2..0c421489f9 100644 --- a/cocos/2d/cocos2d.vcxproj +++ b/cocos/2d/cocos2d.vcxproj @@ -69,7 +69,7 @@ Disabled - $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir)..;$(ProjectDir)..\platform\win32;$(ProjectDir)..\platform\third_party\win32\iconv;$(ProjectDir)..\platform\third_party\win32\zlib;$(ProjectDir)..\platform\third_party\win32\libpng;$(ProjectDir)..\platform\third_party\win32\libjpeg;$(ProjectDir)..\platform\third_party\win32\libtiff;$(ProjectDir)..\platform\third_party\win32\libwebp;$(ProjectDir)..\platform\third_party\win32\libfreetype2;$(ProjectDir)..\platform\third_party\win32\OGLES;..\include;$(ProjectDir)..\kazmath\include;$(ProjectDir)..\platform\third_party\common\etc;$(ProjectDir)..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir);$(ProjectDir)..\physics;$(ProjectDir)..\..\external\glfw3\include\win32;$(ProjectDir)..\base;$(ProjectDir)..\..\external\unzip;$(ProjectDir)..\..\external\tinyxml2;$(ProjectDir)platform\win32;$(ProjectDir)..\..\external\win32-specific\icon\include;$(ProjectDir)..\..\external\win32-specific\zlib\include;$(ProjectDir)..\..\external\png\include\win32;$(ProjectDir)..\..\external\jpeg\include\win32;$(ProjectDir)..\..\external\tiff\include\win32;$(ProjectDir)..\..\external\webp\include\win32;$(ProjectDir)..\..\external\freetype2\include\win32;$(ProjectDir)..\..\external\win32-specific\gles\include\OGLES;$(ProjectDir)..\math\kazmath\include;$(ProjectDir)platform\third_party\common\etc;$(ProjectDir)..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -83,7 +83,16 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\freetype2\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\glfw3\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\curl\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\jpeg\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\png\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\tiff\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\webp\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\zlib\prebuilt\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\icon\prebuilt\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(OutDir)" @@ -119,7 +128,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external*\win32\*.*" "$(OutDir)" @@ -140,79 +149,36 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -228,162 +194,158 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -402,101 +364,147 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cocos/2d/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters index 391517347c..2028e708c8 100644 --- a/cocos/2d/cocos2d.vcxproj.filters +++ b/cocos/2d/cocos2d.vcxproj.filters @@ -4,9 +4,6 @@ {cc64f5ad-2234-494c-9c51-b7a20c8887aa} - - {aec8225f-81a7-4213-b97b-7004d5535398} - {736cf4ab-e0d6-40ba-912a-b062d28d318a} @@ -67,21 +64,6 @@ {7751500e-ac9e-4604-a96d-670b30b7d8bd} - - {b38113b1-3d59-4f6e-ac5a-f43921f6ed09} - - - {569c49c9-27eb-456e-a3f4-9f403e28a3a1} - - - {191b3e94-47dc-4054-b1cb-bf145d281521} - - - {a91a4cc0-41e6-43e9-80c0-2c9101924386} - - - {e278b354-1e41-4e92-95b3-7f661ba67140} - {163895ae-8a8e-46bf-bdf2-98bb2c1347fc} @@ -112,397 +94,26 @@ {b9880458-36e5-4f28-a34b-d01d9512a395} + + {05e27e68-7574-4a8b-af68-553dd3bafdfa} + + + {b797075f-7437-46d5-b4ee-2aa2c108e98f} + + + {c755509d-1610-4e6c-b01b-e01d4d0de46e} + + + {e1b64497-c099-4f06-8d61-9d4c6b7a215a} + + + {7c71abeb-8b4b-4be8-a23c-e32fedc65fc9} + + + {aec8225f-81a7-4213-b97b-7004d5535398} + - - base_nodes - - - base_nodes - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - effects - - - effects - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - label_nodes - - - label_nodes - - - label_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - menu_nodes - - - menu_nodes - - - misc_nodes - - - misc_nodes - - - misc_nodes - - - particle_nodes - - - particle_nodes - - - particle_nodes - - - particle_nodes - - - platform - - - platform - - - platform - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - support - - - support - - - support - - - support - - - support - - - support - - - support\data_support - - - support\image_support - - - support\zip_support - - - support\zip_support - - - support\zip_support - - - textures - - - textures - - - textures - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - text_input_node - - - text_input_node - - - script_support - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src\GL - - - kazmath\src\GL - - - - - - - - draw_nodes - - - draw_nodes - - - misc_nodes - - - shaders - - - shaders - - - shaders - - - shaders - - - platform\win32 - - - platform - - - platform\win32 - - - support - - - support\user_default - - - support\tinyxml2 - - - cocoa - - - - support\component - - - support\component - - - - platform\etc - - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - platform - - - platform - - - event_dispatcher - - - event_dispatcher - - - event_dispatcher - - - event_dispatcher - physics @@ -548,535 +159,421 @@ physics\Box2D - + + base_nodes + + + base_nodes + + + effects + + + effects + + event_dispatcher - + event_dispatcher - + event_dispatcher - + event_dispatcher - + event_dispatcher - + event_dispatcher - + event_dispatcher - + event_dispatcher + + event_dispatcher + + + event_dispatcher + + + event_dispatcher + + + event_dispatcher + + + kazmath\src\GL + + + kazmath\src\GL + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + menu_nodes + + + menu_nodes + + + misc_nodes + + + misc_nodes + + + misc_nodes + + + misc_nodes + + + particle_nodes + + + particle_nodes + + + particle_nodes + + + particle_nodes + + + script_support + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + draw_nodes + + + draw_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + platform\etc + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + shaders + + + shaders + + + shaders + + + shaders + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + text_input_node + + + text_input_node + + + textures + + + textures + + + textures + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + + + + + + + + + support + + + support + + + support + + + support + + + support + + + support + + + support\component + + + support\component + + + support\data_support + + + support\image_support + + + support\tinyxml2 + + + support\user_default + + + support\zip_support + + + support\zip_support + + + support\zip_support + + + base + + + base + + + base + + + base + + + base + + + base + + + base + + + base + + + base + + + base + + + base + + + support + - - base_nodes - - - base_nodes - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - effects - - - effects - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - include - - - include - - - include - - - include - - - include - - - include - - - label_nodes - - - label_nodes - - - label_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - menu_nodes - - - menu_nodes - - - misc_nodes - - - misc_nodes - - - misc_nodes - - - particle_nodes - - - particle_nodes - - - particle_nodes - - - particle_nodes - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - support - - - support - - - support - - - support - - - support - - - support - - - support\data_support - - - support\data_support - - - support\data_support - - - support\image_support - - - support\zip_support - - - support\zip_support - - - support\zip_support - - - textures - - - textures - - - textures - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - text_input_node - - - text_input_node - - - text_input_node - - - script_support - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath\GL - - - kazmath\include\kazmath\GL - - - - - - - draw_nodes - - - draw_nodes - - - misc_nodes - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - platform\win32 - - - support - - - support\user_default - - - support\tinyxml2 - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - - support\component - - - support\component - - - include - - - platform\etc - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - label_nodes - - - platform - - - platform - - - platform - - - event_dispatcher - - - event_dispatcher - - - event_dispatcher - - - event_dispatcher - physics @@ -1131,29 +628,529 @@ physics\Box2D - + + base_nodes + + + base_nodes + + + effects + + + effects + + event_dispatcher - + event_dispatcher - + event_dispatcher - + event_dispatcher - + event_dispatcher - + event_dispatcher - + event_dispatcher - + event_dispatcher + + event_dispatcher + + + event_dispatcher + + + event_dispatcher + + + event_dispatcher + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath\GL + + + kazmath\include\kazmath\GL + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + menu_nodes + + + menu_nodes + + + misc_nodes + + + misc_nodes + + + misc_nodes + + + misc_nodes + + + particle_nodes + + + particle_nodes + + + particle_nodes + + + particle_nodes + + + script_support + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + draw_nodes + + + draw_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + label_nodes + + + platform\etc + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + text_input_node + + + text_input_node + + + text_input_node + + + textures + + + textures + + + textures + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + + + + + + support + + + support + + + support + + + support + + + support + + + support + + + support + + + support\component + + + support\component + + + support\data_support + + + support\data_support + + + support\data_support + + + support\image_support + + + support\tinyxml2 + + + support\user_default + + + support\zip_support + + + support\zip_support + + + support\zip_support + + + base + + + base + + + base + + + base + + + base + + + base + + + base + + + base + + + base + + + base + + + base + + + base + + + base + + + base + + + base + \ No newline at end of file diff --git a/cocos/2d/platform/win32/CCEGLView.cpp b/cocos/2d/platform/win32/CCEGLView.cpp index 4099331cf9..d5b2ba0202 100644 --- a/cocos/2d/platform/win32/CCEGLView.cpp +++ b/cocos/2d/platform/win32/CCEGLView.cpp @@ -26,7 +26,7 @@ THE SOFTWARE. #include "CCSet.h" #include "ccMacros.h" #include "CCDirector.h" -#include "/CCIMEDispatcher.h" +#include "CCIMEDispatcher.h" #include "CCApplication.h" #include "CCTouch.h" #include "CCEventDispatcher.h" diff --git a/cocos/2d/platform/win32/CCEGLView.h b/cocos/2d/platform/win32/CCEGLView.h index 643b500c66..59432e27ba 100644 --- a/cocos/2d/platform/win32/CCEGLView.h +++ b/cocos/2d/platform/win32/CCEGLView.h @@ -30,7 +30,7 @@ THE SOFTWARE. #include "CCGeometry.h" #include "platform/CCEGLViewProtocol.h" -#include "platform/third_party/win32/GLFW/glfw3.h" +#include "glfw3.h" NS_CC_BEGIN diff --git a/cocos/audio/proj.win32/CocosDenshion.vcxproj b/cocos/audio/proj.win32/CocosDenshion.vcxproj index d5a959c878..b59c65d98c 100644 --- a/cocos/audio/proj.win32/CocosDenshion.vcxproj +++ b/cocos/audio/proj.win32/CocosDenshion.vcxproj @@ -11,7 +11,7 @@ - libCocosDenshion + audio {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} CocosDenshion.win32 Win32Proj @@ -65,7 +65,7 @@ Disabled - $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;$(ProjectDir)..\..\cocos2dx;$(ProjectDir)..\..\cocos2dx\include;$(ProjectDir)..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;$(ProjectDir)..\..\physics;$(ProjectDir)..\..\base;$(ProjectDir)..\..\2d;$(ProjectDir)..\..\2d\platform\win32;$(ProjectDir)..\..\math\kazmath\include;$(ProjectDir)..\..\..\external\glfw3\include\win32;$(ProjectDir)..\..\..\external\win32-specific\gles\include\OGLES;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks diff --git a/extensions/proj.win32/libExtensions.vcxproj b/extensions/proj.win32/libExtensions.vcxproj index e1c2ea14a1..25597c43e3 100644 --- a/extensions/proj.win32/libExtensions.vcxproj +++ b/extensions/proj.win32/libExtensions.vcxproj @@ -92,36 +92,48 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - @@ -141,11 +153,6 @@ - - - - - @@ -168,13 +175,6 @@ - - - - - - - @@ -223,39 +223,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -275,11 +294,6 @@ - - - - - @@ -303,20 +317,6 @@ - - - - - - - - - - - - - - @@ -372,10 +372,10 @@ - - - - + + + + diff --git a/extensions/proj.win32/libExtensions.vcxproj.filters b/extensions/proj.win32/libExtensions.vcxproj.filters index e6d6f2354c..766af1001f 100644 --- a/extensions/proj.win32/libExtensions.vcxproj.filters +++ b/extensions/proj.win32/libExtensions.vcxproj.filters @@ -102,75 +102,6 @@ GUI\CCScrollView - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - GUI\CCControlExtension @@ -225,9 +156,6 @@ GUI\CCEditBox - - AssetsManager - spine @@ -298,18 +226,6 @@ network - - CocoStudio\Components - - - CocoStudio\Components - - - CocoStudio\Components - - - CocoStudio\Components - CocoStudio\Armature\animation @@ -364,27 +280,6 @@ CocoStudio\Armature - - CocoStudio\Json - - - CocoStudio\Json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Reader - - - CocoStudio\Components - CocoStudio\Armature\utils @@ -454,9 +349,6 @@ CocoStudio\GUI\System - - CocoStudio\Reader - CocoStudio\GUI\UIWidgets\ScrollWidget @@ -505,9 +397,6 @@ CocoStudio\GUI\Layouts - - CocoStudio\GUI\Layouts - CocoStudio\GUI\Layouts @@ -529,21 +418,129 @@ CocoStudio\Reader - + + AssetsManager + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + CocoStudio\Action - + CocoStudio\Action - + CocoStudio\Action - + CocoStudio\Action - + CocoStudio\Action + + CocoStudio\Components + + + CocoStudio\Components + + + CocoStudio\Components + + + CocoStudio\Components + + + CocoStudio\Components + + + CocoStudio\Reader + + + CocoStudio\Reader + + + CocoStudio\Json + + + CocoStudio\Json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + @@ -569,87 +566,6 @@ GUI\CCScrollView - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - GUI\CCControlExtension @@ -710,9 +626,6 @@ GUI\CCEditBox - - AssetsManager - spine @@ -785,18 +698,6 @@ network - - CocoStudio\Components - - - CocoStudio\Components - - - CocoStudio\Components - - - CocoStudio\Components - CocoStudio\Armature\animation @@ -854,48 +755,6 @@ CocoStudio\Armature - - CocoStudio\Json - - - CocoStudio\Json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Reader - - - CocoStudio\Components - CocoStudio\GUI\UIWidgets\ScrollWidget @@ -965,36 +824,174 @@ CocoStudio\GUI\System - + + AssetsManager + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CocoStudio\Action + + + CocoStudio\Action + + + CocoStudio\Action + + + CocoStudio\Action + + + CocoStudio\Action + + + CocoStudio\Components + + + CocoStudio\Components + + + CocoStudio\Components + + + CocoStudio\Components + + + CocoStudio\Components + + CocoStudio\Reader - - CocoStudio\Action + + CocoStudio\Reader - - CocoStudio\Action + + CocoStudio\Json - - CocoStudio\Action + + CocoStudio\Json - - CocoStudio\Action + + CocoStudio\Json\lib_json - - CocoStudio\Action + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json - + CocoStudio\Json\lib_json - + CocoStudio\Json\lib_json - + CocoStudio\Json\lib_json - + CocoStudio\Json\lib_json diff --git a/samples/Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj b/samples/Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj index 1f00dbf6ea..233a21ce9c 100644 --- a/samples/Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj +++ b/samples/Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj @@ -36,11 +36,10 @@ - + - - - + + @@ -67,7 +66,7 @@ Disabled - $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;..\Classes;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(ProjectDir)..\..\..\..\cocos\2d;$(ProjectDir)..\..\..\..\cocos\base;$(ProjectDir)..\..\..\..\cocos\physics;$(ProjectDir)..\..\..\..\cocos\math\kazmath\include;$(ProjectDir)..\..\..\..\cocos\2d\platform\win32;$(ProjectDir)..\..\..\..\external\glfw3\include\win32;$(ProjectDir)..\..\..\..\external\win32-specific\gles\include\OGLES;..\Classes;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks @@ -95,7 +94,7 @@ MaxSpeed true - $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;..\Classes;%(AdditionalIncludeDirectories) + $(ProjectDir)..\..\..\..\cocos\2d;$(ProjectDir)..\..\..\..\cocos\2d\include;$(ProjectDir)..\..\..\..\cocos\math\kazmath\include;$(ProjectDir)..\..\..\..\cocos\2d\platform\win32;$(ProjectDir)..\..\..\..\external\win32-specific\gles\include\OGLES;..\Classes;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true @@ -132,11 +131,11 @@ - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} false - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} false diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj index 95e857631c..d9227050c3 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj @@ -36,11 +36,11 @@ - + - + @@ -67,7 +67,7 @@ Disabled - $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\external;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\audio\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\extensions\network;..\Classes;..;%(AdditionalIncludeDirectories) + $(ProjectDir)..\..\..\..\cocos\physics;$(ProjectDir)..\..\..\..\cocos\base;$(ProjectDir)..\..\..\..\cocos\2d;$(ProjectDir)..\..\..\..\cocos\math\kazmath\include;$(ProjectDir)..\..\..\..\cocos\2d\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\external\win32-specific\gles\include\OGLES;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\external;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\external\glfw3\include\win32;$(ProjectDir)..\..\..\..\external\websockets\win32\include;$(ProjectDir)..\..\..\..\cocos\audio\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\cocos\network;..\Classes;..;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL @@ -459,11 +459,11 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} false - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} false From f7dc3bb98f606bc493a644796ef5446557525927 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Tue, 15 Oct 2013 13:48:01 +0800 Subject: [PATCH 10/48] issue #2771: migrate the PhysicsShape definition --- cocos2dx/cocoa/CCGeometry.cpp | 24 ++ cocos2dx/cocoa/CCGeometry.h | 20 ++ cocos2dx/physics/CCPhysicsBody.cpp | 8 +- cocos2dx/physics/CCPhysicsShape.cpp | 349 ++++++++++++++++---- cocos2dx/physics/CCPhysicsShape.h | 84 ++++- cocos2dx/physics/CCPhysicsWorld.cpp | 5 +- cocos2dx/physics/chipmunk/CCPhysicsHelper.h | 2 +- 7 files changed, 402 insertions(+), 90 deletions(-) diff --git a/cocos2dx/cocoa/CCGeometry.cpp b/cocos2dx/cocoa/CCGeometry.cpp index cfce9d3fa7..1d5c4896c6 100644 --- a/cocos2dx/cocoa/CCGeometry.cpp +++ b/cocos2dx/cocoa/CCGeometry.cpp @@ -62,16 +62,40 @@ Point Point::operator+(const Point& right) const return Point(this->x + right.x, this->y + right.y); } +Point& Point::operator+=(const Point& right) +{ + this->x += right.x; + this->y += right.y; + return *this; +} + Point Point::operator-(const Point& right) const { return Point(this->x - right.x, this->y - right.y); } +Point& Point::operator-=(const Point& right) +{ + this->x -= right.x; + this->y -= right.y; + return *this; +} + Point Point::operator-() const { return Point(-x, -y); } +bool Point::operator==(const Point& right) +{ + return this->x == right.x && this->y == right.y; +} + +bool Point::operator!=(const Point& right) +{ + return this->x != right.x || this->y != right.y; +} + Point Point::operator*(float a) const { return Point(this->x * a, this->y * a); diff --git a/cocos2dx/cocoa/CCGeometry.h b/cocos2dx/cocoa/CCGeometry.h index 47e2fdf9ac..94bbf3fb10 100644 --- a/cocos2dx/cocoa/CCGeometry.h +++ b/cocos2dx/cocoa/CCGeometry.h @@ -93,16 +93,36 @@ public: * @lua NA */ Point operator+(const Point& right) const; + /** + * @js NA + * @lua NA + */ + Point& operator+=(const Point& right); /** * @js NA * @lua NA */ Point operator-(const Point& right) const; + /** + * @js NA + * @lua NA + */ + Point& operator-=(const Point& right); /** * @js NA * @lua NA */ Point operator-() const; + /** + * @js NA + * @lua NA + */ + bool operator==(const Point& right); + /** + * @js NA + * @lua NA + */ + bool operator!=(const Point& right); /** * @js NA * @lua NA diff --git a/cocos2dx/physics/CCPhysicsBody.cpp b/cocos2dx/physics/CCPhysicsBody.cpp index 3d963922eb..fee8712353 100644 --- a/cocos2dx/physics/CCPhysicsBody.cpp +++ b/cocos2dx/physics/CCPhysicsBody.cpp @@ -364,7 +364,7 @@ void PhysicsBody::addMass(float mass) { if (mass == PHYSICS_INFINITY) { - mass = PHYSICS_INFINITY; + _mass = PHYSICS_INFINITY; _massDefault = false; _density = PHYSICS_INFINITY; } @@ -398,6 +398,8 @@ void PhysicsBody::addMass(float mass) _density = 0; } } + + cpBodySetMass(_info->body, PhysicsHelper::float2cpfloat(_mass)); } void PhysicsBody::addMoment(float moment) @@ -436,7 +438,7 @@ void PhysicsBody::addMoment(float moment) } } - cpBodySetMoment(_info->body, moment); + cpBodySetMoment(_info->body, PhysicsHelper::float2cpfloat(_moment)); } void PhysicsBody::setVelocity(Point velocity) @@ -454,7 +456,7 @@ void PhysicsBody::setMoment(float moment) _moment = moment; _momentDefault = false; - cpBodySetMoment(_info->body, _moment); + cpBodySetMoment(_info->body, PhysicsHelper::float2cpfloat(_moment)); } PhysicsShape* PhysicsBody::getShapeByTag(int tag) diff --git a/cocos2dx/physics/CCPhysicsShape.cpp b/cocos2dx/physics/CCPhysicsShape.cpp index bdfc931101..abc4b4691b 100644 --- a/cocos2dx/physics/CCPhysicsShape.cpp +++ b/cocos2dx/physics/CCPhysicsShape.cpp @@ -50,7 +50,6 @@ PhysicsShape::PhysicsShape() , _mass(0) , _moment(0) , _tag(0) -, _enable(true) { } @@ -60,36 +59,16 @@ PhysicsShape::~PhysicsShape() CC_SAFE_DELETE(_info); } -bool PhysicsShape::init(Type type, PhysicsMaterial material/* = MaterialDefault*/) +bool PhysicsShape::init(Type type) { _info = new PhysicsShapeInfo(this); if (_info == nullptr) return false; _type = type; - _material = material; return true; } -void PhysicsShape::setEnable(bool enable) -{ - if (_enable != enable) - { - _enable = enable; - - if (_body->getWorld() && _body->isEnable()) - { - if (enable) - { - _body->getWorld()->addShape(this); - }else - { - _body->getWorld()->removeShape(this); - } - } - } -} - void PhysicsShape::setMass(float mass) { if (mass < 0) @@ -97,7 +76,6 @@ void PhysicsShape::setMass(float mass) return; } - if (_body) { _body->addMass(-_mass); @@ -114,7 +92,6 @@ void PhysicsShape::setMoment(float moment) return; } - if (_body) { _body->addMoment(-_moment); @@ -124,6 +101,13 @@ void PhysicsShape::setMoment(float moment) _moment = moment; } +void PhysicsShape::setMaterial(PhysicsMaterial material) +{ + setDensity(material.density); + setRestitution(material.restitution); + setFriction(material.friction); +} + PhysicsBodyInfo* PhysicsShape::bodyInfo() const { if (_body != nullptr) @@ -206,32 +190,72 @@ PhysicsShapeEdgeSegment::~PhysicsShapeEdgeSegment() } #if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) - -void PhysicsShape::initEnd() +void PhysicsShape::setDensity(float density) { - for (auto shape : _info->shapes) + if (density < 0) { - cpShapeSetElasticity(shape, _material.elasticity); - cpShapeSetFriction(shape, _material.friction); + return; + } + + _material.density = density; + + if (_material.density == PHYSICS_INFINITY) + { + setMass(PHYSICS_INFINITY); + }else if (_area > 0) + { + setMass(PhysicsHelper::float2cpfloat(_material.density * _area)); } } -void PhysicsShape::setElasticity(float elasticity) +void PhysicsShape::setRestitution(float restitution) { + _material.restitution = restitution; + for (cpShape* shape : _info->shapes) { - cpShapeSetElasticity(shape, PhysicsHelper::float2cpfloat(elasticity)); + cpShapeSetElasticity(shape, PhysicsHelper::float2cpfloat(restitution)); } } void PhysicsShape::setFriction(float friction) { + _material.friction = friction; + for (cpShape* shape : _info->shapes) { cpShapeSetFriction(shape, PhysicsHelper::float2cpfloat(friction)); } } + +Point* PhysicsShape::recenterPoints(Point* points, int count, Point center) +{ + cpVect* cpvs = new cpVect[count]; + cpRecenterPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count)); + PhysicsHelper::cpvs2points(cpvs, points, count); + delete[] cpvs; + + if (center != Point::ZERO) + { + for (int i = 0; i < count; ++i) + { + points[i] += center; + } + } + + return points; +} + +Point PhysicsShape::getPolyonCenter(Point* points, int count) +{ + cpVect* cpvs = new cpVect[count]; + cpVect center = cpCentroidForPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count)); + delete[] cpvs; + + return PhysicsHelper::cpv2point(center); +} + // PhysicsShapeCircle PhysicsShapeCircle* PhysicsShapeCircle::create(float radius, PhysicsMaterial material/* = MaterialDefault*/, Point offset/* = Point(0, 0)*/) { @@ -250,25 +274,65 @@ bool PhysicsShapeCircle::init(float radius, PhysicsMaterial material/* = Materia { do { - CC_BREAK_IF(!PhysicsShape::init(Type::CIRCLE, material)); + CC_BREAK_IF(!PhysicsShape::init(Type::CIRCLE)); cpShape* shape = cpCircleShapeNew(_info->shareBody, radius, PhysicsHelper::point2cpv(offset)); CC_BREAK_IF(shape == nullptr); - _area = PhysicsHelper::cpfloat2float(cpAreaForCircle(0, radius)); - _mass = _material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : _material.density * _area; - _moment = _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : cpMomentForCircle(_mass, 0, radius, PhysicsHelper::point2cpv(offset)); - _info->add(shape); - initEnd(); + _area = calculateDefaultArea(); + _mass = material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : material.density * _area; + _moment = calculateDefaultMoment(); + + setMaterial(material); return true; } while (false); return false; } +float PhysicsShapeCircle::calculateArea(float radius) +{ + return PhysicsHelper::cpfloat2float(cpAreaForCircle(0, radius)); +} + +float PhysicsShapeCircle::calculateMoment(float mass, float radius, Point offset) +{ + return mass == PHYSICS_INFINITY ? PHYSICS_INFINITY + : PhysicsHelper::cpfloat2float(cpMomentForCircle(PhysicsHelper::float2cpfloat(mass), + 0, + PhysicsHelper::float2cpfloat(radius), + PhysicsHelper::point2cpv(offset))); +} + +float PhysicsShapeCircle::calculateDefaultArea() +{ + return PhysicsHelper::cpfloat2float(cpAreaForCircle(0, cpCircleShapeGetRadius(_info->shapes.front()))); +} + +float PhysicsShapeCircle::calculateDefaultMoment() +{ + cpShape* shape = _info->shapes.front(); + + return _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY + : PhysicsHelper::cpfloat2float(cpMomentForCircle(PhysicsHelper::float2cpfloat(_mass), + 0, + cpCircleShapeGetRadius(shape), + cpCircleShapeGetOffset(shape))); +} + +float PhysicsShapeCircle::getRadius() +{ + return PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(_info->shapes.front())); +} + +Point PhysicsShapeCircle::getOffset() +{ + return PhysicsHelper::cpv2point(cpCircleShapeGetOffset(_info->shapes.front())); +} + // PhysicsShapeEdgeSegment PhysicsShapeEdgeSegment* PhysicsShapeEdgeSegment::create(Point a, Point b, PhysicsMaterial material/* = MaterialDefault*/, float border/* = 1*/) { @@ -287,7 +351,7 @@ bool PhysicsShapeEdgeSegment::init(Point a, Point b, PhysicsMaterial material/* { do { - CC_BREAK_IF(!PhysicsShape::init(Type::EDGESEGMENT, material)); + CC_BREAK_IF(!PhysicsShape::init(Type::EDGESEGMENT)); cpShape* shape = cpSegmentShapeNew(_info->shareBody, PhysicsHelper::point2cpv(a), @@ -296,12 +360,14 @@ bool PhysicsShapeEdgeSegment::init(Point a, Point b, PhysicsMaterial material/* CC_BREAK_IF(shape == nullptr); - _mass = PHYSICS_INFINITY; - _moment = PHYSICS_INFINITY; - _info->add(shape); - initEnd(); + _mass = PHYSICS_INFINITY; + _moment = PHYSICS_INFINITY; + _center = a.getMidpoint(b); + + + setMaterial(material); return true; } while (false); @@ -309,6 +375,21 @@ bool PhysicsShapeEdgeSegment::init(Point a, Point b, PhysicsMaterial material/* return false; } +Point PhysicsShapeEdgeSegment::getPointA() +{ + return PhysicsHelper::cpv2point(((cpSegmentShape*)(_info->shapes.front()))->ta); +} + +Point PhysicsShapeEdgeSegment::getPointB() +{ + return PhysicsHelper::cpv2point(((cpSegmentShape*)(_info->shapes.front()))->tb); +} + +Point PhysicsShapeEdgeSegment::getCenter() +{ + return _center; +} + // PhysicsShapeBox PhysicsShapeBox* PhysicsShapeBox::create(Size size, PhysicsMaterial material/* = MaterialDefault*/, Point offset/* = Point(0, 0)*/) { @@ -327,19 +408,26 @@ bool PhysicsShapeBox::init(Size size, PhysicsMaterial material/* = MaterialDefau { do { - CC_BREAK_IF(!PhysicsShape::init(Type::BOX, material)); + CC_BREAK_IF(!PhysicsShape::init(Type::BOX)); - cpShape* shape = cpBoxShapeNew(_info->shareBody, PhysicsHelper::float2cpfloat(size.width), PhysicsHelper::float2cpfloat(size.height)); + cpVect wh = PhysicsHelper::size2cpv(size); + cpVect vec[4] = + { + {-wh.x/2.0f, -wh.y/2.0f}, {-wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, -wh.y/2.0f} + }; + + cpShape* shape = cpPolyShapeNew(_info->shareBody, 4, vec, PhysicsHelper::point2cpv(offset)); CC_BREAK_IF(shape == nullptr); - _area = PhysicsHelper::cpfloat2float(cpAreaForPoly(4, ((cpPolyShape*)shape)->verts)); - _mass = _material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : _material.density * _area; - _moment = _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : cpMomentForBox(_mass, PhysicsHelper::float2cpfloat(size.width), PhysicsHelper::float2cpfloat(size.height)); - _info->add(shape); - initEnd(); + _offset = offset; + _area = calculateDefaultArea(); + _mass = material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : material.density * _area; + _moment = calculateDefaultMoment(); + + setMaterial(material); return true; } while (false); @@ -347,7 +435,60 @@ bool PhysicsShapeBox::init(Size size, PhysicsMaterial material/* = MaterialDefau return false; } -// PhysicsShapeCircle +float PhysicsShapeBox::calculateArea(Size size) +{ + cpVect wh = PhysicsHelper::size2cpv(size); + cpVect vec[4] = + { + {-wh.x/2.0f, -wh.y/2.0f}, {-wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, -wh.y/2.0f} + }; + return PhysicsHelper::cpfloat2float(cpAreaForPoly(4, vec)); +} + +float PhysicsShapeBox::calculateMoment(float mass, Size size, Point offset) +{ + cpVect wh = PhysicsHelper::size2cpv(size); + cpVect vec[4] = + { + {-wh.x/2.0f, -wh.y/2.0f}, {-wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, -wh.y/2.0f} + }; + + return mass == PHYSICS_INFINITY ? PHYSICS_INFINITY + : PhysicsHelper::cpfloat2float(cpMomentForPoly(PhysicsHelper::float2cpfloat(mass), + 4, + vec, + PhysicsHelper::point2cpv(offset))); +} + +float PhysicsShapeBox::calculateDefaultArea() +{ + cpShape* shape = _info->shapes.front(); + return PhysicsHelper::cpfloat2float(cpAreaForPoly(((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts)); +} + +float PhysicsShapeBox::calculateDefaultMoment() +{ + cpShape* shape = _info->shapes.front(); + return _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY + : PhysicsHelper::cpfloat2float(cpMomentForPoly(_mass, ((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts, cpvzero)); +} + +Point* PhysicsShapeBox::getPoints(Point* points) +{ + cpShape* shape = _info->shapes.front(); + return PhysicsHelper::cpvs2points(((cpPolyShape*)shape)->verts, points, ((cpPolyShape*)shape)->numVerts); + + return points; +} + +Size PhysicsShapeBox::getSize() +{ + cpShape* shape = _info->shapes.front(); + return PhysicsHelper::cpv2size(cpv(cpvdist(cpPolyShapeGetVert(shape, 0), cpPolyShapeGetVert(shape, 1)), + cpvdist(cpPolyShapeGetVert(shape, 1), cpPolyShapeGetVert(shape, 2)))); +} + +// PhysicsShapePolygon PhysicsShapePolygon* PhysicsShapePolygon::create(Point* points, int count, PhysicsMaterial material/* = MaterialDefault*/, Point offset/* = Point(0, 0)*/) { PhysicsShapePolygon* shape = new PhysicsShapePolygon(); @@ -361,11 +502,11 @@ PhysicsShapePolygon* PhysicsShapePolygon::create(Point* points, int count, Physi return nullptr; } -bool PhysicsShapePolygon::init(Point* points, int count, PhysicsMaterial material/* = MaterialDefault*/, Point offset /*= Point(0, 0)*/) +bool PhysicsShapePolygon::init(Point* points, int count, PhysicsMaterial material/* = MaterialDefault*/, Point offset/* = Point(0, 0)*/) { do { - CC_BREAK_IF(!PhysicsShape::init(Type::POLYGEN, material)); + CC_BREAK_IF(!PhysicsShape::init(Type::POLYGEN)); cpVect* vecs = new cpVect[count]; PhysicsHelper::points2cpvs(points, vecs, count); @@ -374,13 +515,14 @@ bool PhysicsShapePolygon::init(Point* points, int count, PhysicsMaterial materia CC_BREAK_IF(shape == nullptr); - _area = PhysicsHelper::cpfloat2float(cpAreaForPoly(((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts)); - _mass = _material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : _material.density * _area; - _moment = _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : cpMomentForPoly(_mass, ((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts, PhysicsHelper::point2cpv(offset)); - _info->add(shape); - initEnd(); + _area = calculateDefaultArea(); + _mass = material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : material.density * _area; + _moment = calculateDefaultMoment(); + _center = PhysicsHelper::cpv2point(cpCentroidForPoly(((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts)); + + setMaterial(material); return true; } while (false); @@ -388,6 +530,56 @@ bool PhysicsShapePolygon::init(Point* points, int count, PhysicsMaterial materia return false; } +float PhysicsShapePolygon::calculateArea(Point* points, int count) +{ + cpVect* vecs = new cpVect[count]; + PhysicsHelper::points2cpvs(points, vecs, count); + float area = PhysicsHelper::cpfloat2float(cpAreaForPoly(count, vecs)); + CC_SAFE_DELETE(vecs); + + return area; +} + +float PhysicsShapePolygon::calculateMoment(float mass, Point* points, int count, Point offset) +{ + cpVect* vecs = new cpVect[count]; + PhysicsHelper::points2cpvs(points, vecs, count); + float moment = mass == PHYSICS_INFINITY ? PHYSICS_INFINITY + : PhysicsHelper::cpfloat2float(cpMomentForPoly(mass, count, vecs, PhysicsHelper::point2cpv(offset))); + CC_SAFE_DELETE(vecs); + + return moment; +} + +float PhysicsShapePolygon::calculateDefaultArea() +{ + cpShape* shape = _info->shapes.front(); + return PhysicsHelper::cpfloat2float(cpAreaForPoly(((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts)); +} + +float PhysicsShapePolygon::calculateDefaultMoment() +{ + cpShape* shape = _info->shapes.front(); + return _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY + : PhysicsHelper::cpfloat2float(cpMomentForPoly(_mass, ((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts, cpvzero)); +} + +Point* PhysicsShapePolygon::getPoints(Point* points) +{ + cpShape* shape = _info->shapes.front(); + return PhysicsHelper::cpvs2points(((cpPolyShape*)shape)->verts, points, ((cpPolyShape*)shape)->numVerts); +} + +int PhysicsShapePolygon::getPointsCount() +{ + return ((cpPolyShape*)_info->shapes.front())->numVerts; +} + +Point PhysicsShapePolygon::getCenter() +{ + return _center; +} + // PhysicsShapeEdgeBox PhysicsShapeEdgeBox* PhysicsShapeEdgeBox::create(Size size, PhysicsMaterial material/* = MaterialDefault*/, float border/* = 1*/, Point offset/* = Point(0, 0)*/) { @@ -406,7 +598,7 @@ bool PhysicsShapeEdgeBox::init(Size size, PhysicsMaterial material/* = MaterialD { do { - CC_BREAK_IF(!PhysicsShape::init(Type::EDGEBOX, material)); + CC_BREAK_IF(!PhysicsShape::init(Type::EDGEBOX)); cpVect vec[4] = {}; vec[0] = PhysicsHelper::point2cpv(Point(-size.width/2+offset.x, -size.height/2+offset.y)); @@ -424,10 +616,11 @@ bool PhysicsShapeEdgeBox::init(Size size, PhysicsMaterial material/* = MaterialD } CC_BREAK_IF(i < 4); + _offset = offset; _mass = PHYSICS_INFINITY; _moment = PHYSICS_INFINITY; - initEnd(); + setMaterial(material); return true; } while (false); @@ -454,10 +647,11 @@ bool PhysicsShapeEdgePolygon::init(Point* points, int count, PhysicsMaterial mat cpVect* vec = nullptr; do { - CC_BREAK_IF(!PhysicsShape::init(Type::EDGEPOLYGEN, material)); + CC_BREAK_IF(!PhysicsShape::init(Type::EDGEPOLYGEN)); vec = new cpVect[count]; PhysicsHelper::points2cpvs(points, vec, count); + _center = PhysicsHelper::cpv2point(cpCentroidForPoly(count, vec)); int i = 0; for (; i < count; ++i) @@ -469,23 +663,33 @@ bool PhysicsShapeEdgePolygon::init(Point* points, int count, PhysicsMaterial mat cpShapeSetFriction(shape, 1.0f); _info->add(shape); } - CC_SAFE_DELETE(vec); + CC_SAFE_DELETE_ARRAY(vec); CC_BREAK_IF(i < count); _mass = PHYSICS_INFINITY; _moment = PHYSICS_INFINITY; - initEnd(); + setMaterial(material); return true; } while (false); - if (vec != nullptr) delete[] vec; + CC_SAFE_DELETE_ARRAY(vec); return false; } +Point PhysicsShapeEdgePolygon::getCenter() +{ + return _center; +} + +int PhysicsShapeEdgePolygon::getPointsCount() +{ + return _info->shapes.size() + 1; +} + // PhysicsShapeEdgeChain PhysicsShapeEdgeChain* PhysicsShapeEdgeChain::create(Point* points, int count, PhysicsMaterial material/* = MaterialDefault*/, float border/* = 1*/) { @@ -505,10 +709,11 @@ bool PhysicsShapeEdgeChain::init(Point* points, int count, PhysicsMaterial mater cpVect* vec = nullptr; do { - CC_BREAK_IF(!PhysicsShape::init(Type::EDGECHAIN, material)); + CC_BREAK_IF(!PhysicsShape::init(Type::EDGECHAIN)); vec = new cpVect[count]; PhysicsHelper::points2cpvs(points, vec, count); + _center = PhysicsHelper::cpv2point(cpCentroidForPoly(count, vec)); int i = 0; for (; i < count - 1; ++i) @@ -520,22 +725,32 @@ bool PhysicsShapeEdgeChain::init(Point* points, int count, PhysicsMaterial mater cpShapeSetFriction(shape, 1.0f); _info->add(shape); } - if (vec != nullptr) delete[] vec; + CC_SAFE_DELETE_ARRAY(vec); CC_BREAK_IF(i < count); _mass = PHYSICS_INFINITY; _moment = PHYSICS_INFINITY; - initEnd(); + setMaterial(material); return true; } while (false); - if (vec != nullptr) delete[] vec; + CC_SAFE_DELETE_ARRAY(vec); return false; } +Point PhysicsShapeEdgeChain::getCenter() +{ + return _center; +} + +int PhysicsShapeEdgeChain::getPointsCount() +{ + return _info->shapes.size() + 1; +} + #elif (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) #endif diff --git a/cocos2dx/physics/CCPhysicsShape.h b/cocos2dx/physics/CCPhysicsShape.h index 0aa7a160b6..30a186aa6b 100644 --- a/cocos2dx/physics/CCPhysicsShape.h +++ b/cocos2dx/physics/CCPhysicsShape.h @@ -41,17 +41,17 @@ class PhysicsBodyInfo; typedef struct PhysicsMaterial { float density; - float elasticity; + float restitution; float friction; PhysicsMaterial() : density(0.0f) - , elasticity(0.0f) + , restitution(0.0f) , friction(0.0f){} - PhysicsMaterial(float density, float elasticity, float friction) + PhysicsMaterial(float density, float restitution, float friction) : density(density) - , elasticity(elasticity) + , restitution(restitution) , friction(friction){} }PhysicsMaterial; @@ -83,19 +83,25 @@ public: void setMoment(float moment); inline void setTag(int tag) { _tag = tag; } inline int getTag() { return _tag; } - void setEnable(bool enable); - inline bool isEnable() { return _enable; } inline float getMass() { return _mass; } void setMass(float mass); inline float getDensity() { return _material.density; } void setDensity(float density); - void setElasticity(float elasticity); + void setRestitution(float restitution); void setFriction(float friction); + void setMaterial(PhysicsMaterial material); + + virtual float calculateDefaultMoment() { return 0; } + virtual float calculateDefaultArea() { return 0; } + virtual Point getOffset() { return Point::ZERO; } + virtual Point getCenter() { return getOffset(); } + + static Point* recenterPoints(Point* points, int count, Point center); + static Point getPolyonCenter(Point* points, int count); protected: - bool init(Type type, PhysicsMaterial material); - void initEnd(); + bool init(Type type); /** * @brief PhysicsShape is PhysicsBody's friend class, but all the subclasses isn't. so this method is use for subclasses to catch the bodyInfo from PhysicsBody. @@ -117,7 +123,6 @@ protected: float _moment; PhysicsMaterial _material; int _tag; - bool _enable; friend class PhysicsWorld; friend class PhysicsBody; @@ -128,15 +133,20 @@ class PhysicsShapeCircle : public PhysicsShape { public: static PhysicsShapeCircle* create(float radius, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0)); + static float calculateArea(float radius); + static float calculateMoment(float mass, float radius, Point offset = Point(0, 0)); + float calculateDefaultArea() override; + float calculateDefaultMoment() override; + + float getRadius(); + Point getOffset(); protected: bool init(float radius, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0)); protected: PhysicsShapeCircle(); - virtual ~PhysicsShapeCircle(); - - friend class PhysicsBody; + ~PhysicsShapeCircle(); }; /** A box shape */ @@ -144,6 +154,15 @@ class PhysicsShapeBox : public PhysicsShape { public: static PhysicsShapeBox* create(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0)); + static float calculateArea(Size size); + static float calculateMoment(float mass, Size size, Point offset = Point(0, 0)); + + float calculateDefaultArea() override; + float calculateDefaultMoment() override; + + Point* getPoints(Point* points); + Size getSize(); + Point getOffset() override { return _offset; } protected: bool init(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0)); @@ -152,7 +171,8 @@ protected: PhysicsShapeBox(); virtual ~PhysicsShapeBox(); - friend class PhysicsBody; +protected: + Point _offset; }; /** A polygon shape */ @@ -160,7 +180,15 @@ class PhysicsShapePolygon : public PhysicsShape { public: static PhysicsShapePolygon* create(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0)); + static float calculateArea(Point* points, int count); + static float calculateMoment(float mass, Point* points, int count, Point offset = Point(0, 0)); + float calculateDefaultArea() override; + float calculateDefaultMoment() override; + + Point* getPoints(Point* points); + int getPointsCount(); + Point getCenter() override; protected: bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0)); @@ -168,7 +196,8 @@ protected: PhysicsShapePolygon(); virtual ~PhysicsShapePolygon(); - friend class PhysicsBody; +protected: + Point _center; }; /** A segment shape */ @@ -177,6 +206,10 @@ class PhysicsShapeEdgeSegment : public PhysicsShape public: static PhysicsShapeEdgeSegment* create(Point a, Point b, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); + Point getPointA(); + Point getPointB(); + Point getCenter() override; + protected: bool init(Point a, Point b, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); @@ -184,6 +217,9 @@ protected: PhysicsShapeEdgeSegment(); virtual ~PhysicsShapeEdgeSegment(); +protected: + Point _center; + friend class PhysicsBody; }; @@ -192,6 +228,9 @@ class PhysicsShapeEdgeBox : public PhysicsShape { public: static PhysicsShapeEdgeBox* create(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 0, Point offset = Point(0, 0)); + Point getOffset() override { return _offset; } + Point* getPoints(Point* points); + int getPointsCount(); protected: bool init(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1, Point offset = Point(0, 0)); @@ -200,6 +239,9 @@ protected: PhysicsShapeEdgeBox(); virtual ~PhysicsShapeEdgeBox(); +protected: + Point _offset; + friend class PhysicsBody; }; @@ -208,6 +250,9 @@ class PhysicsShapeEdgePolygon : public PhysicsShape { public: static PhysicsShapeEdgePolygon* create(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); + Point getCenter() override; + Point* getPoints(Point* points); + int getPointsCount(); protected: bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); @@ -217,6 +262,9 @@ protected: virtual ~PhysicsShapeEdgePolygon(); friend class PhysicsBody; + +protected: + Point _center; }; /** a chain shape */ @@ -224,6 +272,9 @@ class PhysicsShapeEdgeChain : public PhysicsShape { public: static PhysicsShapeEdgeChain* create(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); + Point getCenter() override; + Point* getPoints(Point* points); + int getPointsCount(); protected: bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); @@ -232,6 +283,9 @@ protected: PhysicsShapeEdgeChain(); virtual ~PhysicsShapeEdgeChain(); +protected: + Point _center; + friend class PhysicsBody; }; diff --git a/cocos2dx/physics/CCPhysicsWorld.cpp b/cocos2dx/physics/CCPhysicsWorld.cpp index 7ede980f53..4819ff743b 100644 --- a/cocos2dx/physics/CCPhysicsWorld.cpp +++ b/cocos2dx/physics/CCPhysicsWorld.cpp @@ -175,10 +175,7 @@ void PhysicsWorld::addBody(PhysicsBody* body) // add shapes to space for (auto shape : body->getShapes()) { - if (shape->isEnable()) - { - addShape(shape); - } + addShape(shape); } } diff --git a/cocos2dx/physics/chipmunk/CCPhysicsHelper.h b/cocos2dx/physics/chipmunk/CCPhysicsHelper.h index a026d632b7..704500c901 100644 --- a/cocos2dx/physics/chipmunk/CCPhysicsHelper.h +++ b/cocos2dx/physics/chipmunk/CCPhysicsHelper.h @@ -44,7 +44,7 @@ public: static float cpfloat2float(cpFloat f) { return f; } static cpFloat float2cpfloat(float f) { return f; } - static void cpvs2points(const cpVect* cpvs, Point* points, int count) + static Point* cpvs2points(const cpVect* cpvs, Point* points, int count) { for (int i = 0; i < count; ++i) { From d1fead368dd292a7d7169e078f8a76dcf6a957de Mon Sep 17 00:00:00 2001 From: boyu0 Date: Tue, 15 Oct 2013 16:55:08 +0800 Subject: [PATCH 11/48] issue #2771: migrate the PhysicsBody definition --- cocos2dx/base_nodes/CCNode.cpp | 2 +- cocos2dx/physics/CCPhysicsBody.cpp | 121 ++++++++++++++++-- cocos2dx/physics/CCPhysicsBody.h | 26 +++- cocos2dx/physics/CCPhysicsWorld.cpp | 43 ++++++- cocos2dx/physics/chipmunk/CCPhysicsHelper.h | 2 + .../Classes/PhysicsTest/PhysicsTest.cpp | 11 +- 6 files changed, 186 insertions(+), 19 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 47174c5790..4c3168fde4 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -897,7 +897,7 @@ void Node::transformAncestors() #ifdef CC_USE_PHYSICS void Node::updatePhysicsTransform() { - if (_physicsBody) + if (_physicsBody && _physicsBody->isEnable() && !_physicsBody->isResting()) { _position = _physicsBody->getPosition(); _rotationX = _rotationY = _physicsBody->getRotation(); diff --git a/cocos2dx/physics/CCPhysicsBody.cpp b/cocos2dx/physics/CCPhysicsBody.cpp index fee8712353..4fd1e45c62 100644 --- a/cocos2dx/physics/CCPhysicsBody.cpp +++ b/cocos2dx/physics/CCPhysicsBody.cpp @@ -65,12 +65,16 @@ PhysicsBody::PhysicsBody() , _info(nullptr) , _dynamic(true) , _enable(true) +, _rotationEnable(true) +, _gravityEnable(true) , _massDefault(true) , _momentDefault(true) , _mass(MASS_DEFAULT) -, _area(0.0) -, _density(0) +, _area(0.0f) +, _density(0.0f) , _moment(MOMENT_DEFAULT) +, _linearDamping(0.0f) +, _angularDamping(0.0f) , _tag(0) { } @@ -104,6 +108,11 @@ PhysicsBody* PhysicsBody::create() return nullptr; } +void update(float delta) +{ + +} + PhysicsBody* PhysicsBody::createCircle(float radius, PhysicsMaterial material) { PhysicsBody* body = new PhysicsBody(); @@ -229,17 +238,46 @@ void PhysicsBody::setDynamic(bool dynamic) { if (dynamic != _dynamic) { - if (dynamic) + _dynamic = dynamic; + if (_world != nullptr) { - cpBodySetMass(_info->body, PhysicsHelper::float2cpfloat(_mass)); - cpBodySetMoment(_info->body, PhysicsHelper::float2cpfloat(_moment)); - }else - { - cpBodySetMass(_info->body, PHYSICS_INFINITY); - cpBodySetMoment(_info->body, PHYSICS_INFINITY); + if (dynamic) + { + cpSpaceAddBody(_world->_info->space, _info->body); + }else + { + cpSpaceRemoveBody(_world->_info->space, _info->body); + } } - _dynamic = dynamic; + } +} + +void PhysicsBody::setRotationEnable(bool enable) +{ + if (_rotationEnable != enable) + { + cpBodySetMoment(_info->body, enable ? _moment : PHYSICS_INFINITY); + _rotationEnable = enable; + } +} + +void PhysicsBody::setGravityEnable(bool enable) +{ + if (_gravityEnable != enable) + { + _gravityEnable = enable; + + if (_world != nullptr) + { + if (enable) + { + applyForce(_world->getGravity()); + }else + { + applyForce(-_world->getGravity()); + } + } } } @@ -300,7 +338,10 @@ void PhysicsBody::addShape(PhysicsShape* shape) addMass(shape->getMass()); addMoment(shape->getMoment()); - if (_world != nullptr) _world->addShape(shape); + if (_world != nullptr) + { + _world->addShape(shape); + } shape->retain(); } @@ -308,7 +349,7 @@ void PhysicsBody::addShape(PhysicsShape* shape) void PhysicsBody::applyForce(Point force) { - applyForce(force, Point()); + applyForce(force, Point::ZERO); } void PhysicsBody::applyForce(Point force, Point offset) @@ -438,7 +479,10 @@ void PhysicsBody::addMoment(float moment) } } - cpBodySetMoment(_info->body, PhysicsHelper::float2cpfloat(_moment)); + if (_rotationEnable) + { + cpBodySetMoment(_info->body, PhysicsHelper::float2cpfloat(_moment)); + } } void PhysicsBody::setVelocity(Point velocity) @@ -451,12 +495,45 @@ Point PhysicsBody::getVelocity() return PhysicsHelper::cpv2point(cpBodyGetVel(_info->body)); } +void PhysicsBody::setAngularVelocity(float velocity) +{ + cpBodySetAngVel(_info->body, PhysicsHelper::float2cpfloat(velocity)); +} + +float PhysicsBody::getAngularVelocity() +{ + return PhysicsHelper::cpfloat2float(cpBodyGetAngVel(_info->body)); +} + +void PhysicsBody::setVelocityLimit(float limit) +{ + cpBodySetVelLimit(_info->body, PhysicsHelper::float2cpfloat(limit)); +} + +float PhysicsBody::getVelocityLimit() +{ + return PhysicsHelper::cpfloat2float(cpBodyGetVelLimit(_info->body)); +} + +void PhysicsBody::setAngularVelocityLimit(float limit) +{ + cpBodySetVelLimit(_info->body, PhysicsHelper::float2cpfloat(limit)); +} + +float PhysicsBody::getAngularVelocityLimit() +{ + return PhysicsHelper::cpfloat2float(cpBodyGetAngVelLimit(_info->body)); +} + void PhysicsBody::setMoment(float moment) { _moment = moment; _momentDefault = false; - cpBodySetMoment(_info->body, PhysicsHelper::float2cpfloat(_moment)); + if (_rotationEnable) + { + cpBodySetMoment(_info->body, PhysicsHelper::float2cpfloat(_moment)); + } } PhysicsShape* PhysicsBody::getShapeByTag(int tag) @@ -542,6 +619,22 @@ void PhysicsBody::setEnable(bool enable) } } +bool PhysicsBody::isResting() +{ + return cpBodyIsSleeping(_info->body) == cpTrue; +} + +void PhysicsBody::update(float delta) +{ + // damping compute + if (_dynamic) + { + _info->body->v.x *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f); + _info->body->v.y *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f); + _info->body->w *= cpfclamp(1.0f - delta * _angularDamping, 0.0f, 1.0f); + } +} + //Clonable* PhysicsBody::clone() const //{ // PhysicsBody* body = new PhysicsBody(); diff --git a/cocos2dx/physics/CCPhysicsBody.h b/cocos2dx/physics/CCPhysicsBody.h index 84507cfb00..904d94a1bf 100644 --- a/cocos2dx/physics/CCPhysicsBody.h +++ b/cocos2dx/physics/CCPhysicsBody.h @@ -109,6 +109,12 @@ public: virtual void setVelocity(Point velocity); virtual Point getVelocity(); + virtual void setAngularVelocity(float velocity); + virtual float getAngularVelocity(); + virtual void setVelocityLimit(float limit); + virtual float getVelocityLimit(); + virtual void setAngularVelocityLimit(float limit); + virtual float getAngularVelocityLimit(); /* * @brief get the body shapes. @@ -214,13 +220,24 @@ public: /* * @brief get angular damping. */ - //inline float getAngularDamping() { return _angularDamping; } + inline float getLinearDamping() { return _linearDamping; } + inline void setLinearDamping(float damping) { _linearDamping = damping; } + inline float getAngularDamping() { return _angularDamping; } + inline void setAngularDamping(float damping) { _angularDamping = damping; } //virtual Clonable* clone() const override; + bool isResting(); inline bool isEnable() { return _enable; } void setEnable(bool enable); + inline bool isRotationEnable() { return _rotationEnable; } + void setRotationEnable(bool enable); + + inline bool isGravityEnable() { return _gravityEnable; } + void setGravityEnable(bool enable); + + inline int getTag() { return _tag; } inline void setTag(int tag) { _tag = tag; } @@ -232,6 +249,8 @@ protected: virtual void setPosition(Point position); virtual void setRotation(float rotation); + virtual void update(float delta) override; + protected: PhysicsBody(); virtual ~PhysicsBody(); @@ -244,13 +263,16 @@ protected: PhysicsBodyInfo* _info; bool _dynamic; bool _enable; + bool _rotationEnable; + bool _gravityEnable; bool _massDefault; bool _momentDefault; float _mass; float _area; float _density; float _moment; - //float _angularDamping; + float _linearDamping; + float _angularDamping; int _tag; int _categoryBitmask; diff --git a/cocos2dx/physics/CCPhysicsWorld.cpp b/cocos2dx/physics/CCPhysicsWorld.cpp index 4819ff743b..1fda32540f 100644 --- a/cocos2dx/physics/CCPhysicsWorld.cpp +++ b/cocos2dx/physics/CCPhysicsWorld.cpp @@ -164,8 +164,16 @@ void PhysicsWorld::addShape(PhysicsShape* shape) void PhysicsWorld::addBody(PhysicsBody* body) { + CCASSERT(body != nullptr, "the body can not be nullptr"); + if (body->isEnable()) { + //is gravity enable + if (!body->isGravityEnable()) + { + body->applyForce(-_gravity); + } + // add body to space if (body->isDynamic()) { @@ -191,6 +199,18 @@ void PhysicsWorld::addBody(PhysicsBody* body) void PhysicsWorld::removeBody(PhysicsBody* body) { + CCASSERT(body != nullptr, "the body can not be nullptr"); + + if (body->getWorld() == this) + { + // reset the gravity + if (!body->isGravityEnable()) + { + body->applyForce(-_gravity); + } + } + + // remove shaps for (auto shape : body->getShapes()) { for (auto cps : shape->_info->shapes) @@ -202,6 +222,7 @@ void PhysicsWorld::removeBody(PhysicsBody* body) } } + // remove body if (cpSpaceContainsBody(_info->space, body->_info->body)) { cpSpaceRemoveBody(_info->space, body->_info->body); @@ -239,6 +260,11 @@ void PhysicsWorld::removeShape(PhysicsShape* shape) void PhysicsWorld::update(float delta) { + for (auto body : *_bodys) + { + body->update(delta); + } + cpSpaceStep(_info->space, delta); if (_drawNode) @@ -370,8 +396,23 @@ void PhysicsWorld::collisionSeparateCallback(const PhysicsContact& contact) void PhysicsWorld::setGravity(Point gravity) { + if (_bodys != nullptr) + { + for (auto child : *_bodys) + { + PhysicsBody* body = dynamic_cast(child); + + // reset gravity for body + if (!body->isGravityEnable()) + { + body->applyForce(-_gravity); + body->applyForce(gravity); + } + } + } + _gravity = gravity; - cpSpaceSetGravity(_info->space, PhysicsHelper::point2cpv(_gravity)); + cpSpaceSetGravity(_info->space, PhysicsHelper::point2cpv(gravity)); } #elif (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) diff --git a/cocos2dx/physics/chipmunk/CCPhysicsHelper.h b/cocos2dx/physics/chipmunk/CCPhysicsHelper.h index 704500c901..9334d87124 100644 --- a/cocos2dx/physics/chipmunk/CCPhysicsHelper.h +++ b/cocos2dx/physics/chipmunk/CCPhysicsHelper.h @@ -50,6 +50,8 @@ public: { points[i] = cpv2point(cpvs[i]); } + + return points; } static cpVect* points2cpvs(const Point* points, cpVect* cpvs, int count) diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index 91c67da54d..5791cee7bc 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -169,7 +169,16 @@ void PhysicsDemo::addGrossiniAtPosition(Point p, float scale/* = 1.0*/) auto sp = Sprite::createWithTexture(_spriteTexture, Rect(posx, posy, 85, 121)); sp->setScale(scale); - sp->setPhysicsBody(PhysicsBody::createBox(Size(48.0f * scale, 108.0f * scale))); + auto body = PhysicsBody::createBox(Size(48.0f * scale, 108.0f * scale)); + + static int abc = 0; + + if (abc++ > 0) + { + body->setGravityEnable(false); + } + + sp->setPhysicsBody(body); this->addChild(sp); sp->setPosition(p); #endif From 89448135adbe7f2e308450b8a95e177e1f8de0fe Mon Sep 17 00:00:00 2001 From: boyu0 Date: Thu, 17 Oct 2013 10:57:48 +0800 Subject: [PATCH 12/48] issue #2771: implement some joint definition. --- cocos2dx/physics/CCPhysicsBody.cpp | 38 ++----- cocos2dx/physics/CCPhysicsJoint.cpp | 107 ++++++++++++++---- cocos2dx/physics/CCPhysicsJoint.h | 16 ++- cocos2dx/physics/CCPhysicsShape.cpp | 26 +++++ cocos2dx/physics/CCPhysicsShape.h | 3 +- cocos2dx/physics/CCPhysicsWorld.cpp | 7 +- .../physics/chipmunk/CCPhysicsBodyInfo.cpp | 1 + cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.h | 1 + .../physics/chipmunk/CCPhysicsJointInfo.cpp | 42 ++++++- .../physics/chipmunk/CCPhysicsJointInfo.h | 15 ++- .../physics/chipmunk/CCPhysicsShapeInfo.cpp | 38 +++++++ .../physics/chipmunk/CCPhysicsShapeInfo.h | 5 +- .../Classes/PhysicsTest/PhysicsTest.cpp | 11 +- 13 files changed, 237 insertions(+), 73 deletions(-) diff --git a/cocos2dx/physics/CCPhysicsBody.cpp b/cocos2dx/physics/CCPhysicsBody.cpp index 4fd1e45c62..8f1e9e5c1d 100644 --- a/cocos2dx/physics/CCPhysicsBody.cpp +++ b/cocos2dx/physics/CCPhysicsBody.cpp @@ -57,6 +57,7 @@ namespace { static const float MASS_DEFAULT = 1.0; static const float MOMENT_DEFAULT = 200; + static float GROUP_INDEX = 0; } PhysicsBody::PhysicsBody() @@ -226,6 +227,8 @@ bool PhysicsBody::init() CC_BREAK_IF(_info == nullptr); _info->body = cpBodyNew(PhysicsHelper::float2cpfloat(_mass), PhysicsHelper::float2cpfloat(_moment)); + _info->group = ++GROUP_INDEX; + CC_BREAK_IF(_info->body == nullptr); return true; @@ -306,26 +309,6 @@ void PhysicsBody::addShape(PhysicsShape* shape) { if (shape == nullptr) return; - // already added - if (shape->getBody() == this) - { - return; - } - else if (shape->getBody() != nullptr) - { - shape->getBody()->removeShape(shape); - } - - // reset the body - if (shape->_info->body != _info->body) - { - for (cpShape* subShape : shape->_info->shapes) - { - cpShapeSetBody(subShape, _info->body); - } - shape->_info->body = _info->body; - } - // add shape to body if (std::find(_shapes.begin(), _shapes.end(), shape) == _shapes.end()) { @@ -567,20 +550,19 @@ void PhysicsBody::removeShape(PhysicsShape* shape) if (it != _shapes.end()) { - if (_world) - { - _world->removeShape(shape); - } - - _shapes.erase(it); - - // deduce the area, mass and moment // area must update before mass, because the density changes depend on it. _area -= shape->getArea(); addMass(-shape->getMass()); addMoment(-shape->getMoment()); + //remove + if (_world) + { + _world->removeShape(shape); + } + _shapes.erase(it); + shape->setBody(nullptr); shape->release(); } } diff --git a/cocos2dx/physics/CCPhysicsJoint.cpp b/cocos2dx/physics/CCPhysicsJoint.cpp index 63b6ac052e..18f63b7101 100644 --- a/cocos2dx/physics/CCPhysicsJoint.cpp +++ b/cocos2dx/physics/CCPhysicsJoint.cpp @@ -37,6 +37,8 @@ #include "Box2D/CCPhysicsJointInfo.h" #include "chipmunk/CCPhysicsBodyInfo.h" #include "Box2D/CCPhysicsBodyInfo.h" +#include "chipmunk/CCPhysicsShapeInfo.h" +#include "Box2D/CCPhysicsShapeInfo.h" #include "chipmunk/CCPhysicsHelper.h" #include "Box2D/CCPhysicsHelper.h" @@ -47,6 +49,7 @@ PhysicsJoint::PhysicsJoint() , _bodyB(nullptr) , _info(nullptr) , _enable(false) +, _collisionEnable(true) , _tag(0) { @@ -54,6 +57,9 @@ PhysicsJoint::PhysicsJoint() PhysicsJoint::~PhysicsJoint() { + // reset the shapes collision group + setCollisionEnable(true); + CC_SAFE_DELETE(_info); CC_SAFE_RELEASE(_bodyA); @@ -66,7 +72,7 @@ bool PhysicsJoint::init(cocos2d::PhysicsBody *a, cocos2d::PhysicsBody *b) { CC_BREAK_IF(a == nullptr || b == nullptr); - CC_BREAK_IF(!(_info = new PhysicsJointInfo())); + CC_BREAK_IF(!(_info = new PhysicsJointInfo(this))); _bodyA = a; _bodyA->retain(); @@ -97,15 +103,15 @@ void PhysicsJoint::setEnable(bool enable) } } -PhysicsJointPin::PhysicsJointPin() -{ - -} - -PhysicsJointPin::~PhysicsJointPin() -{ - -} +//PhysicsJointPin::PhysicsJointPin() +//{ +// +//} +// +//PhysicsJointPin::~PhysicsJointPin() +//{ +// +//} PhysicsJointFixed::PhysicsJointFixed() { @@ -144,6 +150,18 @@ PhysicsBodyInfo* PhysicsJoint::bodyInfo(PhysicsBody* body) const } +void PhysicsJoint::setCollisionEnable(bool enable) +{ + if (_collisionEnable != enable) + { + _collisionEnable = enable; + + for (auto shape : _bodyB->_shapes) + { + shape->_info->setGroup(enable ? _bodyB->_info->group : _bodyA->_info->group); + } + } +} PhysicsJointFixed* PhysicsJointFixed::create(PhysicsBody* a, PhysicsBody* b, const Point& anchr) { @@ -165,8 +183,18 @@ bool PhysicsJointFixed::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr) { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - _info->joint = cpPivotJointNew(bodyInfo(a)->body, bodyInfo(b)->body, + // add a pivot joint to fixed two body together + cpConstraint* joint = cpPivotJointNew(bodyInfo(a)->body, bodyInfo(b)->body, PhysicsHelper::point2cpv(anchr)); + CC_BREAK_IF(joint); + _info->add(joint); + + // add a gear joint to make two body have the same rotation. + joint = cpGearJointNew(bodyInfo(a)->body, bodyInfo(b)->body, 0, 1); + CC_BREAK_IF(joint); + _info->add(joint); + + setCollisionEnable(false); return true; } while (false); @@ -174,11 +202,11 @@ bool PhysicsJointFixed::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr) return false; } -PhysicsJointPin* PhysicsJointPin::create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2) +PhysicsJointPin* PhysicsJointPin::create(PhysicsBody* a, PhysicsBody* b, const Point& anchr) { PhysicsJointPin* joint = new PhysicsJointPin(); - if (joint && joint->init(a, b, anchr1, anchr2)) + if (joint && joint->init(a, b, anchr)) { joint->autorelease(); return joint; @@ -188,13 +216,20 @@ PhysicsJointPin* PhysicsJointPin::create(PhysicsBody* a, PhysicsBody* b, const P return nullptr; } -bool PhysicsJointPin::init(PhysicsBody *a, PhysicsBody *b, const Point& anchr1, const Point& anchr2) +bool PhysicsJointPin::init(PhysicsBody *a, PhysicsBody *b, const Point& anchr) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - _info->joint = cpPinJointNew(bodyInfo(a)->body, bodyInfo(b)->body, PhysicsHelper::point2cpv(anchr1), PhysicsHelper::point2cpv(anchr2)); + cpConstraint* joint = cpPivotJointNew(bodyInfo(a)->body, bodyInfo(b)->body, + PhysicsHelper::point2cpv(anchr)); + + CC_BREAK_IF(joint); + + _info->add(joint); + + setCollisionEnable(false); return true; } while (false); @@ -221,11 +256,15 @@ bool PhysicsJointSliding::init(PhysicsBody* a, PhysicsBody* b, const Point& groo { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - _info->joint = cpGrooveJointNew(bodyInfo(a)->body, bodyInfo(b)->body, + cpConstraint* joint = cpGrooveJointNew(bodyInfo(a)->body, bodyInfo(b)->body, PhysicsHelper::point2cpv(grooveA), PhysicsHelper::point2cpv(grooveB), PhysicsHelper::point2cpv(anchr)); + CC_BREAK_IF(joint); + + _info->add(joint); + return true; } while (false); @@ -233,11 +272,11 @@ bool PhysicsJointSliding::init(PhysicsBody* a, PhysicsBody* b, const Point& groo } -PhysicsJointLimit* PhysicsJointLimit::create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max) +PhysicsJointLimit* PhysicsJointLimit::create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2) { PhysicsJointLimit* joint = new PhysicsJointLimit(); - if (joint && joint->init(a, b, anchr1, anchr2, min, max)) + if (joint && joint->init(a, b, anchr1, anchr2)) { return joint; } @@ -246,17 +285,21 @@ PhysicsJointLimit* PhysicsJointLimit::create(PhysicsBody* a, PhysicsBody* b, con return nullptr; } -bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max) +bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - _info->joint = cpSlideJointNew(bodyInfo(a)->body, bodyInfo(b)->body, + cpConstraint* joint = cpSlideJointNew(bodyInfo(a)->body, bodyInfo(b)->body, PhysicsHelper::point2cpv(anchr1), PhysicsHelper::point2cpv(anchr2), - PhysicsHelper::float2cpfloat(min), - PhysicsHelper::float2cpfloat(max)); + 0, + PhysicsHelper::float2cpfloat(anchr1.getDistance(anchr2))); + + CC_BREAK_IF(joint); + + _info->add(joint); return true; } while (false); @@ -264,6 +307,26 @@ bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1 return false; } +float PhysicsJointLimit::getMin() +{ + return PhysicsHelper::cpfloat2float(cpSlideJointGetMin(_info->joints.front())); +} + +void PhysicsJointLimit::setMin(float min) +{ + cpSlideJointSetMin(_info->joints.front(), PhysicsHelper::float2cpfloat(min)); +} + +float PhysicsJointLimit::getMax() +{ + return PhysicsHelper::cpfloat2float(cpSlideJointGetMax(_info->joints.front())); +} + +void PhysicsJointLimit::setMax(float max) +{ + cpSlideJointSetMax(_info->joints.front(), PhysicsHelper::float2cpfloat(max)); +} + #elif (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) #endif diff --git a/cocos2dx/physics/CCPhysicsJoint.h b/cocos2dx/physics/CCPhysicsJoint.h index 73383c39b6..ebc7ceddc0 100644 --- a/cocos2dx/physics/CCPhysicsJoint.h +++ b/cocos2dx/physics/CCPhysicsJoint.h @@ -53,6 +53,8 @@ public: inline void setTag(int tag) { _tag = tag; } inline bool isEnable() { return _enable; } void setEnable(bool enable); + inline bool isCollisionEnable() { return _collisionEnable; } + void setCollisionEnable(bool enable); protected: bool init(PhysicsBody* a, PhysicsBody* b); @@ -67,6 +69,7 @@ protected: PhysicsBody* _bodyB; PhysicsJointInfo* _info; bool _enable; + bool _collisionEnable; int _tag; friend class PhysicsBody; @@ -127,10 +130,15 @@ protected: class PhysicsJointLimit : public PhysicsJoint { public: - PhysicsJointLimit* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max); + PhysicsJointLimit* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); + + float getMin(); + void setMin(float min); + float getMax(); + void setMax(float max); protected: - bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max); + bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); protected: PhysicsJointLimit(); @@ -143,10 +151,10 @@ protected: class PhysicsJointPin : public PhysicsJoint { public: - static PhysicsJointPin* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); + static PhysicsJointPin* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr); protected: - bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); + bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr); protected: PhysicsJointPin(); diff --git a/cocos2dx/physics/CCPhysicsShape.cpp b/cocos2dx/physics/CCPhysicsShape.cpp index abc4b4691b..1b5ec5ab0c 100644 --- a/cocos2dx/physics/CCPhysicsShape.cpp +++ b/cocos2dx/physics/CCPhysicsShape.cpp @@ -256,6 +256,32 @@ Point PhysicsShape::getPolyonCenter(Point* points, int count) return PhysicsHelper::cpv2point(center); } +void PhysicsShape::setBody(PhysicsBody *body) +{ + // already added + if (_body == body) + { + return; + } + + if (_body != nullptr) + { + _body->removeShape(this); + } + + if (body == nullptr) + { + _info->setBody(nullptr); + _info->setGroup(CP_NO_GROUP); + _body = nullptr; + }else + { + _info->setBody(body->_info->body); + _info->setGroup(body->_info->group); + _body = body; + } +} + // PhysicsShapeCircle PhysicsShapeCircle* PhysicsShapeCircle::create(float radius, PhysicsMaterial material/* = MaterialDefault*/, Point offset/* = Point(0, 0)*/) { diff --git a/cocos2dx/physics/CCPhysicsShape.h b/cocos2dx/physics/CCPhysicsShape.h index 30a186aa6b..f02e9e3789 100644 --- a/cocos2dx/physics/CCPhysicsShape.h +++ b/cocos2dx/physics/CCPhysicsShape.h @@ -108,7 +108,7 @@ protected: */ PhysicsBodyInfo* bodyInfo() const; - inline void setBody(PhysicsBody* body) { _body = body; } + void setBody(PhysicsBody* body); protected: PhysicsShape(); @@ -126,6 +126,7 @@ protected: friend class PhysicsWorld; friend class PhysicsBody; + friend class PhysicsJoint; }; /** A circle shape */ diff --git a/cocos2dx/physics/CCPhysicsWorld.cpp b/cocos2dx/physics/CCPhysicsWorld.cpp index 1fda32540f..32f10dea2c 100644 --- a/cocos2dx/physics/CCPhysicsWorld.cpp +++ b/cocos2dx/physics/CCPhysicsWorld.cpp @@ -125,9 +125,12 @@ void PhysicsWorld::addJoint(PhysicsJoint* joint) { _joints.push_back(joint); - if (!cpSpaceContainsConstraint(_info->space, joint->_info->joint)) + for (auto subjoint : joint->_info->joints) { - cpSpaceAddConstraint(_info->space, joint->_info->joint); + if (!cpSpaceContainsConstraint(_info->space, subjoint)) + { + cpSpaceAddConstraint(_info->space, subjoint); + } } } diff --git a/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.cpp b/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.cpp index 5fd8ceb171..852dad1eeb 100644 --- a/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.cpp +++ b/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.cpp @@ -28,6 +28,7 @@ NS_CC_BEGIN PhysicsBodyInfo::PhysicsBodyInfo() : body(nullptr) +, group(CP_NO_GROUP) { } diff --git a/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.h b/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.h index 0faef2eb49..a394aa807b 100644 --- a/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.h +++ b/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.h @@ -37,6 +37,7 @@ class PhysicsBodyInfo : public Clonable { public: cpBody* body; + cpGroup group; private: PhysicsBodyInfo(); diff --git a/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.cpp b/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.cpp index aca28aa0fb..7a44587ba5 100644 --- a/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.cpp +++ b/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.cpp @@ -26,18 +26,54 @@ #if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) NS_CC_BEGIN -PhysicsJointInfo::PhysicsJointInfo() -: joint(nullptr) +PhysicsJointInfo::PhysicsJointInfo(PhysicsJoint* joint) +: joint(joint) { } PhysicsJointInfo::~PhysicsJointInfo() { - if (joint) + for (cpConstraint* joint : joints) { cpConstraintFree(joint); } } +void PhysicsJointInfo::add(cpConstraint* joint) +{ + if (joint == nullptr) return; + + joints.push_back(joint); + map.insert(std::pair(joint, this)); +} + +void PhysicsJointInfo::remove(cpConstraint* joint) +{ + if (joint == nullptr) return; + + auto it = std::find(joints.begin(), joints.end(), joint); + if (it != joints.end()) + { + joints.erase(it); + + auto mit = map.find(joint); + if (mit != map.end()) map.erase(mit); + + cpConstraintFree(joint); + } +} + +void PhysicsJointInfo::removeAll() +{ + for (cpConstraint* joint : joints) + { + auto mit = map.find(joint); + if (mit != map.end()) map.erase(mit); + cpConstraintFree(joint); + } + + joints.clear(); +} + NS_CC_END #endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.h b/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.h index 47b1fc6141..1140b8783e 100644 --- a/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.h +++ b/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.h @@ -29,15 +29,26 @@ #define __CCPHYSICS_JOINT_INFO_H__ #include "chipmunk.h" #include "platform/CCPlatformMacros.h" +#include +#include NS_CC_BEGIN +class PhysicsJoint; + class PhysicsJointInfo { public: - cpConstraint* joint; + void add(cpConstraint* shape); + void remove(cpConstraint* shape); + void removeAll(); + +public: + std::vector joints; + PhysicsJoint* joint; + static std::map map; private: - PhysicsJointInfo(); + PhysicsJointInfo(PhysicsJoint* joint); ~PhysicsJointInfo(); friend class PhysicsJoint; diff --git a/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.cpp b/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.cpp index 0c048c780b..07e5c2f932 100644 --- a/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.cpp +++ b/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.cpp @@ -32,6 +32,7 @@ cpBody* PhysicsShapeInfo::shareBody = nullptr; PhysicsShapeInfo::PhysicsShapeInfo(PhysicsShape* shape) : shape(shape) +, group(CP_NO_GROUP) { if (shareBody == nullptr) { @@ -52,10 +53,33 @@ PhysicsShapeInfo::~PhysicsShapeInfo() } } +void PhysicsShapeInfo::setGroup(cpGroup group) +{ + this->group = group; + + for (cpShape* shape : shapes) + { + cpShapeSetGroup(shape, group); + } +} + +void PhysicsShapeInfo::setBody(cpBody* body) +{ + if (this->body != body) + { + this->body = body; + for (cpShape* shape : shapes) + { + cpShapeSetBody(shape, body == nullptr ? shareBody : body); + } + } +} + void PhysicsShapeInfo::add(cpShape* shape) { if (shape == nullptr) return; + cpShapeSetGroup(shape, group); shapes.push_back(shape); map.insert(std::pair(shape, this)); } @@ -71,8 +95,22 @@ void PhysicsShapeInfo::remove(cpShape* shape) auto mit = map.find(shape); if (mit != map.end()) map.erase(mit); + + cpShapeFree(shape); } } +void PhysicsShapeInfo::removeAll() +{ + for (cpShape* shape : shapes) + { + auto mit = map.find(shape); + if (mit != map.end()) map.erase(mit); + cpShapeFree(shape); + } + + shapes.clear(); +} + NS_CC_END #endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.h b/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.h index 5e9f2a73e3..f84f8613c6 100644 --- a/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.h +++ b/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.h @@ -42,12 +42,15 @@ class PhysicsShapeInfo public: void add(cpShape* shape); void remove(cpShape* shape); - void removeall(); + void removeAll(); + void setGroup(cpGroup group); + void setBody(cpBody* body); public: std::vector shapes; PhysicsShape* shape; cpBody* body; + cpGroup group; static std::map map; static cpBody* shareBody; diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index 5791cee7bc..91c67da54d 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -169,16 +169,7 @@ void PhysicsDemo::addGrossiniAtPosition(Point p, float scale/* = 1.0*/) auto sp = Sprite::createWithTexture(_spriteTexture, Rect(posx, posy, 85, 121)); sp->setScale(scale); - auto body = PhysicsBody::createBox(Size(48.0f * scale, 108.0f * scale)); - - static int abc = 0; - - if (abc++ > 0) - { - body->setGravityEnable(false); - } - - sp->setPhysicsBody(body); + sp->setPhysicsBody(PhysicsBody::createBox(Size(48.0f * scale, 108.0f * scale))); this->addChild(sp); sp->setPosition(p); #endif From 736a117fae6d14584e50eb3b4a9085c9c1a2042c Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 17 Oct 2013 16:15:51 +0800 Subject: [PATCH 13/48] Changed submodule URL for 'auto-generated'. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 7b07af24eb..91585f7b9a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,7 +3,7 @@ url = git://github.com/cocos2d/bindings-generator.git [submodule "cocos/scripting/auto-generated"] path = cocos/scripting/auto-generated - url = git://github.com/folecr/cocos2dx-autogen-bindings.git + url = git://github.com/cocos2d-x/bindings-auto-generated.git [submodule "samples/Javascript/Shared"] path = samples/Javascript/Shared url = git://github.com/cocos2d/cocos2d-js-tests.git From 4d28d0ab8bedad2449f5bddb1b330874c8e743a2 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 17 Oct 2013 17:46:09 +0800 Subject: [PATCH 14/48] issue #2509:make lua android template build ok --- .../proj.android/build_native.sh | 6 +++--- .../proj.android/jni/Android.mk | 15 ++------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/template/multi-platform-lua/proj.android/build_native.sh b/template/multi-platform-lua/proj.android/build_native.sh index 6728b60a2e..930a9e5249 100755 --- a/template/multi-platform-lua/proj.android/build_native.sh +++ b/template/multi-platform-lua/proj.android/build_native.sh @@ -80,7 +80,7 @@ fi done # copy common luaScript -for file in "$APP_ROOT"/../../scripting/lua/script/* +for file in "$APP_ROOT"/../../cocos/scripting/lua/script/* do if [ -d "$file" ]; then cp -rf "$file" "$APP_ANDROID_ROOT"/assets @@ -94,9 +94,9 @@ done if [[ "$buildexternalsfromsource" ]]; then echo "Building external dependencies from source" "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source" + "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos:${COCOS2DX_ROOT}/external" else echo "Using prebuilt externals" "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" + "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos:${COCOS2DX_ROOT}/external" fi \ No newline at end of file diff --git a/template/multi-platform-lua/proj.android/jni/Android.mk b/template/multi-platform-lua/proj.android/jni/Android.mk index af986970fe..a28d2c3d4d 100644 --- a/template/multi-platform-lua/proj.android/jni/Android.mk +++ b/template/multi-platform-lua/proj.android/jni/Android.mk @@ -15,19 +15,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_STATIC_LIBRARIES := curl_static_prebuilt -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_lua_static -LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static +LOCAL_WHOLE_STATIC_LIBRARIES := cocos_lua_static include $(BUILD_SHARED_LIBRARY) -$(call import-module,cocos2dx) -$(call import-module,audio/android) -$(call import-module,scripting/lua/proj.android) -$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) -$(call import-module,extensions) -$(call import-module,external/Box2D) -$(call import-module,cocos2dx/platform/android) +$(call import-module,scripting/lua/bindings) \ No newline at end of file From 9c3cac759ceb8c2814328dce6bdb5ec0dfe67029 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 17 Oct 2013 18:39:37 +0800 Subject: [PATCH 15/48] issue #2905:simple game and assets manager build ok on android --- cocos/scripting/javascript/bindings/Android.mk | 3 ++- samples/Cpp/AssetsManagerTest/Classes/AppDelegate.h | 2 +- .../Cpp/AssetsManagerTest/proj.android/build_native.sh | 4 ++-- .../Cpp/AssetsManagerTest/proj.android/jni/Android.mk | 10 +--------- samples/Cpp/SimpleGame/proj.android/build_native.sh | 2 +- samples/Cpp/SimpleGame/proj.android/jni/Android.mk | 6 ++---- 6 files changed, 9 insertions(+), 18 deletions(-) diff --git a/cocos/scripting/javascript/bindings/Android.mk b/cocos/scripting/javascript/bindings/Android.mk index 27a3b51306..5689684060 100644 --- a/cocos/scripting/javascript/bindings/Android.mk +++ b/cocos/scripting/javascript/bindings/Android.mk @@ -36,7 +36,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../../CocosDenshion/include \ $(LOCAL_PATH)/../../auto-generated/js-bindings \ $(LOCAL_PATH)/../../../../extensions \ - $(LOCAL_PATH)/../../../editor-support/cocostudio + $(LOCAL_PATH)/../../../editor-support/cocostudio \ + $(LOCAL_PATH)/../../../editor-support/cocosbuilder LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../auto-generated/js-bindings diff --git a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.h b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.h index 7fcf54741d..2a0dae6d7b 100644 --- a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.h +++ b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.h @@ -11,7 +11,7 @@ #include "CCApplication.h" #include "cocos2d.h" -#include "AssetsManager/AssetsManager.h" +#include "extensions/assets-manager/AssetsManager.h" /** @brief The cocos2d Application. diff --git a/samples/Cpp/AssetsManagerTest/proj.android/build_native.sh b/samples/Cpp/AssetsManagerTest/proj.android/build_native.sh index cfc39f5472..30549e8869 100755 --- a/samples/Cpp/AssetsManagerTest/proj.android/build_native.sh +++ b/samples/Cpp/AssetsManagerTest/proj.android/build_native.sh @@ -68,7 +68,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" COCOS2DX_ROOT="$DIR/../../../.." APP_ROOT="$DIR/.." APP_ANDROID_ROOT="$DIR" -BINDINGS_JS_ROOT="$APP_ROOT/../../../scripting/javascript/bindings/js" +BINDINGS_JS_ROOT="$APP_ROOT/../../../cocos/scripting/javascript/script" echo "NDK_ROOT = $NDK_ROOT" echo "COCOS2DX_ROOT = $COCOS2DX_ROOT" @@ -119,5 +119,5 @@ if [[ "$buildexternalsfromsource" ]]; then else echo "Using prebuilt externals" "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" + "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos:${COCOS2DX_ROOT}/external" fi diff --git a/samples/Cpp/AssetsManagerTest/proj.android/jni/Android.mk b/samples/Cpp/AssetsManagerTest/proj.android/jni/Android.mk index 42c47b9f80..78d938432f 100644 --- a/samples/Cpp/AssetsManagerTest/proj.android/jni/Android.mk +++ b/samples/Cpp/AssetsManagerTest/proj.android/jni/Android.mk @@ -11,18 +11,10 @@ LOCAL_SRC_FILES := hellocpp/main.cpp \ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += spidermonkey_static -LOCAL_WHOLE_STATIC_LIBRARIES += scriptingcore-spidermonkey -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static +LOCAL_WHOLE_STATIC_LIBRARIES := cocos_jsb_static LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=2 -DCOCOS2D_JAVASCRIPT include $(BUILD_SHARED_LIBRARY) -$(call import-module,cocos2dx) -$(call import-module,audio/android) -$(call import-module,scripting/javascript/spidermonkey-android) $(call import-module,scripting/javascript/bindings) -$(call import-module,cocos2dx/platform/android) diff --git a/samples/Cpp/SimpleGame/proj.android/build_native.sh b/samples/Cpp/SimpleGame/proj.android/build_native.sh index 1383ae1490..8f09b2bb6b 100755 --- a/samples/Cpp/SimpleGame/proj.android/build_native.sh +++ b/samples/Cpp/SimpleGame/proj.android/build_native.sh @@ -104,4 +104,4 @@ fi echo "Building in debug" "$NDK_ROOT"/ndk-build NDK_DEBUG=1 -C "$APP_ANDROID_ROOT" \ - "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" + "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos:${COCOS2DX_ROOT}/external" diff --git a/samples/Cpp/SimpleGame/proj.android/jni/Android.mk b/samples/Cpp/SimpleGame/proj.android/jni/Android.mk index d0fd9a4eb2..cdc6ac3234 100644 --- a/samples/Cpp/SimpleGame/proj.android/jni/Android.mk +++ b/samples/Cpp/SimpleGame/proj.android/jni/Android.mk @@ -13,11 +13,9 @@ LOCAL_SRC_FILES := hellocpp/main.cpp \ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocos2dxandroid_static cocosdenshion_static +LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static include $(BUILD_SHARED_LIBRARY) $(call import-module,audio/android) -$(call import-module,cocos2dx) -$(call import-module,extensions) -$(call import-module,cocos2dx/platform/android) +$(call import-module,2d) From 8c0d7e151c3e9194c257375f814320cc80cf67f6 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 18 Oct 2013 10:02:47 +0800 Subject: [PATCH 16/48] Updating the submodule reference of 'auto-generated'. --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 73aebd082a..893da8ccfb 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 73aebd082ae63561cc1ca769f28e302820da7e39 +Subproject commit 893da8ccfb4ed7fa754c483a90dc4e5248c36e03 From ca3cbec8582fe6dc0b5068990ca6dc06a5acb64d Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 18 Oct 2013 11:06:17 +0800 Subject: [PATCH 17/48] [Template] Hello JavaScript --> HelloJavascript. It's for replacement. --- .../HelloJavascript.xcodeproj/project.pbxproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/template/multi-platform-js/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj b/template/multi-platform-js/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj index 82228bc55f..2a53c9e26c 100644 --- a/template/multi-platform-js/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj +++ b/template/multi-platform-js/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj @@ -295,7 +295,7 @@ 5091731717ECDF7A00D62437 /* Icon-58.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-58.png"; path = "ios/Icon-58.png"; sourceTree = ""; }; 5091731817ECDF7A00D62437 /* Icon-80.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-80.png"; path = "ios/Icon-80.png"; sourceTree = ""; }; 5091731917ECDF7A00D62437 /* Icon-100.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-100.png"; path = "ios/Icon-100.png"; sourceTree = ""; }; - 509D4AAA17EBB24E00697056 /* Hello JavaScript Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Hello JavaScript Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 509D4AAA17EBB24E00697056 /* Hello JavaScript Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = "Hello JavaScript Mac.app"; path = "HelloJavaScript Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 509D4AAB17EBB2AB00697056 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppController.h; path = ios/AppController.h; sourceTree = ""; }; 509D4AAC17EBB2AB00697056 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AppController.mm; path = ios/AppController.mm; sourceTree = ""; }; 509D4AAD17EBB2AB00697056 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "ios/Default-568h@2x.png"; sourceTree = ""; }; @@ -320,7 +320,7 @@ 509D4AE617EBB81800697056 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; 509D4AE817EBB82000697056 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 509D4AEA17EBB82600697056 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; - A922753D1517C094001B78AA /* Hello JavaScript iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Hello JavaScript iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + A922753D1517C094001B78AA /* Hello JavaScript iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = "Hello JavaScript iOS.app"; path = "HelloJavaScript iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A92275411517C094001B78AA /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; A92275431517C094001B78AA /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; A92275451517C094001B78AA /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; @@ -545,9 +545,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 509D4A7517EBB24E00697056 /* Hello JavaScript Mac */ = { + 509D4A7517EBB24E00697056 /* HelloJavascript Mac */ = { isa = PBXNativeTarget; - buildConfigurationList = 509D4AA717EBB24E00697056 /* Build configuration list for PBXNativeTarget "Hello JavaScript Mac" */; + buildConfigurationList = 509D4AA717EBB24E00697056 /* Build configuration list for PBXNativeTarget "HelloJavascript Mac" */; buildPhases = ( 509D4A8017EBB24E00697056 /* Sources */, 509D4A8217EBB24E00697056 /* Frameworks */, @@ -562,14 +562,14 @@ 1A676826180E9BF70076BC67 /* PBXTargetDependency */, 1A676828180E9BF70076BC67 /* PBXTargetDependency */, ); - name = "Hello JavaScript Mac"; + name = "HelloJavascript Mac"; productName = HelloJavascript; productReference = 509D4AAA17EBB24E00697056 /* Hello JavaScript Mac.app */; productType = "com.apple.product-type.application"; }; - A922753C1517C094001B78AA /* Hello JavaScript iOS */ = { + A922753C1517C094001B78AA /* HelloJavascript iOS */ = { isa = PBXNativeTarget; - buildConfigurationList = A92277001517C097001B78AA /* Build configuration list for PBXNativeTarget "Hello JavaScript iOS" */; + buildConfigurationList = A92277001517C097001B78AA /* Build configuration list for PBXNativeTarget "HelloJavascript iOS" */; buildPhases = ( A92275391517C094001B78AA /* Sources */, A922753A1517C094001B78AA /* Frameworks */, @@ -584,7 +584,7 @@ 1A676835180E9C110076BC67 /* PBXTargetDependency */, 1A676837180E9C110076BC67 /* PBXTargetDependency */, ); - name = "Hello JavaScript iOS"; + name = "HelloJavascript iOS"; productName = HelloJavascript; productReference = A922753D1517C094001B78AA /* Hello JavaScript iOS.app */; productType = "com.apple.product-type.application"; @@ -620,8 +620,8 @@ ); projectRoot = ""; targets = ( - A922753C1517C094001B78AA /* Hello JavaScript iOS */, - 509D4A7517EBB24E00697056 /* Hello JavaScript Mac */, + A922753C1517C094001B78AA /* HelloJavascript iOS */, + 509D4A7517EBB24E00697056 /* HelloJavascript Mac */, ); }; /* End PBXProject section */ @@ -1058,7 +1058,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 509D4AA717EBB24E00697056 /* Build configuration list for PBXNativeTarget "Hello JavaScript Mac" */ = { + 509D4AA717EBB24E00697056 /* Build configuration list for PBXNativeTarget "HelloJavascript Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( 509D4AA817EBB24E00697056 /* Debug */, @@ -1076,7 +1076,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - A92277001517C097001B78AA /* Build configuration list for PBXNativeTarget "Hello JavaScript iOS" */ = { + A92277001517C097001B78AA /* Build configuration list for PBXNativeTarget "HelloJavascript iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A92277011517C097001B78AA /* Debug */, From c8ba071294d55b3361e7d6400a1bef37f78f8855 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 18 Oct 2013 11:13:54 +0800 Subject: [PATCH 18/48] Update AUTHORS --- AUTHORS | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 0638129f45..71cba826b3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -618,7 +618,10 @@ Developers: Fixed a bug that cc.Scheduler.schedule(target, func) without repeat argument couldn't repeat schedule forever on device. XiaoLongHan (kpkhxlgy0) - Fixed a bug that outside of keyboard can't be responded to close keyboard when using EditBox。 + Fixed a bug that outside of keyboard can't be responded to close keyboard when using EditBox. + + lettas + A fix for multi-platform template. Retired Core Developers: WenSheng Yang From 7d588fbaa32e539aaea87338303ebe687055ad1e Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 18 Oct 2013 11:15:02 +0800 Subject: [PATCH 19/48] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 3b2637b29d..62169acdf3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [FIX] fixed a memory leak in XMLHTTPRequest.cpp [FIX] removeSpriteFramesFromFile() crashes if file doesn't exist. [FIX] Avoid unnecessary object duplication for Scale9Sprite. + [FIX] create_project.py does not rename/replace template projects completely. [Android] [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [NEW] Added Cocos2dxHelper.runOnGLThread(Runnable) again From 88ae56bfe940145145d87f2ab3a0b3dfa5d1384c Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 18 Oct 2013 13:52:25 +0800 Subject: [PATCH 20/48] issue #2771: implement PhysicsBody's bit masks. --- cocos2dx/physics/CCPhysicsBody.h | 6 ++-- cocos2dx/physics/CCPhysicsContact.h | 8 +++-- cocos2dx/physics/CCPhysicsShape.h | 14 ++++---- cocos2dx/physics/CCPhysicsWorld.cpp | 52 +++++++++++++++++++++++++---- cocos2dx/physics/CCPhysicsWorld.h | 8 ++--- 5 files changed, 65 insertions(+), 23 deletions(-) diff --git a/cocos2dx/physics/CCPhysicsBody.h b/cocos2dx/physics/CCPhysicsBody.h index 904d94a1bf..869c7be1da 100644 --- a/cocos2dx/physics/CCPhysicsBody.h +++ b/cocos2dx/physics/CCPhysicsBody.h @@ -149,11 +149,11 @@ public: */ inline Sprite* getOwner() const { return _owner; } - void setCategoryBitmask(int bitmask); + inline void setCategoryBitmask(int bitmask) { _categoryBitmask = bitmask; } inline int getCategoryBitmask() const { return _categoryBitmask; } - void setContactTestBitmask(int bitmask); + inline void setContactTestBitmask(int bitmask) { _contactTestBitmask = bitmask; } inline int getContactTestBitmask() const { return _contactTestBitmask; } - void setCollisionBitmask(int bitmask); + inline void setCollisionBitmask(int bitmask) { _collisionBitmask = bitmask; } inline int getCollisionBitmask() const { return _collisionBitmask; } /* diff --git a/cocos2dx/physics/CCPhysicsContact.h b/cocos2dx/physics/CCPhysicsContact.h index 605a6dcf80..df31ae7be3 100644 --- a/cocos2dx/physics/CCPhysicsContact.h +++ b/cocos2dx/physics/CCPhysicsContact.h @@ -47,11 +47,11 @@ public: /* * @brief get contact shape A. */ - inline PhysicsShape* getShapeA() { return _shapeA; } + inline PhysicsShape* getShapeA() const { return _shapeA; } /* * @brief get contact shape B. */ - inline PhysicsShape* getShapeB() { return _shapeB; } + inline PhysicsShape* getShapeB() const { return _shapeB; } /* * @brief get data. */ @@ -65,6 +65,9 @@ private: static PhysicsContact* create(PhysicsShape* a, PhysicsShape* b); bool init(PhysicsShape* a, PhysicsShape* b); + inline bool getNotify() { return _notify; } + inline void setNotify(bool notify) { _notify = notify; } + private: PhysicsContact(); ~PhysicsContact(); @@ -74,6 +77,7 @@ private: PhysicsShape* _shapeB; PhysicsContactInfo* _info; void* _data; + bool _notify; friend class PhysicsWorld; }; diff --git a/cocos2dx/physics/CCPhysicsShape.h b/cocos2dx/physics/CCPhysicsShape.h index f02e9e3789..fcf70c7c19 100644 --- a/cocos2dx/physics/CCPhysicsShape.h +++ b/cocos2dx/physics/CCPhysicsShape.h @@ -76,17 +76,17 @@ public: }; public: - inline PhysicsBody* getBody(){ return _body; } - inline Type getType() { return _type; } - inline float getArea() { return _area; } - inline float getMoment() { return _moment; } + inline PhysicsBody* getBody() const { return _body; } + inline Type getType() const { return _type; } + inline float getArea() const { return _area; } + inline float getMoment() const { return _moment; } void setMoment(float moment); inline void setTag(int tag) { _tag = tag; } - inline int getTag() { return _tag; } + inline int getTag() const { return _tag; } - inline float getMass() { return _mass; } + inline float getMass() const { return _mass; } void setMass(float mass); - inline float getDensity() { return _material.density; } + inline float getDensity() const { return _material.density; } void setDensity(float density); void setRestitution(float restitution); void setFriction(float friction); diff --git a/cocos2dx/physics/CCPhysicsWorld.cpp b/cocos2dx/physics/CCPhysicsWorld.cpp index 32f10dea2c..afccdca8d9 100644 --- a/cocos2dx/physics/CCPhysicsWorld.cpp +++ b/cocos2dx/physics/CCPhysicsWorld.cpp @@ -35,6 +35,7 @@ #include "CCPhysicsShape.h" #include "CCPhysicsContact.h" #include "CCPhysicsJoint.h" +#include "CCPhysicsContact.h" #include "chipmunk/CCPhysicsWorldInfo.h" #include "Box2D/CCPhysicsWorldInfo.h" @@ -361,18 +362,45 @@ void PhysicsWorld::drawWithShape(DrawNode* node, PhysicsShape* shape) } } -int PhysicsWorld::collisionBeginCallback(const PhysicsContact& contact) +int PhysicsWorld::collisionBeginCallback(PhysicsContact& contact) { - if (_listener && _listener->onContactBegin) + bool ret = true; + PhysicsBody* bodyA = contact.getShapeA()->getBody(); + PhysicsBody* bodyB = contact.getShapeB()->getBody(); + + if ((bodyA->getCategoryBitmask() & bodyB->getContactTestBitmask()) == 0) { - return _listener->onContactBegin(contact); + contact.setNotify(false); } - return true; + if ((bodyA->getCategoryBitmask() & bodyB->getCollisionBitmask()) == 0) + { + ret = false; + } + + if (contact.getNotify() && _listener && _listener->onContactBegin) + { + // the mask has high priority than _listener->onContactBegin. + // so if the mask test is false, the two bodies won't have collision. + if (ret) + { + ret = _listener->onContactBegin(contact); + }else + { + _listener->onContactBegin(contact); + } + } + + return ret; } -int PhysicsWorld::collisionPreSolveCallback(const PhysicsContact& contact, const PhysicsContactPreSolve& solve) +int PhysicsWorld::collisionPreSolveCallback(PhysicsContact& contact, const PhysicsContactPreSolve& solve) { + if (!contact.getNotify()) + { + return true; + } + if (_listener && _listener->onContactPreSolve) { return _listener->onContactPreSolve(contact, solve); @@ -381,16 +409,26 @@ int PhysicsWorld::collisionPreSolveCallback(const PhysicsContact& contact, const return true; } -void PhysicsWorld::collisionPostSolveCallback(const PhysicsContact& contact, const PhysicsContactPostSolve& solve) +void PhysicsWorld::collisionPostSolveCallback(PhysicsContact& contact, const PhysicsContactPostSolve& solve) { + if (!contact.getNotify()) + { + return; + } + if (_listener && _listener->onContactPreSolve) { _listener->onContactPostSolve(contact, solve); } } -void PhysicsWorld::collisionSeparateCallback(const PhysicsContact& contact) +void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact) { + if (!contact.getNotify()) + { + return; + } + if (_listener && _listener->onContactEnd) { _listener->onContactEnd(contact); diff --git a/cocos2dx/physics/CCPhysicsWorld.h b/cocos2dx/physics/CCPhysicsWorld.h index d7a30f37cf..a0539ae81d 100644 --- a/cocos2dx/physics/CCPhysicsWorld.h +++ b/cocos2dx/physics/CCPhysicsWorld.h @@ -106,10 +106,10 @@ protected: virtual void drawWithShape(DrawNode* node, PhysicsShape* shape); - virtual int collisionBeginCallback(const PhysicsContact& contact); - virtual int collisionPreSolveCallback(const PhysicsContact& contact, const PhysicsContactPreSolve& solve); - virtual void collisionPostSolveCallback(const PhysicsContact& contact, const PhysicsContactPostSolve& solve); - virtual void collisionSeparateCallback(const PhysicsContact& contact); + virtual int collisionBeginCallback(PhysicsContact& contact); + virtual int collisionPreSolveCallback(PhysicsContact& contact, const PhysicsContactPreSolve& solve); + virtual void collisionPostSolveCallback(PhysicsContact& contact, const PhysicsContactPostSolve& solve); + virtual void collisionSeparateCallback(PhysicsContact& contact); #if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) static int collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *space, void *data); From 63c13d8eaa0f34d5e05065c5a3c661f57c197bf9 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 18 Oct 2013 14:18:36 +0800 Subject: [PATCH 21/48] issue #2905:simplify Android.mk dependence --- cocos/editor-support/cocosbuilder/Android.mk | 4 +- cocos/editor-support/cocostudio/Android.mk | 4 +- cocos/gui/Android.mk | 5 +- extensions/Android.mk | 52 +++++------ external/Box2D/Android.mk | 90 ++++++++++---------- external/chipmunk/Android.mk | 58 ++++++------- samples/Cpp/TestCpp/Android.mk | 13 +-- 7 files changed, 106 insertions(+), 120 deletions(-) diff --git a/cocos/editor-support/cocosbuilder/Android.mk b/cocos/editor-support/cocosbuilder/Android.mk index 4685debd1b..f5699a7f60 100644 --- a/cocos/editor-support/cocosbuilder/Android.mk +++ b/cocos/editor-support/cocosbuilder/Android.mk @@ -39,10 +39,8 @@ $(LOCAL_PATH)/../../.. LOCAL_CFLAGS += -Wno-psabi LOCAL_EXPORT_CFLAGS += -Wno-psabi -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static +LOCAL_WHOLE_STATIC_LIBRARIES := cocos_extension_static include $(BUILD_STATIC_LIBRARY) -$(call import-module,2d) $(call import-module,extensions) diff --git a/cocos/editor-support/cocostudio/Android.mk b/cocos/editor-support/cocostudio/Android.mk index 380eeba149..b9b1535fe6 100644 --- a/cocos/editor-support/cocostudio/Android.mk +++ b/cocos/editor-support/cocostudio/Android.mk @@ -43,10 +43,10 @@ CCSSceneReader.cpp \ ../../../external/json/json_writer.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \ -$(LOCAL_PATH)/../../../external/json +$(LOCAL_PATH)/../../../external LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../2d \ -$(LOCAL_PATH)/../../../external/json \ +$(LOCAL_PATH)/../../../external \ $(LOCAL_PATH)/.. \ $(LOCAL_PATH)/../.. \ $(LOCAL_PATH)/../../../external diff --git a/cocos/gui/Android.mk b/cocos/gui/Android.mk index 31edffec85..49f33a17e6 100644 --- a/cocos/gui/Android.mk +++ b/cocos/gui/Android.mk @@ -39,11 +39,8 @@ LOCAL_EXPORT_CFLAGS += -Wno-psabi LOCAL_WHOLE_STATIC_LIBRARIES := cocostudio_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static include $(BUILD_STATIC_LIBRARY) - -$(call import-module,extensions) $(call import-module,editor-support/cocostudio) -$(call import-module,2d) +$(call import-module,extensions) diff --git a/extensions/Android.mk b/extensions/Android.mk index 8f9bbe4f66..a5f4fd051f 100644 --- a/extensions/Android.mk +++ b/extensions/Android.mk @@ -6,36 +6,35 @@ LOCAL_MODULE := cocos_extension_static LOCAL_MODULE_FILENAME := libextension LOCAL_SRC_FILES := \ -$(LOCAL_PATH)/assets-manager/AssetsManager.cpp \ -$(LOCAL_PATH)/GUI/CCControlExtension/CCControl.cpp \ -$(LOCAL_PATH)/GUI/CCControlExtension/CCControlButton.cpp \ -$(LOCAL_PATH)/GUI/CCControlExtension/CCControlColourPicker.cpp \ -$(LOCAL_PATH)/GUI/CCControlExtension/CCControlHuePicker.cpp \ -$(LOCAL_PATH)/GUI/CCControlExtension/CCControlPotentiometer.cpp \ -$(LOCAL_PATH)/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp \ -$(LOCAL_PATH)/GUI/CCControlExtension/CCControlSlider.cpp \ -$(LOCAL_PATH)/GUI/CCControlExtension/CCControlStepper.cpp \ -$(LOCAL_PATH)/GUI/CCControlExtension/CCControlSwitch.cpp \ -$(LOCAL_PATH)/GUI/CCControlExtension/CCControlUtils.cpp \ -$(LOCAL_PATH)/GUI/CCControlExtension/CCInvocation.cpp \ -$(LOCAL_PATH)/GUI/CCControlExtension/CCScale9Sprite.cpp \ -$(LOCAL_PATH)/GUI/CCEditBox/CCEditBox.cpp \ -$(LOCAL_PATH)/GUI/CCEditBox/CCEditBoxImplAndroid.cpp \ -$(LOCAL_PATH)/GUI/CCEditBox/CCEditBoxImplNone.cpp \ -$(LOCAL_PATH)/GUI/CCEditBox/CCEditBoxImplTizen.cpp \ -$(LOCAL_PATH)/GUI/CCEditBox/CCEditBoxImplWin.cpp \ -$(LOCAL_PATH)/GUI/CCScrollView/CCScrollView.cpp \ -$(LOCAL_PATH)/GUI/CCScrollView/CCSorting.cpp \ -$(LOCAL_PATH)/GUI/CCScrollView/CCTableView.cpp \ -$(LOCAL_PATH)/GUI/CCScrollView/CCTableViewCell.cpp \ -$(LOCAL_PATH)/physics-nodes/CCPhysicsDebugNode.cpp \ -$(LOCAL_PATH)/physics-nodes/CCPhysicsSprite.cpp +assets-manager/AssetsManager.cpp \ +GUI/CCControlExtension/CCControl.cpp \ +GUI/CCControlExtension/CCControlButton.cpp \ +GUI/CCControlExtension/CCControlColourPicker.cpp \ +GUI/CCControlExtension/CCControlHuePicker.cpp \ +GUI/CCControlExtension/CCControlPotentiometer.cpp \ +GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp \ +GUI/CCControlExtension/CCControlSlider.cpp \ +GUI/CCControlExtension/CCControlStepper.cpp \ +GUI/CCControlExtension/CCControlSwitch.cpp \ +GUI/CCControlExtension/CCControlUtils.cpp \ +GUI/CCControlExtension/CCInvocation.cpp \ +GUI/CCControlExtension/CCScale9Sprite.cpp \ +GUI/CCEditBox/CCEditBox.cpp \ +GUI/CCEditBox/CCEditBoxImplAndroid.cpp \ +GUI/CCEditBox/CCEditBoxImplNone.cpp \ +GUI/CCEditBox/CCEditBoxImplTizen.cpp \ +GUI/CCEditBox/CCEditBoxImplWin.cpp \ +GUI/CCScrollView/CCScrollView.cpp \ +GUI/CCScrollView/CCSorting.cpp \ +GUI/CCScrollView/CCTableView.cpp \ +GUI/CCScrollView/CCTableViewCell.cpp \ +physics-nodes/CCPhysicsDebugNode.cpp \ +physics-nodes/CCPhysicsSprite.cpp LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_curl_static LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += libwebsockets_static LOCAL_CXXFLAGS += -fexceptions @@ -53,6 +52,7 @@ include $(BUILD_STATIC_LIBRARY) $(call import-module,2d) $(call import-module,audio/android) +$(call import-module,curl/prebuilt/android) $(call import-module,Box2D) -$(call import-module,chipmunk) $(call import-module,websockets/prebuilt/android) + diff --git a/external/Box2D/Android.mk b/external/Box2D/Android.mk index 5172a998e7..c366750c01 100644 --- a/external/Box2D/Android.mk +++ b/external/Box2D/Android.mk @@ -7,51 +7,51 @@ LOCAL_MODULE := box2d_static LOCAL_MODULE_FILENAME := libbox2d LOCAL_SRC_FILES := \ -$(LOCAL_PATH)/Collision/b2BroadPhase.cpp \ -$(LOCAL_PATH)/Collision/b2CollideCircle.cpp \ -$(LOCAL_PATH)/Collision/b2CollideEdge.cpp \ -$(LOCAL_PATH)/Collision/b2CollidePolygon.cpp \ -$(LOCAL_PATH)/Collision/b2Collision.cpp \ -$(LOCAL_PATH)/Collision/b2Distance.cpp \ -$(LOCAL_PATH)/Collision/b2DynamicTree.cpp \ -$(LOCAL_PATH)/Collision/b2TimeOfImpact.cpp \ -$(LOCAL_PATH)/Collision/Shapes/b2ChainShape.cpp \ -$(LOCAL_PATH)/Collision/Shapes/b2CircleShape.cpp \ -$(LOCAL_PATH)/Collision/Shapes/b2EdgeShape.cpp \ -$(LOCAL_PATH)/Collision/Shapes/b2PolygonShape.cpp \ -$(LOCAL_PATH)/Common/b2BlockAllocator.cpp \ -$(LOCAL_PATH)/Common/b2Draw.cpp \ -$(LOCAL_PATH)/Common/b2Math.cpp \ -$(LOCAL_PATH)/Common/b2Settings.cpp \ -$(LOCAL_PATH)/Common/b2StackAllocator.cpp \ -$(LOCAL_PATH)/Common/b2Timer.cpp \ -$(LOCAL_PATH)/Dynamics/b2Body.cpp \ -$(LOCAL_PATH)/Dynamics/b2ContactManager.cpp \ -$(LOCAL_PATH)/Dynamics/b2Fixture.cpp \ -$(LOCAL_PATH)/Dynamics/b2Island.cpp \ -$(LOCAL_PATH)/Dynamics/b2World.cpp \ -$(LOCAL_PATH)/Dynamics/b2WorldCallbacks.cpp \ -$(LOCAL_PATH)/Dynamics/Contacts/b2ChainAndCircleContact.cpp \ -$(LOCAL_PATH)/Dynamics/Contacts/b2ChainAndPolygonContact.cpp \ -$(LOCAL_PATH)/Dynamics/Contacts/b2CircleContact.cpp \ -$(LOCAL_PATH)/Dynamics/Contacts/b2Contact.cpp \ -$(LOCAL_PATH)/Dynamics/Contacts/b2ContactSolver.cpp \ -$(LOCAL_PATH)/Dynamics/Contacts/b2EdgeAndCircleContact.cpp \ -$(LOCAL_PATH)/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp \ -$(LOCAL_PATH)/Dynamics/Contacts/b2PolygonAndCircleContact.cpp \ -$(LOCAL_PATH)/Dynamics/Contacts/b2PolygonContact.cpp \ -$(LOCAL_PATH)/Dynamics/Joints/b2DistanceJoint.cpp \ -$(LOCAL_PATH)/Dynamics/Joints/b2FrictionJoint.cpp \ -$(LOCAL_PATH)/Dynamics/Joints/b2GearJoint.cpp \ -$(LOCAL_PATH)/Dynamics/Joints/b2Joint.cpp \ -$(LOCAL_PATH)/Dynamics/Joints/b2MouseJoint.cpp \ -$(LOCAL_PATH)/Dynamics/Joints/b2PrismaticJoint.cpp \ -$(LOCAL_PATH)/Dynamics/Joints/b2PulleyJoint.cpp \ -$(LOCAL_PATH)/Dynamics/Joints/b2RevoluteJoint.cpp \ -$(LOCAL_PATH)/Dynamics/Joints/b2RopeJoint.cpp \ -$(LOCAL_PATH)/Dynamics/Joints/b2WeldJoint.cpp \ -$(LOCAL_PATH)/Dynamics/Joints/b2WheelJoint.cpp \ -$(LOCAL_PATH)/Rope/b2Rope.cpp +Collision/b2BroadPhase.cpp \ +Collision/b2CollideCircle.cpp \ +Collision/b2CollideEdge.cpp \ +Collision/b2CollidePolygon.cpp \ +Collision/b2Collision.cpp \ +Collision/b2Distance.cpp \ +Collision/b2DynamicTree.cpp \ +Collision/b2TimeOfImpact.cpp \ +Collision/Shapes/b2ChainShape.cpp \ +Collision/Shapes/b2CircleShape.cpp \ +Collision/Shapes/b2EdgeShape.cpp \ +Collision/Shapes/b2PolygonShape.cpp \ +Common/b2BlockAllocator.cpp \ +Common/b2Draw.cpp \ +Common/b2Math.cpp \ +Common/b2Settings.cpp \ +Common/b2StackAllocator.cpp \ +Common/b2Timer.cpp \ +Dynamics/b2Body.cpp \ +Dynamics/b2ContactManager.cpp \ +Dynamics/b2Fixture.cpp \ +Dynamics/b2Island.cpp \ +Dynamics/b2World.cpp \ +Dynamics/b2WorldCallbacks.cpp \ +Dynamics/Contacts/b2ChainAndCircleContact.cpp \ +Dynamics/Contacts/b2ChainAndPolygonContact.cpp \ +Dynamics/Contacts/b2CircleContact.cpp \ +Dynamics/Contacts/b2Contact.cpp \ +Dynamics/Contacts/b2ContactSolver.cpp \ +Dynamics/Contacts/b2EdgeAndCircleContact.cpp \ +Dynamics/Contacts/b2EdgeAndPolygonContact.cpp \ +Dynamics/Contacts/b2PolygonAndCircleContact.cpp \ +Dynamics/Contacts/b2PolygonContact.cpp \ +Dynamics/Joints/b2DistanceJoint.cpp \ +Dynamics/Joints/b2FrictionJoint.cpp \ +Dynamics/Joints/b2GearJoint.cpp \ +Dynamics/Joints/b2Joint.cpp \ +Dynamics/Joints/b2MouseJoint.cpp \ +Dynamics/Joints/b2PrismaticJoint.cpp \ +Dynamics/Joints/b2PulleyJoint.cpp \ +Dynamics/Joints/b2RevoluteJoint.cpp \ +Dynamics/Joints/b2RopeJoint.cpp \ +Dynamics/Joints/b2WeldJoint.cpp \ +Dynamics/Joints/b2WheelJoint.cpp \ +Rope/b2Rope.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. diff --git a/external/chipmunk/Android.mk b/external/chipmunk/Android.mk index e8013df8c3..e8441cd0d7 100644 --- a/external/chipmunk/Android.mk +++ b/external/chipmunk/Android.mk @@ -7,35 +7,35 @@ LOCAL_MODULE := chipmunk_static LOCAL_MODULE_FILENAME := libchipmunk LOCAL_SRC_FILES := \ -$(LOCAL_PATH)/src/chipmunk.c \ -$(LOCAL_PATH)/src/cpArbiter.c \ -$(LOCAL_PATH)/src/cpArray.c \ -$(LOCAL_PATH)/src/cpBB.c \ -$(LOCAL_PATH)/src/cpBBTree.c \ -$(LOCAL_PATH)/src/cpBody.c \ -$(LOCAL_PATH)/src/cpCollision.c \ -$(LOCAL_PATH)/src/cpHashSet.c \ -$(LOCAL_PATH)/src/cpPolyShape.c \ -$(LOCAL_PATH)/src/cpShape.c \ -$(LOCAL_PATH)/src/cpSpace.c \ -$(LOCAL_PATH)/src/cpSpaceComponent.c \ -$(LOCAL_PATH)/src/cpSpaceHash.c \ -$(LOCAL_PATH)/src/cpSpaceQuery.c \ -$(LOCAL_PATH)/src/cpSpaceStep.c \ -$(LOCAL_PATH)/src/cpSpatialIndex.c \ -$(LOCAL_PATH)/src/cpSweep1D.c \ -$(LOCAL_PATH)/src/cpVect.c \ -$(LOCAL_PATH)/src/constraints/cpConstraint.c \ -$(LOCAL_PATH)/src/constraints/cpDampedRotarySpring.c \ -$(LOCAL_PATH)/src/constraints/cpDampedSpring.c \ -$(LOCAL_PATH)/src/constraints/cpGearJoint.c \ -$(LOCAL_PATH)/src/constraints/cpGrooveJoint.c \ -$(LOCAL_PATH)/src/constraints/cpPinJoint.c \ -$(LOCAL_PATH)/src/constraints/cpPivotJoint.c \ -$(LOCAL_PATH)/src/constraints/cpRatchetJoint.c \ -$(LOCAL_PATH)/src/constraints/cpRotaryLimitJoint.c \ -$(LOCAL_PATH)/src/constraints/cpSimpleMotor.c \ -$(LOCAL_PATH)/src/constraints/cpSlideJoint.c +src/chipmunk.c \ +src/cpArbiter.c \ +src/cpArray.c \ +src/cpBB.c \ +src/cpBBTree.c \ +src/cpBody.c \ +src/cpCollision.c \ +src/cpHashSet.c \ +src/cpPolyShape.c \ +src/cpShape.c \ +src/cpSpace.c \ +src/cpSpaceComponent.c \ +src/cpSpaceHash.c \ +src/cpSpaceQuery.c \ +src/cpSpaceStep.c \ +src/cpSpatialIndex.c \ +src/cpSweep1D.c \ +src/cpVect.c \ +src/constraints/cpConstraint.c \ +src/constraints/cpDampedRotarySpring.c \ +src/constraints/cpDampedSpring.c \ +src/constraints/cpGearJoint.c \ +src/constraints/cpGrooveJoint.c \ +src/constraints/cpPinJoint.c \ +src/constraints/cpPivotJoint.c \ +src/constraints/cpRatchetJoint.c \ +src/constraints/cpRotaryLimitJoint.c \ +src/constraints/cpSimpleMotor.c \ +src/constraints/cpSlideJoint.c LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include/chipmunk diff --git a/samples/Cpp/TestCpp/Android.mk b/samples/Cpp/TestCpp/Android.mk index 00c130e372..af16f48433 100644 --- a/samples/Cpp/TestCpp/Android.mk +++ b/samples/Cpp/TestCpp/Android.mk @@ -141,28 +141,19 @@ Classes/ZwoptexTest/ZwoptexTest.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/Classes -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static +LOCAL_WHOLE_STATIC_LIBRARIES := cocos_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_static LOCAL_WHOLE_STATIC_LIBRARIES += spine_static LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_curl_static + LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/Classes include $(BUILD_STATIC_LIBRARY) -$(call import-module,audio/android) -$(call import-module,Box2D) -$(call import-module,chipmunk) -$(call import-module,2d) $(call import-module,extensions) $(call import-module,editor-support/cocosbuilder) $(call import-module,editor-support/spine) $(call import-module,editor-support/cocostudio) $(call import-module,network) -$(call import-module,curl/prebuilt/android) From 5f65cdc3c0860ab414a177ef0eb3a2d271e446be Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 18 Oct 2013 15:39:09 +0800 Subject: [PATCH 22/48] fix xcode compiling error and simplify android.mk --- .../cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- cocos/2d/Android.mk | 7 +------ cocos/2d/platform/android/Android.mk | 2 +- external/png/prebuilt/android/Android.mk | 2 +- external/tiff/prebuilt/android/Android.mk | 2 +- external/webp/prebuilt/android/Android.mk | 2 +- 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index e48cb4ba94..abe193af68 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -9fac2ba89faf5e6f3c870c02f5186641e6be1590 \ No newline at end of file +a791b9789e080d3e7530890cfbaa966fffef5f9e \ No newline at end of file diff --git a/cocos/2d/Android.mk b/cocos/2d/Android.mk index 7e60320ddb..ec9f2dbf6e 100644 --- a/cocos/2d/Android.mk +++ b/cocos/2d/Android.mk @@ -191,12 +191,7 @@ LOCAL_EXPORT_LDLIBS := -lGLESv2 \ -lz \ -landroid -LOCAL_WHOLE_STATIC_LIBRARIES := cocos_libpng_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jpeg_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libxml2_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libtiff_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libwebp_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_freetype2_static +LOCAL_WHOLE_STATIC_LIBRARIES := cocos_freetype2_static LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static diff --git a/cocos/2d/platform/android/Android.mk b/cocos/2d/platform/android/Android.mk index 2aca5c8ed3..db9bec71b9 100644 --- a/cocos/2d/platform/android/Android.mk +++ b/cocos/2d/platform/android/Android.mk @@ -42,7 +42,7 @@ LOCAL_EXPORT_LDLIBS := -lGLESv1_CM \ -lz \ -landroid -LOCAL_WHOLE_STATIC_LIBRARIES := android_native_app_glue cocos_libpng_static cocos_jpeg_static cocos_libxml2_static cocos_libtiff_static cocos_libwebp_static +LOCAL_WHOLE_STATIC_LIBRARIES := android_native_app_glue cocos_png_static cocos_jpeg_static cocos_tiff_static cocos_webp_static include $(BUILD_STATIC_LIBRARY) diff --git a/external/png/prebuilt/android/Android.mk b/external/png/prebuilt/android/Android.mk index 41a0f91322..457f97c57f 100644 --- a/external/png/prebuilt/android/Android.mk +++ b/external/png/prebuilt/android/Android.mk @@ -1,7 +1,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE := cocos_libpng_static +LOCAL_MODULE := cocos_png_static LOCAL_MODULE_FILENAME := png LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libpng.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include/android diff --git a/external/tiff/prebuilt/android/Android.mk b/external/tiff/prebuilt/android/Android.mk index 40af980160..417eeda4ad 100644 --- a/external/tiff/prebuilt/android/Android.mk +++ b/external/tiff/prebuilt/android/Android.mk @@ -1,7 +1,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE := cocos_libtiff_static +LOCAL_MODULE := cocos_tiff_static LOCAL_MODULE_FILENAME := tiff LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libtiff.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include/android diff --git a/external/webp/prebuilt/android/Android.mk b/external/webp/prebuilt/android/Android.mk index e102ac2511..1bd16f8c45 100644 --- a/external/webp/prebuilt/android/Android.mk +++ b/external/webp/prebuilt/android/Android.mk @@ -1,7 +1,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE := cocos_libwebp_static +LOCAL_MODULE := cocos_webp_static LOCAL_MODULE_FILENAME := webp LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libwebp.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include/android From 6aef4476d95171bbd4ca6c005e1d2259eb6e1f9c Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 18 Oct 2013 15:55:47 +0800 Subject: [PATCH 23/48] issue #2771: edit some mistake when merge --- cocos/physics/chipmunk/CCPhysicsHelper.h | 2 +- cocos/physics/chipmunk/CCPhysicsShapeInfo.h | 2 +- samples/Cpp/TestCpp/Classes/controller.cpp | 197 ++++++++++++++++++++ 3 files changed, 199 insertions(+), 2 deletions(-) create mode 100644 samples/Cpp/TestCpp/Classes/controller.cpp diff --git a/cocos/physics/chipmunk/CCPhysicsHelper.h b/cocos/physics/chipmunk/CCPhysicsHelper.h index 9334d87124..323527cd6a 100644 --- a/cocos/physics/chipmunk/CCPhysicsHelper.h +++ b/cocos/physics/chipmunk/CCPhysicsHelper.h @@ -29,7 +29,7 @@ #define __CCPHYSICS_HELPER_H__ #include "chipmunk.h" -#include "platform/CCPlatformMacros.h" +#include "CCPlatformMacros.h" #include "cocoa/CCGeometry.h" NS_CC_BEGIN diff --git a/cocos/physics/chipmunk/CCPhysicsShapeInfo.h b/cocos/physics/chipmunk/CCPhysicsShapeInfo.h index f84f8613c6..83be655b02 100644 --- a/cocos/physics/chipmunk/CCPhysicsShapeInfo.h +++ b/cocos/physics/chipmunk/CCPhysicsShapeInfo.h @@ -31,7 +31,7 @@ #include #include #include "chipmunk.h" -#include "platform/CCPlatformMacros.h" +#include "CCPlatformMacros.h" NS_CC_BEGIN diff --git a/samples/Cpp/TestCpp/Classes/controller.cpp b/samples/Cpp/TestCpp/Classes/controller.cpp new file mode 100644 index 0000000000..f78fb2c9af --- /dev/null +++ b/samples/Cpp/TestCpp/Classes/controller.cpp @@ -0,0 +1,197 @@ + +// C++ includes +#include +#include +#include + +// test inclues +#include "controller.h" +#include "testResource.h" +#include "tests.h" + + +struct { + const char *test_name; + std::function callback; +} g_aTestNames[] = { + { "Accelerometer", []() { return new AccelerometerTestScene(); } }, + { "ActionManagerTest", [](){return new ActionManagerTestScene(); } }, + { "ActionsEaseTest", [](){return new ActionsEaseTestScene();} }, + { "ActionsProgressTest", [](){return new ProgressActionsTestScene(); } }, + { "ActionsTest", [](){ return new ActionsTestScene(); } }, + { "Box2dTest", []() { return new Box2DTestScene(); } }, + { "Box2dTestBed", []() { return new Box2dTestBedScene(); } }, + { "BugsTest", []() { return new BugsTestScene(); } }, +#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) + { "ChipmunkTest", []() { return new ChipmunkAccelTouchTestScene(); } }, +#endif + { "ClickAndMoveTest", [](){return new ClickAndMoveTestScene(); } }, +#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) + { "ClippingNodeTest", []() { return new ClippingNodeTestScene(); } }, +#endif + { "CocosDenshionTest", []() { return new CocosDenshionTestScene(); } }, + { "ConfigurationTest", []() { return new ConfigurationTestScene(); } }, +#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN) +#if (CC_TARGET_PLATFORM != CC_PLATFORM_NACL) +#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) +#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA) + { "CurlTest", []() { return new CurlTestScene(); } }, +#endif +#endif +#endif +#endif + { "CurrentLanguageTest", []() { return new CurrentLanguageTestScene(); } }, + { "DrawPrimitivesTest", [](){return new DrawPrimitivesTestScene();} }, + { "EventDispatcherTest(NEW)", []() { return new EventDispatcherTestScene(); } }, + { "EffectAdvancedTest", []() { return new EffectAdvanceScene(); } }, + { "EffectsTest", [](){return new EffectTestScene();} }, + { "ExtensionsTest", []() { return new ExtensionsTestScene(); } }, + { "FileUtilsTest", []() { return new FileUtilsTestScene(); } }, + { "FontTest", []() { return new FontTestScene(); } }, + { "IntervalTest", [](){return new IntervalTestScene(); } }, + { "KeyboardTest", []() { return new KeyboardTestScene(); } }, +#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA) + { "KeypadTest", []() { return new KeypadTestScene(); } }, +#endif + { "LabelTest", [](){return new AtlasTestScene(); } }, + { "LabelTestNew", [](){return new AtlasTestSceneNew(); } }, + { "LayerTest", [](){return new LayerTestScene();} }, + { "MenuTest", [](){return new MenuTestScene();} }, + { "MotionStreakTest", [](){return new MotionStreakTestScene();} }, + { "MutiTouchTest", []() { return new MutiTouchTestScene(); } }, + { "NodeTest", [](){return new CocosNodeTestScene();} }, + { "ParallaxTest", [](){return new ParallaxTestScene(); } }, + { "ParticleTest", [](){return new ParticleTestScene(); } }, + { "PerformanceTest", []() { return new PerformanceTestScene(); } }, + { "PhysicsTest", []() { return new PhysicsTestScene(); } }, + { "RenderTextureTest", [](){return new RenderTextureScene(); } }, + { "RotateWorldTest", [](){return new RotateWorldTestScene(); } }, + { "SceneTest", [](){return new SceneTestScene();} }, + { "SchedulerTest", [](){return new SchedulerTestScene(); } }, + { "ShaderTest", []() { return new ShaderTestScene(); } }, + { "ShaderTestSprite", []() { return new ShaderTestScene2(); } }, + { "SpineTest", []() { return new SpineTestScene(); } }, + { "SpriteTest", [](){return new SpriteTestScene(); } }, + { "TextInputTest", [](){return new TextInputTestScene(); } }, + { "Texture2DTest", [](){return new TextureTestScene(); } }, +#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) + { "TextureCacheTest", []() { return new TextureCacheTestScene(); } }, +#endif + { "TexturePackerEncryption", []() { return new TextureAtlasEncryptionTestScene(); } }, + { "TileMapTest", [](){return new TileMapTestScene(); } }, + { "TouchesTest", [](){return new PongScene();} }, + { "TransitionsTest", [](){return new TransitionsTestScene();} }, + { "UserDefaultTest", []() { return new UserDefaultTestScene(); } }, + { "ZwoptexTest", []() { return new ZwoptexTestScene(); } }, +}; + +static int g_testCount = sizeof(g_aTestNames) / sizeof(g_aTestNames[0]); + +#define LINE_SPACE 40 + +static Point s_tCurPos = Point::ZERO; + +TestController::TestController() +: _beginPos(Point::ZERO) +{ + // add close menu + auto closeItem = MenuItemImage::create(s_pathClose, s_pathClose, CC_CALLBACK_1(TestController::closeCallback, this) ); + auto menu =Menu::create(closeItem, NULL); + + menu->setPosition( Point::ZERO ); + closeItem->setPosition(Point( VisibleRect::right().x - 30, VisibleRect::top().y - 30)); + + // add menu items for tests + _itemMenu = Menu::create(); + for (int i = 0; i < g_testCount; ++i) + { +// #if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) +// auto label = LabelBMFont::create(g_aTestNames[i].c_str(), "fonts/arial16.fnt"); +// #else + auto label = LabelTTF::create( g_aTestNames[i].test_name, "Arial", 24); +// #endif + auto menuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestController::menuCallback, this)); + + _itemMenu->addChild(menuItem, i + 10000); + menuItem->setPosition( Point( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) )); + } + + _itemMenu->setContentSize(Size(VisibleRect::getVisibleRect().size.width, (g_testCount + 1) * (LINE_SPACE))); + _itemMenu->setPosition(s_tCurPos); + addChild(_itemMenu); + + setTouchEnabled(true); + + addChild(menu, 1); + + // Register Touch Event + auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE); + listener->setSwallowTouches(true); + + listener->onTouchBegan = CC_CALLBACK_2(TestController::onTouchBegan, this); + listener->onTouchMoved = CC_CALLBACK_2(TestController::onTouchMoved, this); + + EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, this); +} + +TestController::~TestController() +{ +} + +void TestController::menuCallback(Object * sender) +{ + + Director::getInstance()->purgeCachedData(); + + // get the userdata, it's the index of the menu item clicked + auto menuItem = static_cast(sender); + int idx = menuItem->getZOrder() - 10000; + + // create the test scene and run it + auto scene = g_aTestNames[idx].callback(); + + if (scene && scene->initTest()) + { + scene->runThisTest(); + scene->release(); + } +} + +void TestController::closeCallback(Object * sender) +{ + Director::getInstance()->end(); +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + exit(0); +#endif +} + +bool TestController::onTouchBegan(Touch* touch, Event *event) +{ + _beginPos = touch->getLocation(); + return true; +} + +void TestController::onTouchMoved(Touch* touch, Event *event) +{ + auto touchLocation = touch->getLocation(); + float nMoveY = touchLocation.y - _beginPos.y; + + auto curPos = _itemMenu->getPosition(); + auto nextPos = Point(curPos.x, curPos.y + nMoveY); + + if (nextPos.y < 0.0f) + { + _itemMenu->setPosition(Point::ZERO); + return; + } + + if (nextPos.y > ((g_testCount + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height)) + { + _itemMenu->setPosition(Point(0, ((g_testCount + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); + return; + } + + _itemMenu->setPosition(nextPos); + _beginPos = touchLocation; + s_tCurPos = nextPos; +} From 4ccb13f5d02dba6532822a8fd93b29ef9178e803 Mon Sep 17 00:00:00 2001 From: samuelhu Date: Fri, 18 Oct 2013 17:37:04 +0800 Subject: [PATCH 24/48] fix libluajia.a search path bug --- build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index abe193af68..bb2117f6df 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -a791b9789e080d3e7530890cfbaa966fffef5f9e \ No newline at end of file +af3544581a6508d57d3fe3b1f999cdc091bad543 \ No newline at end of file From 5741a166205a686ed21ea143c6f066f4c0752f19 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 18 Oct 2013 17:47:29 +0800 Subject: [PATCH 25/48] issue #2771: edit some include head file path --- cocos/physics/CCPhysicsBody.h | 2 +- cocos/physics/CCPhysicsWorld.cpp | 6 +++--- cocos/physics/chipmunk/CCPhysicsHelper.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/physics/CCPhysicsBody.h b/cocos/physics/CCPhysicsBody.h index 65883d5bcb..72cad042bc 100644 --- a/cocos/physics/CCPhysicsBody.h +++ b/cocos/physics/CCPhysicsBody.h @@ -43,7 +43,7 @@ class PhysicsJoint; class PhysicsBodyInfo; -const PhysicsMaterial PHYSICSBODY_MATERIAL_DEFAULT = {0.0f, 1.0f, 1.0f}; +const PhysicsMaterial PHYSICSBODY_MATERIAL_DEFAULT = {1.0f, 1.0f, 1.0f}; /** * A body affect by physics. diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index afccdca8d9..30939dc9fd 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -49,9 +49,9 @@ #include "Box2D/CCPhysicsJointInfo.h" #include "chipmunk/CCPhysicsHelper.h" -#include "draw_nodes/CCDrawNode.h" -#include "cocoa/CCArray.h" -#include "layers_scenes_transitions_nodes/CCScene.h" +#include "CCDrawNode.h" +#include "CCArray.h" +#include "CCScene.h" #include "CCDirector.h" #include diff --git a/cocos/physics/chipmunk/CCPhysicsHelper.h b/cocos/physics/chipmunk/CCPhysicsHelper.h index 323527cd6a..337bb1a1df 100644 --- a/cocos/physics/chipmunk/CCPhysicsHelper.h +++ b/cocos/physics/chipmunk/CCPhysicsHelper.h @@ -30,7 +30,7 @@ #include "chipmunk.h" #include "CCPlatformMacros.h" -#include "cocoa/CCGeometry.h" +#include "CCGeometry.h" NS_CC_BEGIN From 8fbfff97d933d95600ca54b196372aeee0f4ec0d Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 18 Oct 2013 17:56:22 +0800 Subject: [PATCH 26/48] issue #2771: delete some files added by mistake. --- .gitmodules | 2 +- cocos2dx/base_nodes/CCNode.cpp | 1538 ---------------- cocos2dx/base_nodes/CCNode.h | 1575 ----------------- cocos2dx/cocoa/CCGeometry.h | 584 ------ cocos2dx/physics/CCPhysicsBody.h | 292 --- cocos2dx/physics/CCPhysicsContact.h | 147 -- cocos2dx/physics/CCPhysicsJoint.h | 168 -- cocos2dx/physics/CCPhysicsShape.h | 296 ---- cocos2dx/physics/CCPhysicsWorld.cpp | 496 ------ cocos2dx/physics/CCPhysicsWorld.h | 149 -- cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.h | 54 - cocos2dx/physics/chipmunk/CCPhysicsHelper.h | 71 - .../physics/chipmunk/CCPhysicsJointInfo.h | 60 - .../physics/chipmunk/CCPhysicsShapeInfo.h | 67 - cocos2dx/sprite_nodes/CCSprite.cpp | 1138 ------------ 15 files changed, 1 insertion(+), 6636 deletions(-) delete mode 100644 cocos2dx/base_nodes/CCNode.cpp delete mode 100644 cocos2dx/base_nodes/CCNode.h delete mode 100644 cocos2dx/cocoa/CCGeometry.h delete mode 100644 cocos2dx/physics/CCPhysicsBody.h delete mode 100644 cocos2dx/physics/CCPhysicsContact.h delete mode 100644 cocos2dx/physics/CCPhysicsJoint.h delete mode 100644 cocos2dx/physics/CCPhysicsShape.h delete mode 100644 cocos2dx/physics/CCPhysicsWorld.cpp delete mode 100644 cocos2dx/physics/CCPhysicsWorld.h delete mode 100644 cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.h delete mode 100644 cocos2dx/physics/chipmunk/CCPhysicsHelper.h delete mode 100644 cocos2dx/physics/chipmunk/CCPhysicsJointInfo.h delete mode 100644 cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.h delete mode 100644 cocos2dx/sprite_nodes/CCSprite.cpp diff --git a/.gitmodules b/.gitmodules index c4175f6e86..91585f7b9a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,7 +3,7 @@ url = git://github.com/cocos2d/bindings-generator.git [submodule "cocos/scripting/auto-generated"] path = cocos/scripting/auto-generated -url=git://github.com/cocos2d-x/bindings-auto-generated.git + url = git://github.com/cocos2d-x/bindings-auto-generated.git [submodule "samples/Javascript/Shared"] path = samples/Javascript/Shared url = git://github.com/cocos2d/cocos2d-js-tests.git diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp deleted file mode 100644 index 4c3168fde4..0000000000 --- a/cocos2dx/base_nodes/CCNode.cpp +++ /dev/null @@ -1,1538 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2008-2010 Ricardo Quesada -Copyright (c) 2009 Valentin Milea -Copyright (c) 2011 Zynga Inc. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#include "CCNode.h" - -#include - -#include "cocoa/CCString.h" -#include "support/data_support/ccCArray.h" -#include "support/TransformUtils.h" -#include "CCCamera.h" -#include "effects/CCGrid.h" -#include "CCDirector.h" -#include "CCScheduler.h" -#include "event_dispatcher/CCTouch.h" -#include "actions/CCActionManager.h" -#include "script_support/CCScriptSupport.h" -#include "shaders/CCGLProgram.h" -#include "event_dispatcher/CCEventDispatcher.h" -#include "event_dispatcher/CCEvent.h" -#include "event_dispatcher/CCEventTouch.h" - -#ifdef CC_USE_PHYSICS -#include "physics/CCPhysicsBody.h" -#endif - -// externals -#include "kazmath/GL/matrix.h" -#include "support/component/CCComponent.h" -#include "support/component/CCComponentContainer.h" - - - -#if CC_NODE_RENDER_SUBPIXEL -#define RENDER_IN_SUBPIXEL -#else -#define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__)) -#endif - -NS_CC_BEGIN - -#if CC_USE_ARRAY_VECTOR -bool nodeComparisonLess(const RCPtr& pp1, const RCPtr& pp2) -{ - Object *p1 = static_cast(pp1); - Object *p2 = static_cast(pp2); - Node *n1 = static_cast(p1); - Node *n2 = static_cast(p2); - - return( n1->getZOrder() < n2->getZOrder() || - ( n1->getZOrder() == n2->getZOrder() && n1->getOrderOfArrival() < n2->getOrderOfArrival() ) - ); -} -#else -bool nodeComparisonLess(Object* p1, Object* p2) -{ - Node *n1 = static_cast(p1); - Node *n2 = static_cast(p2); - - return( n1->getZOrder() < n2->getZOrder() || - ( n1->getZOrder() == n2->getZOrder() && n1->getOrderOfArrival() < n2->getOrderOfArrival() ) - ); -} -#endif - -// XXX: Yes, nodes might have a sort problem once every 15 days if the game runs at 60 FPS and each frame sprites are reordered. -static int s_globalOrderOfArrival = 1; -int Node::_globalEventPriorityIndex = 0; - -Node::Node(void) -: _rotationX(0.0f) -, _rotationY(0.0f) -, _scaleX(1.0f) -, _scaleY(1.0f) -, _vertexZ(0.0f) -, _position(Point::ZERO) -, _skewX(0.0f) -, _skewY(0.0f) -, _anchorPointInPoints(Point::ZERO) -, _anchorPoint(Point::ZERO) -, _contentSize(Size::ZERO) -, _additionalTransform(AffineTransform::IDENTITY) -, _transform(AffineTransform::IDENTITY) -, _inverse(AffineTransform::IDENTITY) -, _additionalTransformDirty(false) -, _transformDirty(true) -, _inverseDirty(true) -, _camera(NULL) -// children (lazy allocs) -// lazy alloc -, _grid(NULL) -, _ZOrder(0) -, _children(NULL) -, _parent(NULL) -// "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true -, _tag(Node::INVALID_TAG) -// userData is always inited as nil -, _userData(NULL) -, _userObject(NULL) -, _shaderProgram(NULL) -, _orderOfArrival(0) -, _running(false) -, _visible(true) -, _ignoreAnchorPointForPosition(false) -, _reorderChildDirty(false) -, _isTransitionFinished(false) -, _updateScriptHandler(0) -, _componentContainer(NULL) -, _eventPriority(0) -, _oldEventPriority(0) -#ifdef CC_USE_PHYSICS -, _physicsBody(nullptr) -#endif -{ - // set default scheduler and actionManager - Director *director = Director::getInstance(); - _actionManager = director->getActionManager(); - _actionManager->retain(); - _scheduler = director->getScheduler(); - _scheduler->retain(); - - ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine(); - _scriptType = pEngine != NULL ? pEngine->getScriptType() : kScriptTypeNone; -} - -Node::~Node() -{ - CCLOGINFO( "deallocing Node: %p - tag: %i", this, _tag ); - - if (_updateScriptHandler) - { - ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptHandler(_updateScriptHandler); - } - - CC_SAFE_RELEASE(_actionManager); - CC_SAFE_RELEASE(_scheduler); - // attributes - CC_SAFE_RELEASE(_camera); - - CC_SAFE_RELEASE(_grid); - CC_SAFE_RELEASE(_shaderProgram); - CC_SAFE_RELEASE(_userObject); - - if(_children && _children->count() > 0) - { - Object* child; - CCARRAY_FOREACH(_children, child) - { - Node* node = static_cast(child); - if (node) - { - node->_parent = NULL; - } - } - } - - // children - CC_SAFE_RELEASE(_children); - - removeAllComponents(); - - CC_SAFE_DELETE(_componentContainer); - - removeAllEventListeners(); - -#ifdef CC_USE_PHYSICS - CC_SAFE_RELEASE(_physicsBody); -#endif -} - -bool Node::init() -{ - return true; -} - -float Node::getSkewX() const -{ - return _skewX; -} - -void Node::setSkewX(float newSkewX) -{ - _skewX = newSkewX; - _transformDirty = _inverseDirty = true; -} - -float Node::getSkewY() const -{ - return _skewY; -} - -void Node::setSkewY(float newSkewY) -{ - _skewY = newSkewY; - - _transformDirty = _inverseDirty = true; -} - -/// zOrder getter -int Node::getZOrder() const -{ - return _ZOrder; -} - -/// zOrder setter : private method -/// used internally to alter the zOrder variable. DON'T call this method manually -void Node::_setZOrder(int z) -{ - _ZOrder = z; -} - -void Node::setZOrder(int z) -{ - _setZOrder(z); - if (_parent) - { - _parent->reorderChild(this, z); - } -} - -/// vertexZ getter -float Node::getVertexZ() const -{ - return _vertexZ; -} - - -/// vertexZ setter -void Node::setVertexZ(float var) -{ - _vertexZ = var; -} - - -/// rotation getter -float Node::getRotation() const -{ - CCASSERT(_rotationX == _rotationY, "CCNode#rotation. RotationX != RotationY. Don't know which one to return"); - return _rotationX; -} - -/// rotation setter -void Node::setRotation(float newRotation) -{ - _rotationX = _rotationY = newRotation; - _transformDirty = _inverseDirty = true; - -#ifdef CC_USE_PHYSICS - if (_physicsBody) - { - _physicsBody->setRotation(newRotation); - } -#endif -} - -float Node::getRotationX() const -{ - return _rotationX; -} - -void Node::setRotationX(float fRotationX) -{ - _rotationX = fRotationX; - _transformDirty = _inverseDirty = true; -} - -float Node::getRotationY() const -{ - return _rotationY; -} - -void Node::setRotationY(float fRotationY) -{ - _rotationY = fRotationY; - _transformDirty = _inverseDirty = true; -} - -/// scale getter -float Node::getScale(void) const -{ - CCASSERT( _scaleX == _scaleY, "CCNode#scale. ScaleX != ScaleY. Don't know which one to return"); - return _scaleX; -} - -/// scale setter -void Node::setScale(float scale) -{ - _scaleX = _scaleY = scale; - _transformDirty = _inverseDirty = true; -} - -/// scaleX getter -float Node::getScaleX() const -{ - return _scaleX; -} - -/// scale setter -void Node::setScale(float scaleX,float scaleY) -{ - _scaleX = scaleX; - _scaleY = scaleY; - _transformDirty = _inverseDirty = true; -} - -/// scaleX setter -void Node::setScaleX(float newScaleX) -{ - _scaleX = newScaleX; - _transformDirty = _inverseDirty = true; -} - -/// scaleY getter -float Node::getScaleY() const -{ - return _scaleY; -} - -/// scaleY setter -void Node::setScaleY(float newScaleY) -{ - _scaleY = newScaleY; - _transformDirty = _inverseDirty = true; -} - -/// position getter -const Point& Node::getPosition() const -{ - return _position; -} - -/// position setter -void Node::setPosition(const Point& newPosition) -{ - _position = newPosition; - _transformDirty = _inverseDirty = true; - -#ifdef CC_USE_PHYSICS - if (_physicsBody) - { - _physicsBody->setPosition(newPosition); - } -#endif -} - -void Node::getPosition(float* x, float* y) const -{ - *x = _position.x; - *y = _position.y; -} - -void Node::setPosition(float x, float y) -{ - setPosition(Point(x, y)); -} - -float Node::getPositionX() const -{ - return _position.x; -} - -float Node::getPositionY() const -{ - return _position.y; -} - -void Node::setPositionX(float x) -{ - setPosition(Point(x, _position.y)); -} - -void Node::setPositionY(float y) -{ - setPosition(Point(_position.x, y)); -} - -unsigned int Node::getChildrenCount() const -{ - return _children ? _children->count() : 0; -} - -/// camera getter: lazy alloc -Camera* Node::getCamera() -{ - if (!_camera) - { - _camera = new Camera(); - } - - return _camera; -} - -/// grid setter -void Node::setGrid(GridBase* pGrid) -{ - CC_SAFE_RETAIN(pGrid); - CC_SAFE_RELEASE(_grid); - _grid = pGrid; -} - - -/// isVisible getter -bool Node::isVisible() const -{ - return _visible; -} - -/// isVisible setter -void Node::setVisible(bool var) -{ - _visible = var; -} - -const Point& Node::getAnchorPointInPoints() const -{ - return _anchorPointInPoints; -} - -/// anchorPoint getter -const Point& Node::getAnchorPoint() const -{ - return _anchorPoint; -} - -void Node::setAnchorPoint(const Point& point) -{ - if( ! point.equals(_anchorPoint)) - { - _anchorPoint = point; - _anchorPointInPoints = Point(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y ); - _transformDirty = _inverseDirty = true; - } -} - -/// contentSize getter -const Size& Node::getContentSize() const -{ - return _contentSize; -} - -void Node::setContentSize(const Size & size) -{ - if ( ! size.equals(_contentSize)) - { - _contentSize = size; - - _anchorPointInPoints = Point(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y ); - _transformDirty = _inverseDirty = true; - } -} - -// isRunning getter -bool Node::isRunning() const -{ - return _running; -} - -/// parent setter -void Node::setParent(Node * var) -{ - _parent = var; -} - -/// isRelativeAnchorPoint getter -bool Node::isIgnoreAnchorPointForPosition() const -{ - return _ignoreAnchorPointForPosition; -} -/// isRelativeAnchorPoint setter -void Node::ignoreAnchorPointForPosition(bool newValue) -{ - if (newValue != _ignoreAnchorPointForPosition) - { - _ignoreAnchorPointForPosition = newValue; - _transformDirty = _inverseDirty = true; - } -} - -/// tag getter -int Node::getTag() const -{ - return _tag; -} - -/// tag setter -void Node::setTag(int var) -{ - _tag = var; -} - -/// userData setter -void Node::setUserData(void *var) -{ - _userData = var; -} - -int Node::getOrderOfArrival() const -{ - return _orderOfArrival; -} - -void Node::setOrderOfArrival(int orderOfArrival) -{ - CCASSERT(orderOfArrival >=0, "Invalid orderOfArrival"); - _orderOfArrival = orderOfArrival; -} - -void Node::setUserObject(Object *pUserObject) -{ - CC_SAFE_RETAIN(pUserObject); - CC_SAFE_RELEASE(_userObject); - _userObject = pUserObject; -} - -void Node::setShaderProgram(GLProgram *pShaderProgram) -{ - CC_SAFE_RETAIN(pShaderProgram); - CC_SAFE_RELEASE(_shaderProgram); - _shaderProgram = pShaderProgram; -} - -Rect Node::getBoundingBox() const -{ - Rect rect = Rect(0, 0, _contentSize.width, _contentSize.height); - return RectApplyAffineTransform(rect, getNodeToParentTransform()); -} - -Node * Node::create(void) -{ - Node * pRet = new Node(); - if (pRet && pRet->init()) - { - pRet->autorelease(); - } - else - { - CC_SAFE_DELETE(pRet); - } - return pRet; -} - -void Node::cleanup() -{ - // actions - this->stopAllActions(); - this->unscheduleAllSelectors(); - - if ( _scriptType != kScriptTypeNone) - { - int action = kNodeOnCleanup; - BasicScriptData data(this,(void*)&action); - ScriptEvent scriptEvent(kNodeEvent,(void*)&data); - ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); - } - - // timers - arrayMakeObjectsPerformSelector(_children, cleanup, Node*); -} - - -const char* Node::description() const -{ - return String::createWithFormat("", _tag)->getCString(); -} - -// lazy allocs -void Node::childrenAlloc(void) -{ - _children = Array::createWithCapacity(4); - _children->retain(); -} - -Node* Node::getChildByTag(int aTag) -{ - CCASSERT( aTag != Node::INVALID_TAG, "Invalid tag"); - - if(_children && _children->count() > 0) - { - Object* child; - CCARRAY_FOREACH(_children, child) - { - Node* pNode = static_cast(child); - if(pNode && pNode->_tag == aTag) - return pNode; - } - } - return NULL; -} - -/* "add" logic MUST only be on this method -* If a class want's to extend the 'addChild' behavior it only needs -* to override this method -*/ -void Node::addChild(Node *child, int zOrder, int tag) -{ - CCASSERT( child != NULL, "Argument must be non-nil"); - CCASSERT( child->_parent == NULL, "child already added. It can't be added again"); - - if( ! _children ) - { - this->childrenAlloc(); - } - - this->insertChild(child, zOrder); - - child->_tag = tag; - - child->setParent(this); - child->setOrderOfArrival(s_globalOrderOfArrival++); - - if( _running ) - { - child->onEnter(); - // prevent onEnterTransitionDidFinish to be called twice when a node is added in onEnter - if (_isTransitionFinished) { - child->onEnterTransitionDidFinish(); - } - } -} - -void Node::addChild(Node *child, int zOrder) -{ - CCASSERT( child != NULL, "Argument must be non-nil"); - this->addChild(child, zOrder, child->_tag); -} - -void Node::addChild(Node *child) -{ - CCASSERT( child != NULL, "Argument must be non-nil"); - this->addChild(child, child->_ZOrder, child->_tag); -} - -void Node::removeFromParent() -{ - this->removeFromParentAndCleanup(true); -} - -void Node::removeFromParentAndCleanup(bool cleanup) -{ - if (_parent != NULL) - { - _parent->removeChild(this,cleanup); - } -} - -/* "remove" logic MUST only be on this method -* If a class want's to extend the 'removeChild' behavior it only needs -* to override this method -*/ -void Node::removeChild(Node* child, bool cleanup /* = true */) -{ - // explicit nil handling - if (_children == NULL) - { - return; - } - - int index = _children->getIndexOfObject(child); - if( index != CC_INVALID_INDEX ) - this->detachChild( child, index, cleanup ); -} - -void Node::removeChildByTag(int tag, bool cleanup/* = true */) -{ - CCASSERT( tag != Node::INVALID_TAG, "Invalid tag"); - - Node *child = this->getChildByTag(tag); - - if (child == NULL) - { - CCLOG("cocos2d: removeChildByTag(tag = %d): child not found!", tag); - } - else - { - this->removeChild(child, cleanup); - } -} - -void Node::removeAllChildren() -{ - this->removeAllChildrenWithCleanup(true); -} - -void Node::removeAllChildrenWithCleanup(bool cleanup) -{ - // not using detachChild improves speed here - if ( _children && _children->count() > 0 ) - { - Object* child; - CCARRAY_FOREACH(_children, child) - { - Node* pNode = static_cast(child); - if (pNode) - { - // IMPORTANT: - // -1st do onExit - // -2nd cleanup - if(_running) - { - pNode->onExitTransitionDidStart(); - pNode->onExit(); - } - - if (cleanup) - { - pNode->cleanup(); - } - // set parent nil at the end - pNode->setParent(NULL); - } - } - - _children->removeAllObjects(); - } - -} - -void Node::detachChild(Node *child, int childIndex, bool doCleanup) -{ - // IMPORTANT: - // -1st do onExit - // -2nd cleanup - if (_running) - { - child->onExitTransitionDidStart(); - child->onExit(); - } - - // If you don't do cleanup, the child's actions will not get removed and the - // its scheduledSelectors_ dict will not get released! - if (doCleanup) - { - child->cleanup(); - } - - // set parent nil at the end - child->setParent(NULL); - - _children->removeObjectAtIndex(childIndex); -} - - -// helper used by reorderChild & add -void Node::insertChild(Node* child, int z) -{ - _reorderChildDirty = true; - _children->addObject(child); - child->_setZOrder(z); -} - -void Node::reorderChild(Node *child, int zOrder) -{ - CCASSERT( child != NULL, "Child must be non-nil"); - _reorderChildDirty = true; - child->setOrderOfArrival(s_globalOrderOfArrival++); - child->_setZOrder(zOrder); -} - -void Node::sortAllChildren() -{ -#if 0 - if (_reorderChildDirty) - { - int i,j,length = _children->count(); - - // insertion sort - for(i=1; i( _children->getObjectAtIndex(i) ); - auto tempJ = static_cast( _children->getObjectAtIndex(j) ); - - //continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller - while(j>=0 && ( tempI->_ZOrder < tempJ->_ZOrder || ( tempI->_ZOrder == tempJ->_ZOrder && tempI->_orderOfArrival < tempJ->_orderOfArrival ) ) ) - { - _children->fastSetObject( tempJ, j+1 ); - j = j-1; - if(j>=0) - tempJ = static_cast( _children->getObjectAtIndex(j) ); - } - _children->fastSetObject(tempI, j+1); - } - - //don't need to check children recursively, that's done in visit of each child - - _reorderChildDirty = false; - } -#else - if( _reorderChildDirty ) { - std::sort( std::begin(*_children), std::end(*_children), nodeComparisonLess ); - _reorderChildDirty = false; - } -#endif -} - - - void Node::draw() - { - //CCASSERT(0); - // override me - // Only use- this function to draw your stuff. - // DON'T draw your stuff outside this method - } - -void Node::visit() -{ - // quick return if not visible. children won't be drawn. - if (!_visible) - { - return; - } - - kmGLPushMatrix(); - - if (_grid && _grid->isActive()) - { - _grid->beforeDraw(); - } - - this->transform(); - int i = 0; - - if(_children && _children->count() > 0) - { - sortAllChildren(); - // draw children zOrder < 0 - for( ; i < _children->count(); i++ ) - { - auto node = static_cast( _children->getObjectAtIndex(i) ); - - if ( node && node->_ZOrder < 0 ) - node->visit(); - else - break; - } - // self draw - this->draw(); - updateEventPriorityIndex(); - - for( ; i < _children->count(); i++ ) - { - auto node = static_cast( _children->getObjectAtIndex(i) ); - if (node) - node->visit(); - } - } - else - { - this->draw(); - updateEventPriorityIndex(); - } - - // reset for next frame - _orderOfArrival = 0; - - if (_grid && _grid->isActive()) - { - _grid->afterDraw(this); - } - - kmGLPopMatrix(); -} - -void Node::transformAncestors() -{ - if( _parent != NULL ) - { - _parent->transformAncestors(); - _parent->transform(); - } -} - -#ifdef CC_USE_PHYSICS -void Node::updatePhysicsTransform() -{ - if (_physicsBody && _physicsBody->isEnable() && !_physicsBody->isResting()) - { - _position = _physicsBody->getPosition(); - _rotationX = _rotationY = _physicsBody->getRotation(); - _transformDirty = _inverseDirty = true; - } -} -#endif - - -void Node::transform() -{ -#ifdef CC_USE_PHYSICS - updatePhysicsTransform(); -#endif - - kmMat4 transfrom4x4; - - // Convert 3x3 into 4x4 matrix - CGAffineToGL(this->getNodeToParentTransform(), transfrom4x4.mat); - - // Update Z vertex manually - transfrom4x4.mat[14] = _vertexZ; - - kmGLMultMatrix( &transfrom4x4 ); - - - // XXX: Expensive calls. Camera should be integrated into the cached affine matrix - if ( _camera != NULL && !(_grid != NULL && _grid->isActive()) ) - { - bool translate = (_anchorPointInPoints.x != 0.0f || _anchorPointInPoints.y != 0.0f); - - if( translate ) - kmGLTranslatef(RENDER_IN_SUBPIXEL(_anchorPointInPoints.x), RENDER_IN_SUBPIXEL(_anchorPointInPoints.y), 0 ); - - _camera->locate(); - - if( translate ) - kmGLTranslatef(RENDER_IN_SUBPIXEL(-_anchorPointInPoints.x), RENDER_IN_SUBPIXEL(-_anchorPointInPoints.y), 0 ); - } - -} - - -void Node::onEnter() -{ - _isTransitionFinished = false; - - arrayMakeObjectsPerformSelector(_children, onEnter, Node*); - - this->resumeSchedulerAndActions(); - - _running = true; - - if (_scriptType != kScriptTypeNone) - { - int action = kNodeOnEnter; - BasicScriptData data(this,(void*)&action); - ScriptEvent scriptEvent(kNodeEvent,(void*)&data); - ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); - } -} - -void Node::onEnterTransitionDidFinish() -{ - _isTransitionFinished = true; - - arrayMakeObjectsPerformSelector(_children, onEnterTransitionDidFinish, Node*); - - if (_scriptType != kScriptTypeNone) - { - int action = kNodeOnEnterTransitionDidFinish; - BasicScriptData data(this,(void*)&action); - ScriptEvent scriptEvent(kNodeEvent,(void*)&data); - ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); - } -} - -void Node::onExitTransitionDidStart() -{ - arrayMakeObjectsPerformSelector(_children, onExitTransitionDidStart, Node*); - if (_scriptType != kScriptTypeNone) - { - int action = kNodeOnExitTransitionDidStart; - BasicScriptData data(this,(void*)&action); - ScriptEvent scriptEvent(kNodeEvent,(void*)&data); - ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); - } -} - -void Node::onExit() -{ - this->pauseSchedulerAndActions(); - - _running = false; - if (_scriptType != kScriptTypeNone) - { - int action = kNodeOnExit; - BasicScriptData data(this,(void*)&action); - ScriptEvent scriptEvent(kNodeEvent,(void*)&data); - ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); - } - - arrayMakeObjectsPerformSelector(_children, onExit, Node*); - - removeAllEventListeners(); -} - -void Node::setActionManager(ActionManager* actionManager) -{ - if( actionManager != _actionManager ) { - this->stopAllActions(); - CC_SAFE_RETAIN(actionManager); - CC_SAFE_RELEASE(_actionManager); - _actionManager = actionManager; - } -} - -Action * Node::runAction(Action* action) -{ - CCASSERT( action != NULL, "Argument must be non-nil"); - _actionManager->addAction(action, this, !_running); - return action; -} - -void Node::stopAllActions() -{ - _actionManager->removeAllActionsFromTarget(this); -} - -void Node::stopAction(Action* action) -{ - _actionManager->removeAction(action); -} - -void Node::stopActionByTag(int tag) -{ - CCASSERT( tag != Action::INVALID_TAG, "Invalid tag"); - _actionManager->removeActionByTag(tag, this); -} - -Action * Node::getActionByTag(int tag) -{ - CCASSERT( tag != Action::INVALID_TAG, "Invalid tag"); - return _actionManager->getActionByTag(tag, this); -} - -unsigned int Node::getNumberOfRunningActions() const -{ - return _actionManager->getNumberOfRunningActionsInTarget(this); -} - -// Node - Callbacks - -void Node::setScheduler(Scheduler* scheduler) -{ - if( scheduler != _scheduler ) { - this->unscheduleAllSelectors(); - CC_SAFE_RETAIN(scheduler); - CC_SAFE_RELEASE(_scheduler); - _scheduler = scheduler; - } -} - -bool Node::isScheduled(SEL_SCHEDULE selector) -{ - return _scheduler->isScheduledForTarget(selector, this); -} - -void Node::scheduleUpdate() -{ - scheduleUpdateWithPriority(0); -} - -void Node::scheduleUpdateWithPriority(int priority) -{ - _scheduler->scheduleUpdateForTarget(this, priority, !_running); -} - -void Node::scheduleUpdateWithPriorityLua(int nHandler, int priority) -{ - unscheduleUpdate(); - _updateScriptHandler = nHandler; - _scheduler->scheduleUpdateForTarget(this, priority, !_running); -} - -void Node::unscheduleUpdate() -{ - _scheduler->unscheduleUpdateForTarget(this); - if (_updateScriptHandler) - { - ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptHandler(_updateScriptHandler); - _updateScriptHandler = 0; - } -} - -void Node::schedule(SEL_SCHEDULE selector) -{ - this->schedule(selector, 0.0f, kRepeatForever, 0.0f); -} - -void Node::schedule(SEL_SCHEDULE selector, float interval) -{ - this->schedule(selector, interval, kRepeatForever, 0.0f); -} - -void Node::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay) -{ - CCASSERT( selector, "Argument must be non-nil"); - CCASSERT( interval >=0, "Argument must be positive"); - - _scheduler->scheduleSelector(selector, this, interval , repeat, delay, !_running); -} - -void Node::scheduleOnce(SEL_SCHEDULE selector, float delay) -{ - this->schedule(selector, 0.0f, 0, delay); -} - -void Node::unschedule(SEL_SCHEDULE selector) -{ - // explicit nil handling - if (selector == 0) - return; - - _scheduler->unscheduleSelector(selector, this); -} - -void Node::unscheduleAllSelectors() -{ - _scheduler->unscheduleAllForTarget(this); -} - -void Node::resumeSchedulerAndActions() -{ - _scheduler->resumeTarget(this); - _actionManager->resumeTarget(this); -} - -void Node::pauseSchedulerAndActions() -{ - _scheduler->pauseTarget(this); - _actionManager->pauseTarget(this); -} - -// override me -void Node::update(float fDelta) -{ - if (0 != _updateScriptHandler) - { - //only lua use - SchedulerScriptData data(_updateScriptHandler,fDelta); - ScriptEvent event(kScheduleEvent,&data); - ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - } - - if (_componentContainer && !_componentContainer->isEmpty()) - { - _componentContainer->visit(fDelta); - } -} - -const AffineTransform& Node::getNodeToParentTransform() const -{ - if (_transformDirty) - { - - // Translate values - float x = _position.x; - float y = _position.y; - - if (_ignoreAnchorPointForPosition) - { - x += _anchorPointInPoints.x; - y += _anchorPointInPoints.y; - } - - // Rotation values - // Change rotation code to handle X and Y - // If we skew with the exact same value for both x and y then we're simply just rotating - float cx = 1, sx = 0, cy = 1, sy = 0; - if (_rotationX || _rotationY) - { - float radiansX = -CC_DEGREES_TO_RADIANS(_rotationX); - float radiansY = -CC_DEGREES_TO_RADIANS(_rotationY); - cx = cosf(radiansX); - sx = sinf(radiansX); - cy = cosf(radiansY); - sy = sinf(radiansY); - } - - bool needsSkewMatrix = ( _skewX || _skewY ); - - - // optimization: - // inline anchor point calculation if skew is not needed - // Adjusted transform calculation for rotational skew - if (! needsSkewMatrix && !_anchorPointInPoints.equals(Point::ZERO)) - { - x += cy * -_anchorPointInPoints.x * _scaleX + -sx * -_anchorPointInPoints.y * _scaleY; - y += sy * -_anchorPointInPoints.x * _scaleX + cx * -_anchorPointInPoints.y * _scaleY; - } - - - // Build Transform Matrix - // Adjusted transform calculation for rotational skew - _transform = AffineTransformMake( cy * _scaleX, sy * _scaleX, - -sx * _scaleY, cx * _scaleY, - x, y ); - - // XXX: Try to inline skew - // If skew is needed, apply skew and then anchor point - if (needsSkewMatrix) - { - AffineTransform skewMatrix = AffineTransformMake(1.0f, tanf(CC_DEGREES_TO_RADIANS(_skewY)), - tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1.0f, - 0.0f, 0.0f ); - _transform = AffineTransformConcat(skewMatrix, _transform); - - // adjust anchor point - if (!_anchorPointInPoints.equals(Point::ZERO)) - { - _transform = AffineTransformTranslate(_transform, -_anchorPointInPoints.x, -_anchorPointInPoints.y); - } - } - - if (_additionalTransformDirty) - { - _transform = AffineTransformConcat(_transform, _additionalTransform); - _additionalTransformDirty = false; - } - - _transformDirty = false; - } - - return _transform; -} - -void Node::setAdditionalTransform(const AffineTransform& additionalTransform) -{ - _additionalTransform = additionalTransform; - _transformDirty = true; - _additionalTransformDirty = true; -} - -const AffineTransform& Node::getParentToNodeTransform() const -{ - if ( _inverseDirty ) { - _inverse = AffineTransformInvert(this->getNodeToParentTransform()); - _inverseDirty = false; - } - - return _inverse; -} - -AffineTransform Node::getNodeToWorldTransform() const -{ - AffineTransform t = this->getNodeToParentTransform(); - - for (Node *p = _parent; p != NULL; p = p->getParent()) - t = AffineTransformConcat(t, p->getNodeToParentTransform()); - - return t; -} - -AffineTransform Node::getWorldToNodeTransform() const -{ - return AffineTransformInvert(this->getNodeToWorldTransform()); -} - -Point Node::convertToNodeSpace(const Point& worldPoint) const -{ - Point ret = PointApplyAffineTransform(worldPoint, getWorldToNodeTransform()); - return ret; -} - -Point Node::convertToWorldSpace(const Point& nodePoint) const -{ - Point ret = PointApplyAffineTransform(nodePoint, getNodeToWorldTransform()); - return ret; -} - -Point Node::convertToNodeSpaceAR(const Point& worldPoint) const -{ - Point nodePoint = convertToNodeSpace(worldPoint); - return nodePoint - _anchorPointInPoints; -} - -Point Node::convertToWorldSpaceAR(const Point& nodePoint) const -{ - Point pt = nodePoint + _anchorPointInPoints; - return convertToWorldSpace(pt); -} - -Point Node::convertToWindowSpace(const Point& nodePoint) const -{ - Point worldPoint = this->convertToWorldSpace(nodePoint); - return Director::getInstance()->convertToUI(worldPoint); -} - -// convenience methods which take a Touch instead of Point -Point Node::convertTouchToNodeSpace(Touch *touch) const -{ - Point point = touch->getLocation(); - return this->convertToNodeSpace(point); -} -Point Node::convertTouchToNodeSpaceAR(Touch *touch) const -{ - Point point = touch->getLocation(); - return this->convertToNodeSpaceAR(point); -} - -void Node::updateTransform() -{ - // Recursively iterate over children - arrayMakeObjectsPerformSelector(_children, updateTransform, Node*); -} - -Component* Node::getComponent(const char *pName) -{ - if( _componentContainer ) - return _componentContainer->get(pName); - return nullptr; -} - -bool Node::addComponent(Component *pComponent) -{ - // lazy alloc - if( !_componentContainer ) - _componentContainer = new ComponentContainer(this); - return _componentContainer->add(pComponent); -} - -bool Node::removeComponent(const char *pName) -{ - if( _componentContainer ) - return _componentContainer->remove(pName); - return false; -} - -void Node::removeAllComponents() -{ - if( _componentContainer ) - _componentContainer->removeAll(); -} - -void Node::resetEventPriorityIndex() -{ - _globalEventPriorityIndex = 0; -} - -void Node::associateEventListener(EventListener* listener) -{ - _eventlisteners.insert(listener); -} - -void Node::dissociateEventListener(EventListener* listener) -{ - _eventlisteners.erase(listener); -} - -void Node::removeAllEventListeners() -{ - auto dispatcher = EventDispatcher::getInstance(); - - auto eventListenersCopy = _eventlisteners; - - for (auto& listener : eventListenersCopy) - { - dispatcher->removeEventListener(listener); - } -} - -void Node::setDirtyForAllEventListeners() -{ - auto dispatcher = EventDispatcher::getInstance(); - - for (auto& listener : _eventlisteners) - { - dispatcher->setDirtyForEventType(listener->_type, true); - } -} - -#ifdef CC_USE_PHYSICS -void Node::setPhysicsBody(PhysicsBody* body) -{ - if (_physicsBody != nullptr) - { - _physicsBody->release(); - } - - _physicsBody = body; - _physicsBody->retain(); - _physicsBody->setPosition(getPosition()); - _physicsBody->setRotation(getRotation()); -} - -PhysicsBody* Node::getPhysicsBody() const -{ - return _physicsBody; -} -#endif //CC_USE_PHYSICS - -// NodeRGBA -NodeRGBA::NodeRGBA() -: _displayedOpacity(255) -, _realOpacity(255) -, _displayedColor(Color3B::WHITE) -, _realColor(Color3B::WHITE) -, _cascadeColorEnabled(false) -, _cascadeOpacityEnabled(false) -{} - -NodeRGBA::~NodeRGBA() {} - -bool NodeRGBA::init() -{ - if (Node::init()) - { - _displayedOpacity = _realOpacity = 255; - _displayedColor = _realColor = Color3B::WHITE; - _cascadeOpacityEnabled = _cascadeColorEnabled = false; - return true; - } - return false; -} - -GLubyte NodeRGBA::getOpacity(void) const -{ - return _realOpacity; -} - -GLubyte NodeRGBA::getDisplayedOpacity(void) const -{ - return _displayedOpacity; -} - -void NodeRGBA::setOpacity(GLubyte opacity) -{ - _displayedOpacity = _realOpacity = opacity; - - if (_cascadeOpacityEnabled) - { - GLubyte parentOpacity = 255; - RGBAProtocol* pParent = dynamic_cast(_parent); - if (pParent && pParent->isCascadeOpacityEnabled()) - { - parentOpacity = pParent->getDisplayedOpacity(); - } - this->updateDisplayedOpacity(parentOpacity); - } -} - -void NodeRGBA::updateDisplayedOpacity(GLubyte parentOpacity) -{ - _displayedOpacity = _realOpacity * parentOpacity/255.0; - - if (_cascadeOpacityEnabled) - { - Object* pObj; - CCARRAY_FOREACH(_children, pObj) - { - RGBAProtocol* item = dynamic_cast(pObj); - if (item) - { - item->updateDisplayedOpacity(_displayedOpacity); - } - } - } -} - -bool NodeRGBA::isCascadeOpacityEnabled(void) const -{ - return _cascadeOpacityEnabled; -} - -void NodeRGBA::setCascadeOpacityEnabled(bool cascadeOpacityEnabled) -{ - _cascadeOpacityEnabled = cascadeOpacityEnabled; -} - -const Color3B& NodeRGBA::getColor(void) const -{ - return _realColor; -} - -const Color3B& NodeRGBA::getDisplayedColor() const -{ - return _displayedColor; -} - -void NodeRGBA::setColor(const Color3B& color) -{ - _displayedColor = _realColor = color; - - if (_cascadeColorEnabled) - { - Color3B parentColor = Color3B::WHITE; - RGBAProtocol *parent = dynamic_cast(_parent); - if (parent && parent->isCascadeColorEnabled()) - { - parentColor = parent->getDisplayedColor(); - } - - updateDisplayedColor(parentColor); - } -} - -void NodeRGBA::updateDisplayedColor(const Color3B& parentColor) -{ - _displayedColor.r = _realColor.r * parentColor.r/255.0; - _displayedColor.g = _realColor.g * parentColor.g/255.0; - _displayedColor.b = _realColor.b * parentColor.b/255.0; - - if (_cascadeColorEnabled) - { - Object *obj = NULL; - CCARRAY_FOREACH(_children, obj) - { - RGBAProtocol *item = dynamic_cast(obj); - if (item) - { - item->updateDisplayedColor(_displayedColor); - } - } - } -} - -bool NodeRGBA::isCascadeColorEnabled(void) const -{ - return _cascadeColorEnabled; -} - -void NodeRGBA::setCascadeColorEnabled(bool cascadeColorEnabled) -{ - _cascadeColorEnabled = cascadeColorEnabled; -} - -NS_CC_END diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h deleted file mode 100644 index 575e4b5cfb..0000000000 --- a/cocos2dx/base_nodes/CCNode.h +++ /dev/null @@ -1,1575 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2009 Valentin Milea - Copyright (c) 2011 Zynga Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __PLATFORM_CCNODE_H__ -#define __PLATFORM_CCNODE_H__ - -#include "ccMacros.h" -#include "cocoa/CCAffineTransform.h" -#include "cocoa/CCArray.h" -#include "CCGL.h" -#include "shaders/ccGLStateCache.h" -#include "shaders/CCGLProgram.h" -#include "kazmath/kazmath.h" -#include "script_support/CCScriptSupport.h" -#include "CCProtocols.h" -#include "event_dispatcher/CCEventDispatcher.h" -#include "physics/CCPhysicsSetting.h" - -#include - -NS_CC_BEGIN - -class Camera; -class GridBase; -class Point; -class Touch; -class Action; -class RGBAProtocol; -class LabelProtocol; -class Scheduler; -class ActionManager; -class Component; -class Dictionary; -class ComponentContainer; -class EventDispatcher; -#ifdef CC_USE_PHYSICS -class PhysicsBody; -#endif - -/** - * @addtogroup base_nodes - * @{ - */ - -enum { - kNodeOnEnter, - kNodeOnExit, - kNodeOnEnterTransitionDidFinish, - kNodeOnExitTransitionDidStart, - kNodeOnCleanup -}; - -#if CC_USE_ARRAY_VECTOR -bool nodeComparisonLess(const RCPtr& pp1, const RCPtr& pp2); -#else -bool nodeComparisonLess(Object* p1, Object* p2); -#endif - -class EventListener; - -/** @brief Node is the main element. Anything that gets drawn or contains things that get drawn is a Node. - The most popular Nodes are: Scene, Layer, Sprite, Menu. - - The main features of a Node are: - - They can contain other Node nodes (addChild, getChildByTag, removeChild, etc) - - They can schedule periodic callback (schedule, unschedule, etc) - - They can execute actions (runAction, stopAction, etc) - - Some Node nodes provide extra functionality for them or their children. - - Subclassing a Node usually means (one/all) of: - - overriding init to initialize resources and schedule callbacks - - create callbacks to handle the advancement of time - - overriding draw to render the node - - Features of Node: - - position - - scale (x, y) - - rotation (in degrees, clockwise) - - Camera (an interface to gluLookAt ) - - GridBase (to do mesh transformations) - - anchor point - - size - - visible - - z-order - - openGL z position - - Default values: - - rotation: 0 - - position: (x=0,y=0) - - scale: (x=1,y=1) - - contentSize: (x=0,y=0) - - anchorPoint: (x=0,y=0) - - Limitations: - - A Node is a "void" object. It doesn't have a texture - - Order in transformations with grid disabled - -# The node will be translated (position) - -# The node will be rotated (rotation) - -# The node will be scaled (scale) - -# The node will be moved according to the camera values (camera) - - Order in transformations with grid enabled - -# The node will be translated (position) - -# The node will be rotated (rotation) - -# The node will be scaled (scale) - -# The grid will capture the screen - -# The node will be moved according to the camera values (camera) - -# The grid will render the captured screen - - Camera: - - Each node has a camera. By default it points to the center of the Node. - */ - -class CC_DLL Node : public Object -{ -public: - /// Default tag used for all the nodes - static const int INVALID_TAG = -1; - - /// @{ - /// @name Constructor, Destructor and Initializers - - /** - * Allocates and initializes a node. - * @return A initialized node which is marked as "autorelease". - */ - static Node * create(void); - - /** - * Default constructor - * @js ctor - */ - Node(void); - - /** - * Default destructor - * @js NA - * @lua NA - */ - virtual ~Node(void); - - /** - * Initializes the instance of Node - * @return Whether the initialization was successful. - */ - virtual bool init(); - - /** - * Gets the description string. It makes debugging easier. - * @return A string terminated with '\0' - * @js NA - * @lua NA - */ - const char* description(void) const; - - /// @} end of initializers - - - - /// @{ - /// @name Setters & Getters for Graphic Peroperties - - /** - * Sets the Z order which stands for the drawing order, and reorder this node in its parent's children array. - * - * The Z order of node is relative to its "brothers": children of the same parent. - * It's nothing to do with OpenGL's z vertex. This one only affects the draw order of nodes in cocos2d. - * The larger number it is, the later this node will be drawn in each message loop. - * Please refer to setVertexZ(float) for the difference. - * - * @param zOrder Z order of this node. - */ - virtual void setZOrder(int zOrder); - /** - * Sets the z order which stands for the drawing order - * - * This is an internal method. Don't call it outside the framework. - * The difference between setZOrder(int) and _setOrder(int) is: - * - _setZOrder(int) is a pure setter for _ZOrder memeber variable - * - setZOrder(int) firstly changes _ZOrder, then recorder this node in its parent's chilren array. - */ - virtual void _setZOrder(int z); - /** - * Gets the Z order of this node. - * - * @see setZOrder(int) - * - * @return The Z order. - */ - virtual int getZOrder() const; - - /** - * Sets the real OpenGL Z vertex. - * - * Differences between openGL Z vertex and cocos2d Z order: - * - OpenGL Z modifies the Z vertex, and not the Z order in the relation between parent-children - * - OpenGL Z might require to set 2D projection - * - cocos2d Z order works OK if all the nodes uses the same openGL Z vertex. eg: vertexZ = 0 - * - * @warning Use it at your own risk since it might break the cocos2d parent-children z order - * - * @param vertexZ OpenGL Z vertex of this node. - */ - virtual void setVertexZ(float vertexZ); - /** - * Gets OpenGL Z vertex of this node. - * - * @see setVertexZ(float) - * - * @return OpenGL Z vertex of this node - */ - virtual float getVertexZ() const; - - - /** - * Changes the scale factor on X axis of this node - * - * The deafult value is 1.0 if you haven't changed it before - * - * @param scaleX The scale factor on X axis. - */ - virtual void setScaleX(float scaleX); - /** - * Returns the scale factor on X axis of this node - * - * @see setScaleX(float) - * - * @return The scale factor on X axis. - */ - virtual float getScaleX() const; - - - /** - * Changes the scale factor on Y axis of this node - * - * The Default value is 1.0 if you haven't changed it before. - * - * @param scaleY The scale factor on Y axis. - */ - virtual void setScaleY(float scaleY); - /** - * Returns the scale factor on Y axis of this node - * - * @see setScaleY(float) - * - * @return The scale factor on Y axis. - */ - virtual float getScaleY() const; - - - /** - * Changes both X and Y scale factor of the node. - * - * 1.0 is the default scale factor. It modifies the X and Y scale at the same time. - * - * @param scale The scale factor for both X and Y axis. - */ - virtual void setScale(float scale); - /** - * Gets the scale factor of the node, when X and Y have the same scale factor. - * - * @warning Assert when _scaleX != _scaleY. - * @see setScale(float) - * - * @return The scale factor of the node. - */ - virtual float getScale() const; - - /** - * Changes both X and Y scale factor of the node. - * - * 1.0 is the default scale factor. It modifies the X and Y scale at the same time. - * - * @param scaleX The scale factor on X axis. - * @param scaleY The scale factor on Y axis. - */ - virtual void setScale(float scaleX,float scaleY); - - /** - * Changes the position (x,y) of the node in OpenGL coordinates - * - * Usually we use Point(x,y) to compose Point object. - * The original point (0,0) is at the left-bottom corner of screen. - * For example, this codesnip sets the node in the center of screen. - * @code - * Size size = Director::getInstance()->getWinSize(); - * node->setPosition( Point(size.width/2, size.height/2) ) - * @endcode - * - * @param position The position (x,y) of the node in OpenGL coordinates - */ - virtual void setPosition(const Point &position); - /** - * Gets the position (x,y) of the node in OpenGL coordinates - * - * @see setPosition(const Point&) - * - * @return The position (x,y) of the node in OpenGL coordinates - * @code - * In js and lua return value is table which contains x,y - * @endcode - */ - virtual const Point& getPosition() const; - /** - * Sets position in a more efficient way. - * - * Passing two numbers (x,y) is much efficient than passing Point object. - * This method is binded to lua and javascript. - * Passing a number is 10 times faster than passing a object from lua to c++ - * - * @code - * // sample code in lua - * local pos = node::getPosition() -- returns Point object from C++ - * node:setPosition(x, y) -- pass x, y coordinate to C++ - * @endcode - * - * @param x X coordinate for position - * @param y Y coordinate for position - */ - virtual void setPosition(float x, float y); - /** - * Gets position in a more efficient way, returns two number instead of a Point object - * - * @see setPosition(float, float) - * @code - * In js,out value not return - * @endcode - */ - virtual void getPosition(float* x, float* y) const; - /** - * Gets/Sets x or y coordinate individually for position. - * These methods are used in Lua and Javascript Bindings - */ - virtual void setPositionX(float x); - virtual float getPositionX(void) const; - virtual void setPositionY(float y); - virtual float getPositionY(void) const; - - - /** - * Changes the X skew angle of the node in degrees. - * - * This angle describes the shear distortion in the X direction. - * Thus, it is the angle between the Y axis and the left edge of the shape - * The default skewX angle is 0. Positive values distort the node in a CW direction. - * - * @param fSkewX The X skew angle of the node in degrees. - */ - virtual void setSkewX(float fSkewX); - /** - * Returns the X skew angle of the node in degrees. - * - * @see setSkewX(float) - * - * @return The X skew angle of the node in degrees. - */ - virtual float getSkewX() const; - - - /** - * Changes the Y skew angle of the node in degrees. - * - * This angle describes the shear distortion in the Y direction. - * Thus, it is the angle between the X axis and the bottom edge of the shape - * The default skewY angle is 0. Positive values distort the node in a CCW direction. - * - * @param fSkewY The Y skew angle of the node in degrees. - */ - virtual void setSkewY(float fSkewY); - /** - * Returns the Y skew angle of the node in degrees. - * - * @see setSkewY(float) - * - * @return The Y skew angle of the node in degrees. - */ - virtual float getSkewY() const; - - - /** - * Sets the anchor point in percent. - * - * anchorPoint is the point around which all transformations and positioning manipulations take place. - * It's like a pin in the node where it is "attached" to its parent. - * The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. - * But you can use values higher than (1,1) and lower than (0,0) too. - * The default anchorPoint is (0.5,0.5), so it starts in the center of the node. - * - * @param anchorPoint The anchor point of node. - */ - virtual void setAnchorPoint(const Point& anchorPoint); - /** - * Returns the anchor point in percent. - * - * @see setAnchorPoint(const Point&) - * - * @return The anchor point of node. - */ - virtual const Point& getAnchorPoint() const; - /** - * Returns the anchorPoint in absolute pixels. - * - * @warning You can only read it. If you wish to modify it, use anchorPoint instead. - * @see getAnchorPoint() - * - * @return The anchor point in absolute pixels. - */ - virtual const Point& getAnchorPointInPoints() const; - - - /** - * Sets the untransformed size of the node. - * - * The contentSize remains the same no matter the node is scaled or rotated. - * All nodes has a size. Layer and Scene has the same size of the screen. - * - * @param contentSize The untransformed size of the node. - */ - virtual void setContentSize(const Size& contentSize); - /** - * Returns the untransformed size of the node. - * - * @see setContentSize(const Size&) - * - * @return The untransformed size of the node. - */ - virtual const Size& getContentSize() const; - - - /** - * Sets whether the node is visible - * - * The default value is true, a node is default to visible - * - * @param visible true if the node is visible, false if the node is hidden. - */ - virtual void setVisible(bool visible); - /** - * Determines if the node is visible - * - * @see setVisible(bool) - * - * @return true if the node is visible, false if the node is hidden. - */ - virtual bool isVisible() const; - - - /** - * Sets the rotation (angle) of the node in degrees. - * - * 0 is the default rotation angle. - * Positive values rotate node clockwise, and negative values for anti-clockwise. - * - * @param rotation The rotation of the node in degrees. - */ - virtual void setRotation(float rotation); - /** - * Returns the rotation of the node in degrees. - * - * @see setRotation(float) - * - * @return The rotation of the node in degrees. - */ - virtual float getRotation() const; - - - /** - * Sets the X rotation (angle) of the node in degrees which performs a horizontal rotational skew. - * - * 0 is the default rotation angle. - * Positive values rotate node clockwise, and negative values for anti-clockwise. - * - * @param rotationX The X rotation in degrees which performs a horizontal rotational skew. - */ - virtual void setRotationX(float rotationX); - /** - * Gets the X rotation (angle) of the node in degrees which performs a horizontal rotation skew. - * - * @see setRotationX(float) - * - * @return The X rotation in degrees. - */ - virtual float getRotationX() const; - - - /** - * Sets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew. - * - * 0 is the default rotation angle. - * Positive values rotate node clockwise, and negative values for anti-clockwise. - * - * @param rotationY The Y rotation in degrees. - */ - virtual void setRotationY(float rotationY); - /** - * Gets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew. - * - * @see setRotationY(float) - * - * @return The Y rotation in degrees. - */ - virtual float getRotationY() const; - - - /** - * Sets the arrival order when this node has a same ZOrder with other children. - * - * A node which called addChild subsequently will take a larger arrival order, - * If two children have the same Z order, the child with larger arrival order will be drawn later. - * - * @warning This method is used internally for zOrder sorting, don't change this manually - * - * @param orderOfArrival The arrival order. - */ - virtual void setOrderOfArrival(int orderOfArrival); - /** - * Returns the arrival order, indecates which children is added previously. - * - * @see setOrderOfArrival(unsigned int) - * - * @return The arrival order. - */ - virtual int getOrderOfArrival() const; - - - /** @deprecated No longer needed - * @js NA - * @lua NA - */ - CC_DEPRECATED_ATTRIBUTE void setGLServerState(int serverState) { /* ignore */ }; - /** @deprecated No longer needed - * @js NA - * @lua NA - */ - CC_DEPRECATED_ATTRIBUTE int getGLServerState() const { return 0; } - - /** - * Sets whether the anchor point will be (0,0) when you position this node. - * - * This is an internal method, only used by Layer and Scene. Don't call it outside framework. - * The default value is false, while in Layer and Scene are true - * - * @param ignore true if anchor point will be (0,0) when you position this node - * @todo This method shoud be renamed as setIgnoreAnchorPointForPosition(bool) or something with "set" - */ - virtual void ignoreAnchorPointForPosition(bool ignore); - /** - * Gets whether the anchor point will be (0,0) when you position this node. - * - * @see ignoreAnchorPointForPosition(bool) - * - * @return true if the anchor point will be (0,0) when you position this node. - */ - virtual bool isIgnoreAnchorPointForPosition() const; - - /// @} end of Setters & Getters for Graphic Peroperties - - - /// @{ - /// @name Children and Parent - - /** - * Adds a child to the container with z-order as 0. - * - * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. - * - * @param child A child node - */ - virtual void addChild(Node * child); - /** - * Adds a child to the container with a z-order - * - * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. - * - * @param child A child node - * @param zOrder Z order for drawing priority. Please refer to setZOrder(int) - */ - virtual void addChild(Node * child, int zOrder); - /** - * Adds a child to the container with z order and tag - * - * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. - * - * @param child A child node - * @param zOrder Z order for drawing priority. Please refer to setZOrder(int) - * @param tag A interger to identify the node easily. Please refer to setTag(int) - */ - virtual void addChild(Node* child, int zOrder, int tag); - /** - * Gets a child from the container with its tag - * - * @param tag An identifier to find the child node. - * - * @return a Node object whose tag equals to the input parameter - */ - Node * getChildByTag(int tag); - /** - * Return an array of children - * - * Composing a "tree" structure is a very important feature of Node - * Here's a sample code of traversing children array: - * @code - * Node* node = NULL; - * CCARRAY_FOREACH(parent->getChildren(), node) - * { - * node->setPosition(0,0); - * } - * @endcode - * This sample code traverses all children nodes, and set their position to (0,0) - * - * @return An array of children - */ - virtual Array* getChildren() { return _children; } - virtual const Array *getChildren() const { return _children; } - - /** - * Get the amount of children. - * - * @return The amount of children. - */ - unsigned int getChildrenCount() const; - - /** - * Sets the parent node - * - * @param parent A pointer to the parnet node - */ - virtual void setParent(Node* parent); - /** - * Returns a pointer to the parent node - * - * @see setParent(Node*) - * - * @returns A pointer to the parnet node - */ - virtual Node* getParent() { return _parent; } - virtual const Node* getParent() const { return _parent; } - - - ////// REMOVES ////// - - /** - * Removes this node itself from its parent node with a cleanup. - * If the node orphan, then nothing happens. - * @see removeFromParentAndCleanup(bool) - */ - virtual void removeFromParent(); - /** - * Removes this node itself from its parent node. - * If the node orphan, then nothing happens. - * @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. - * @js removeFromParent - * @lua removeFromParent - */ - virtual void removeFromParentAndCleanup(bool cleanup); - - /** - * Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. - * - * @param child The child node which will be removed. - * @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. - */ - virtual void removeChild(Node* child, bool cleanup = true); - - /** - * Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter - * - * @param tag An interger number that identifies a child node - * @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. - */ - virtual void removeChildByTag(int tag, bool cleanup = true); - /** - * Removes all children from the container with a cleanup. - * - * @see removeAllChildrenWithCleanup(bool) - */ - virtual void removeAllChildren(); - /** - * Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter. - * - * @param cleanup true if all running actions on all children nodes should be cleanup, false oterwise. - * @js removeAllChildren - * @lua removeAllChildren - */ - virtual void removeAllChildrenWithCleanup(bool cleanup); - - /** - * Reorders a child according to a new z value. - * - * @param child An already added child node. It MUST be already added. - * @param zOrder Z order for drawing priority. Please refer to setZOrder(int) - */ - virtual void reorderChild(Node * child, int zOrder); - - /** - * Sorts the children array once before drawing, instead of every time when a child is added or reordered. - * This appraoch can improves the performance massively. - * @note Don't call this manually unless a child added needs to be removed in the same frame - */ - virtual void sortAllChildren(); - - /// @} end of Children and Parent - - - - /// @{ - /// @name Grid object for effects - - /** - * Returns a grid object that is used when applying effects - * - * @return A Grid object that is used when applying effects - * @js NA - */ - virtual GridBase* getGrid() { return _grid; } - /** - * @js NA - */ - virtual const GridBase* getGrid() const { return _grid; } - - /** - * Changes a grid object that is used when applying effects - * - * @param grid A Grid object that is used when applying effects - */ - virtual void setGrid(GridBase *grid); - - /// @} end of Grid - - - /// @{ - /// @name Tag & User data - - /** - * Returns a tag that is used to identify the node easily. - * - * You can set tags to node then identify them easily. - * @code - * #define TAG_PLAYER 1 - * #define TAG_MONSTER 2 - * #define TAG_BOSS 3 - * // set tags - * node1->setTag(TAG_PLAYER); - * node2->setTag(TAG_MONSTER); - * node3->setTag(TAG_BOSS); - * parent->addChild(node1); - * parent->addChild(node2); - * parent->addChild(node3); - * // identify by tags - * Node* node = NULL; - * CCARRAY_FOREACH(parent->getChildren(), node) - * { - * switch(node->getTag()) - * { - * case TAG_PLAYER: - * break; - * case TAG_MONSTER: - * break; - * case TAG_BOSS: - * break; - * } - * } - * @endcode - * - * @return A interger that identifies the node. - */ - virtual int getTag() const; - /** - * Changes the tag that is used to identify the node easily. - * - * Please refer to getTag for the sample code. - * - * @param tag A interger that indentifies the node. - */ - virtual void setTag(int tag); - - /** - * Returns a custom user data pointer - * - * You can set everything in UserData pointer, a data block, a structure or an object. - * - * @return A custom user data pointer - * @js NA - * @lua NA - */ - virtual void* getUserData() { return _userData; } - /** - * @js NA - * @lua NA - */ - virtual const void* getUserData() const { return _userData; } - - /** - * Sets a custom user data pointer - * - * You can set everything in UserData pointer, a data block, a structure or an object, etc. - * @warning Don't forget to release the memroy manually, - * especially before you change this data pointer, and before this node is autoreleased. - * - * @param userData A custom user data pointer - * @js NA - * @lua NA - */ - virtual void setUserData(void *userData); - - /** - * Returns a user assigned Object - * - * Similar to userData, but instead of holding a void* it holds an object - * - * @return A user assigned Object - * @js NA - * @lua NA - */ - virtual Object* getUserObject() { return _userObject; } - /** - * @js NA - * @lua NA - */ - virtual const Object* getUserObject() const { return _userObject; } - - /** - * Returns a user assigned Object - * - * Similar to UserData, but instead of holding a void* it holds an object. - * The UserObject will be retained once in this method, - * and the previous UserObject (if existed) will be relese. - * The UserObject will be released in Node's destructure. - * - * @param userObject A user assigned Object - */ - virtual void setUserObject(Object *userObject); - - /// @} end of Tag & User Data - - - /// @{ - /// @name Shader Program - /** - * Return the shader program currently used for this node - * - * @return The shader program currelty used for this node - */ - virtual GLProgram* getShaderProgram() { return _shaderProgram; } - virtual const GLProgram* getShaderProgram() const { return _shaderProgram; } - - /** - * Sets the shader program for this node - * - * Since v2.0, each rendering node must set its shader program. - * It should be set in initialize phase. - * @code - * node->setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); - * @endcode - * - * @param shaderProgram The shader program which fetchs from ShaderCache. - */ - virtual void setShaderProgram(GLProgram *shaderProgram); - /// @} end of Shader Program - - - /** - * Returns a camera object that lets you move the node using a gluLookAt - * - * @code - * Camera* camera = node->getCamera(); - * camera->setEye(0, 0, 415/2); - * camera->setCenter(0, 0, 0); - * @endcode - * - * @return A Camera object that lets you move the node using a gluLookAt - */ - virtual Camera* getCamera(); - - /** - * Returns whether or not the node accepts event callbacks. - * - * Running means the node accept event callbacks like onEnter(), onExit(), update() - * - * @return Whether or not the node is running. - */ - virtual bool isRunning() const; - - /** - * Schedules for lua script. - * @js NA - */ - void scheduleUpdateWithPriorityLua(int handler, int priority); - - /// @} end Script Bindings - - - /// @{ - /// @name Event Callbacks - - /** - * Event callback that is invoked every time when Node enters the 'stage'. - * If the Node enters the 'stage' with a transition, this event is called when the transition starts. - * During onEnter you can't access a "sister/brother" node. - * If you override onEnter, you shall call its parent's one, e.g., Node::onEnter(). - * @js NA - * @lua NA - */ - virtual void onEnter(); - - /** Event callback that is invoked when the Node enters in the 'stage'. - * If the Node enters the 'stage' with a transition, this event is called when the transition finishes. - * If you override onEnterTransitionDidFinish, you shall call its parent's one, e.g. Node::onEnterTransitionDidFinish() - * @js NA - * @lua NA - */ - virtual void onEnterTransitionDidFinish(); - - /** - * Event callback that is invoked every time the Node leaves the 'stage'. - * If the Node leaves the 'stage' with a transition, this event is called when the transition finishes. - * During onExit you can't access a sibling node. - * If you override onExit, you shall call its parent's one, e.g., Node::onExit(). - * @js NA - * @lua NA - */ - virtual void onExit(); - - /** - * Event callback that is called every time the Node leaves the 'stage'. - * If the Node leaves the 'stage' with a transition, this callback is called when the transition starts. - * @js NA - * @lua NA - */ - virtual void onExitTransitionDidStart(); - - /// @} end of event callbacks. - - - /** - * Stops all running actions and schedulers - */ - virtual void cleanup(); - - /** - * Override this method to draw your own node. - * The following GL states will be enabled by default: - * - glEnableClientState(GL_VERTEX_ARRAY); - * - glEnableClientState(GL_COLOR_ARRAY); - * - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - * - glEnable(GL_TEXTURE_2D); - * AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE - * But if you enable any other GL state, you should disable it after drawing your node. - */ - virtual void draw(); - - /** - * Visits this node's children and draw them recursively. - */ - virtual void visit(); - - - /** - * Returns a "local" axis aligned bounding box of the node. - * The returned box is relative only to its parent. - * - * @note This method returns a temporaty variable, so it can't returns const Rect& - * @todo Rename to getBoundingBox() in the future versions. - * - * @return A "local" axis aligned boudning box of the node. - */ - virtual Rect getBoundingBox() const; - - /** @deprecated Use getBoundingBox instead */ - CC_DEPRECATED_ATTRIBUTE inline virtual Rect boundingBox() const { return getBoundingBox(); } - - /// @{ - /// @name Actions - - /** - * Sets the ActionManager object that is used by all actions. - * - * @warning If you set a new ActionManager, then previously created actions will be removed. - * - * @param actionManager A ActionManager object that is used by all actions. - */ - virtual void setActionManager(ActionManager* actionManager); - /** - * Gets the ActionManager object that is used by all actions. - * @see setActionManager(ActionManager*) - * @return A ActionManager object. - */ - virtual ActionManager* getActionManager() { return _actionManager; } - virtual const ActionManager* getActionManager() const { return _actionManager; } - - /** - * Executes an action, and returns the action that is executed. - * - * This node becomes the action's target. Refer to Action::getTarget() - * @warning Actions don't retain their target. - * - * @return An Action pointer - */ - Action* runAction(Action* action); - - /** - * Stops and removes all actions from the running action list . - */ - void stopAllActions(); - - /** - * Stops and removes an action from the running action list. - * - * @param action The action object to be removed. - */ - void stopAction(Action* action); - - /** - * Removes an action from the running action list by its tag. - * - * @param tag A tag that indicates the action to be removed. - */ - void stopActionByTag(int tag); - - /** - * Gets an action from the running action list by its tag. - * - * @see setTag(int), getTag(). - * - * @return The action object with the given tag. - */ - Action* getActionByTag(int tag); - - /** - * Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays). - * - * Composable actions are counted as 1 action. Example: - * If you are running 1 Sequence of 7 actions, it will return 1. - * If you are running 7 Sequences of 2 actions, it will return 7. - * @todo Rename to getNumberOfRunningActions() - * - * @return The number of actions that are running plus the ones that are schedule to run - */ - unsigned int getNumberOfRunningActions() const; - - /** @deprecated Use getNumberOfRunningActions() instead */ - CC_DEPRECATED_ATTRIBUTE unsigned int numberOfRunningActions() const { return getNumberOfRunningActions(); }; - - /// @} end of Actions - - - /// @{ - /// @name Scheduler and Timer - - /** - * Sets a Scheduler object that is used to schedule all "updates" and timers. - * - * @warning If you set a new Scheduler, then previously created timers/update are going to be removed. - * @param scheduler A Shdeduler object that is used to schedule all "update" and timers. - */ - virtual void setScheduler(Scheduler* scheduler); - /** - * Gets a Sheduler object. - * - * @see setScheduler(Scheduler*) - * @return A Scheduler object. - */ - virtual Scheduler* getScheduler() { return _scheduler; } - virtual const Scheduler* getScheduler() const { return _scheduler; } - - - /** - * Checks whether a selector is scheduled. - * - * @param selector A function selector - * @return Whether the funcion selector is scheduled. - * @js NA - * @lua NA - */ - bool isScheduled(SEL_SCHEDULE selector); - - /** - * Schedules the "update" method. - * - * It will use the order number 0. This method will be called every frame. - * Scheduled methods with a lower order value will be called before the ones that have a higher order value. - * Only one "update" method could be scheduled per node. - * @js NA - * @lua NA - */ - void scheduleUpdate(void); - - /** - * Schedules the "update" method with a custom priority. - * - * This selector will be called every frame. - * Scheduled methods with a lower priority will be called before the ones that have a higher value. - * Only one "update" selector could be scheduled per node (You can't have 2 'update' selectors). - * @js NA - * @lua NA - */ - void scheduleUpdateWithPriority(int priority); - - /* - * Unschedules the "update" method. - * @see scheduleUpdate(); - */ - void unscheduleUpdate(void); - - /** - * Schedules a custom selector. - * - * If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. - * @code - * // firstly, implement a schedule function - * void MyNode::TickMe(float dt); - * // wrap this function into a selector via schedule_selector marco. - * this->schedule(schedule_selector(MyNode::TickMe), 0, 0, 0); - * @endcode - * - * @param selector The SEL_SCHEDULE selector to be scheduled. - * @param interval Tick interval in seconds. 0 means tick every frame. If interval = 0, it's recommended to use scheduleUpdate() instead. - * @param repeat The selector will be excuted (repeat + 1) times, you can use kRepeatForever for tick infinitely. - * @param delay The amount of time that the first tick will wait before execution. - * @lua NA - */ - void schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay); - - /** - * Schedules a custom selector with an interval time in seconds. - * @see schedule(SEL_SCHEDULE, float, unsigned int, float) - * - * @param selector The SEL_SCHEDULE selector to be scheduled. - * @param interval Callback interval time in seconds. 0 means tick every frame, - * @lua NA - */ - void schedule(SEL_SCHEDULE selector, float interval); - - /** - * Schedules a selector that runs only once, with a delay of 0 or larger - * @see schedule(SEL_SCHEDULE, float, unsigned int, float) - * - * @param selector The SEL_SCHEDULE selector to be scheduled. - * @param delay The amount of time that the first tick will wait before execution. - * @lua NA - */ - void scheduleOnce(SEL_SCHEDULE selector, float delay); - - /** - * Schedules a custom selector, the scheduled selector will be ticked every frame - * @see schedule(SEL_SCHEDULE, float, unsigned int, float) - * - * @param selector A function wrapped as a selector - * @lua NA - */ - void schedule(SEL_SCHEDULE selector); - - /** - * Unschedules a custom selector. - * @see schedule(SEL_SCHEDULE, float, unsigned int, float) - * - * @param selector A function wrapped as a selector - * @lua NA - */ - void unschedule(SEL_SCHEDULE selector); - - /** - * Unschedule all scheduled selectors: custom selectors, and the 'update' selector. - * Actions are not affected by this method. - * @lua NA - */ - void unscheduleAllSelectors(void); - - /** - * Resumes all scheduled selectors and actions. - * This method is called internally by onEnter - */ - void resumeSchedulerAndActions(void); - /** - * Pauses all scheduled selectors and actions. - * This method is called internally by onExit - */ - void pauseSchedulerAndActions(void); - - /* - * Update method will be called automatically every frame if "scheduleUpdate" is called, and the node is "live" - */ - virtual void update(float delta); - - /// @} end of Scheduler and Timer - - /// @{ - /// @name Transformations - - /** - * Performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes. - */ - void transform(); - /** - * Performs OpenGL view-matrix transformation of it's ancestors. - * Generally the ancestors are already transformed, but in certain cases (eg: attaching a FBO) - * It's necessary to transform the ancestors again. - */ - void transformAncestors(); - /** - * Calls children's updateTransform() method recursively. - * - * This method is moved from Sprite, so it's no longer specific to Sprite. - * As the result, you apply SpriteBatchNode's optimization on your customed Node. - * e.g., batchNode->addChild(myCustomNode), while you can only addChild(sprite) before. - */ - virtual void updateTransform(); - - /** - * Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates. - * The matrix is in Pixels. - */ - virtual const AffineTransform& getNodeToParentTransform() const; - - /** @deprecated use getNodeToParentTransform() instead */ - CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform nodeToParentTransform() const { return getNodeToParentTransform(); } - - /** - * Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates. - * The matrix is in Pixels. - */ - virtual const AffineTransform& getParentToNodeTransform() const; - - /** @deprecated Use getParentToNodeTransform() instead */ - CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform parentToNodeTransform() const { return getParentToNodeTransform(); } - - /** - * Returns the world affine transform matrix. The matrix is in Pixels. - */ - virtual AffineTransform getNodeToWorldTransform() const; - - /** @deprecated Use getNodeToWorldTransform() instead */ - CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform nodeToWorldTransform() const { return getNodeToWorldTransform(); } - - /** - * Returns the inverse world affine transform matrix. The matrix is in Pixels. - */ - virtual AffineTransform getWorldToNodeTransform() const; - - /** @deprecated Use worldToNodeTransform() instead */ - CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform worldToNodeTransform() const { return getWorldToNodeTransform(); } - - /// @} end of Transformations - - - /// @{ - /// @name Coordinate Converters - - /** - * Converts a Point to node (local) space coordinates. The result is in Points. - */ - Point convertToNodeSpace(const Point& worldPoint) const; - - /** - * Converts a Point to world space coordinates. The result is in Points. - */ - Point convertToWorldSpace(const Point& nodePoint) const; - - /** - * Converts a Point to node (local) space coordinates. The result is in Points. - * treating the returned/received node point as anchor relative. - */ - Point convertToNodeSpaceAR(const Point& worldPoint) const; - - /** - * Converts a local Point to world space coordinates.The result is in Points. - * treating the returned/received node point as anchor relative. - */ - Point convertToWorldSpaceAR(const Point& nodePoint) const; - - /** - * convenience methods which take a Touch instead of Point - */ - Point convertTouchToNodeSpace(Touch * touch) const; - - /** - * converts a Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). - */ - Point convertTouchToNodeSpaceAR(Touch * touch) const; - - /** - * Sets the additional transform. - * - * @note The additional transform will be concatenated at the end of getNodeToParentTransform. - * It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't). - * @code - // create a batchNode - SpriteBatchNode* batch= SpriteBatchNode::create("Icon-114.png"); - this->addChild(batch); - - // create two sprites, spriteA will be added to batchNode, they are using different textures. - Sprite* spriteA = Sprite::createWithTexture(batch->getTexture()); - Sprite* spriteB = Sprite::create("Icon-72.png"); - - batch->addChild(spriteA); - - // We can't make spriteB as spriteA's child since they use different textures. So just add it to layer. - // But we want to simulate `parent-child` relationship for these two node. - this->addChild(spriteB); - - //position - spriteA->setPosition(Point(200, 200)); - - // Gets the spriteA's transform. - AffineTransform t = spriteA->getNodeToParentTransform(); - - // Sets the additional transform to spriteB, spriteB's postion will based on its pseudo parent i.e. spriteA. - spriteB->setAdditionalTransform(t); - - //scale - spriteA->setScale(2); - - // Gets the spriteA's transform. - t = spriteA->getNodeToParentTransform(); - - // Sets the additional transform to spriteB, spriteB's scale will based on its pseudo parent i.e. spriteA. - spriteB->setAdditionalTransform(t); - - //rotation - spriteA->setRotation(20); - - // Gets the spriteA's transform. - t = spriteA->getNodeToParentTransform(); - - // Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA. - spriteB->setAdditionalTransform(t); - * @endcode - */ - void setAdditionalTransform(const AffineTransform& additionalTransform); - - /// @} end of Coordinate Converters - - /// @{ - /// @name component functions - /** - * gets a component by its name - */ - Component* getComponent(const char *pName); - - /** - * adds a component - */ - virtual bool addComponent(Component *pComponent); - - /** - * removes a component by its name - */ - virtual bool removeComponent(const char *pName); - - /** - * removes all components - */ - virtual void removeAllComponents(); - /// @} end of component functions - - -#ifdef CC_USE_PHYSICS - /** - * set the PhysicsBody that let the sprite effect with physics - */ - void setPhysicsBody(PhysicsBody* body); - - /** - * get the PhysicsBody the sprite have - */ - PhysicsBody* getPhysicsBody() const; - - /** - * update rotation and position from physics body - */ - virtual void updatePhysicsTransform(); -#endif - - -private: - friend class Director; - friend class EventDispatcher; - - int getEventPriority() const { return _eventPriority; }; - - void associateEventListener(EventListener* listener); - void dissociateEventListener(EventListener* listener); - - static void resetEventPriorityIndex(); - std::set _eventlisteners; - -protected: - - /// Upates event priority for this node. - inline void updateEventPriorityIndex() { - _oldEventPriority = _eventPriority; - _eventPriority = ++_globalEventPriorityIndex; - if (_oldEventPriority != _eventPriority) - { - setDirtyForAllEventListeners(); - } - }; - - /// Removes all event listeners that associated with this node. - void removeAllEventListeners(); - - /// Sets dirty for event listener. - void setDirtyForAllEventListeners(); - - /// lazy allocs - void childrenAlloc(void); - - /// helper that reorder a child - void insertChild(Node* child, int z); - - /// Removes a child, call child->onExit(), do cleanup, remove it from children array. - void detachChild(Node *child, int index, bool doCleanup); - - /// Convert cocos2d coordinates to UI windows coordinate. - Point convertToWindowSpace(const Point& nodePoint) const; - - - float _rotationX; ///< rotation angle on x-axis - float _rotationY; ///< rotation angle on y-axis - - float _scaleX; ///< scaling factor on x-axis - float _scaleY; ///< scaling factor on y-axis - - float _vertexZ; ///< OpenGL real Z vertex - - Point _position; ///< position of the node - - float _skewX; ///< skew angle on x-axis - float _skewY; ///< skew angle on y-axis - - Point _anchorPointInPoints; ///< anchor point in points - Point _anchorPoint; ///< anchor point normalized (NOT in points) - - Size _contentSize; ///< untransformed size of the node - - // "cache" variables are allowed to be mutable - mutable AffineTransform _additionalTransform; ///< transform - mutable AffineTransform _transform; ///< transform - mutable AffineTransform _inverse; ///< inverse transform - mutable bool _additionalTransformDirty; ///< The flag to check whether the additional transform is dirty - mutable bool _transformDirty; ///< transform dirty flag - mutable bool _inverseDirty; ///< inverse transform dirty flag - - Camera *_camera; ///< a camera - - GridBase *_grid; ///< a grid - - int _ZOrder; ///< z-order value that affects the draw order - - Array *_children; ///< array of children nodes - Node *_parent; ///< weak reference to parent node - - int _tag; ///< a tag. Can be any number you assigned just to identify this node - - void *_userData; ///< A user assingned void pointer, Can be point to any cpp object - Object *_userObject; ///< A user assigned Object - - GLProgram *_shaderProgram; ///< OpenGL shader - - int _orderOfArrival; ///< used to preserve sequence while sorting children with the same zOrder - - Scheduler *_scheduler; ///< scheduler used to schedule timers and updates - - ActionManager *_actionManager; ///< a pointer to ActionManager singleton, which is used to handle all the actions - - bool _running; ///< is running - - bool _visible; ///< is this node visible - - bool _ignoreAnchorPointForPosition; ///< true if the Anchor Point will be (0,0) when you position the Node, false otherwise. - ///< Used by Layer and Scene. - - bool _reorderChildDirty; ///< children order dirty flag - bool _isTransitionFinished; ///< flag to indicate whether the transition was finished - - int _scriptHandler; ///< script handler for onEnter() & onExit(), used in Javascript binding and Lua binding. - int _updateScriptHandler; ///< script handler for update() callback per frame, which is invoked from lua & javascript. - ccScriptType _scriptType; ///< type of script binding, lua or javascript - - ComponentContainer *_componentContainer; ///< Dictionary of components - - int _eventPriority; ///< The scene graph based priority of event listener. - int _oldEventPriority; ///< The old scene graph based priority of event listener. - static int _globalEventPriorityIndex; ///< The index of global event priority. - -#ifdef CC_USE_PHYSICS - PhysicsBody* _physicsBody; ///< the physicsBody the node have -#endif -}; - -//#pragma mark - NodeRGBA - -/** NodeRGBA is a subclass of Node that implements the RGBAProtocol protocol. - - All features from Node are valid, plus the following new features: - - opacity - - RGB colors - - Opacity/Color propagates into children that conform to the RGBAProtocol if cascadeOpacity/cascadeColor is enabled. - @since v2.1 - */ -class CC_DLL NodeRGBA : public Node, public RGBAProtocol -{ -public: - /** - * @js ctor - */ - NodeRGBA(); - /** - * @js NA - * @lua NA - */ - virtual ~NodeRGBA(); - - virtual bool init(); - - // overrides - virtual GLubyte getOpacity() const override; - virtual GLubyte getDisplayedOpacity() const override; - virtual void setOpacity(GLubyte opacity) override; - virtual void updateDisplayedOpacity(GLubyte parentOpacity) override; - virtual bool isCascadeOpacityEnabled() const override; - virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override; - - virtual const Color3B& getColor(void) const override; - virtual const Color3B& getDisplayedColor() const override; - virtual void setColor(const Color3B& color) override; - virtual void updateDisplayedColor(const Color3B& parentColor) override; - virtual bool isCascadeColorEnabled() const override; - virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override; - - virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);}; - virtual bool isOpacityModifyRGB() const override { return false; }; - -protected: - GLubyte _displayedOpacity; - GLubyte _realOpacity; - Color3B _displayedColor; - Color3B _realColor; - bool _cascadeColorEnabled; - bool _cascadeOpacityEnabled; -}; - -// end of base_node group -/// @} - -NS_CC_END - -#endif // __PLATFORM_CCNODE_H__ diff --git a/cocos2dx/cocoa/CCGeometry.h b/cocos2dx/cocoa/CCGeometry.h deleted file mode 100644 index 94bbf3fb10..0000000000 --- a/cocos2dx/cocoa/CCGeometry.h +++ /dev/null @@ -1,584 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __CCGEMETRY_H__ -#define __CCGEMETRY_H__ - -#include -#include - -#include "platform/CCPlatformMacros.h" -#include "CCObject.h" -#include "ccMacros.h" - -NS_CC_BEGIN - -/** Clamp a value between from and to. - @since v0.99.1 - */ -inline float clampf(float value, float min_inclusive, float max_inclusive) -{ - if (min_inclusive > max_inclusive) { - CC_SWAP(min_inclusive, max_inclusive, float); - } - return value < min_inclusive ? min_inclusive : value < max_inclusive? value : max_inclusive; -} - -/** - * @addtogroup data_structures - * @{ - */ - -// for Point assignement operator and copy constructor -class CC_DLL Size; - -class CC_DLL Point -{ -public: - float x; - float y; - -public: - /** - * @js NA - */ - Point(); - /** - * @js NA - */ - Point(float x, float y); - /** - * @js NA - * @lua NA - */ - Point(const Point& other); - /** - * @js NA - * @lua NA - */ - explicit Point(const Size& size); - /** - * @js NA - * @lua NA - */ - Point& operator= (const Point& other); - /** - * @js NA - * @lua NA - */ - Point& operator= (const Size& size); - /** - * @js NA - * @lua NA - */ - Point operator+(const Point& right) const; - /** - * @js NA - * @lua NA - */ - Point& operator+=(const Point& right); - /** - * @js NA - * @lua NA - */ - Point operator-(const Point& right) const; - /** - * @js NA - * @lua NA - */ - Point& operator-=(const Point& right); - /** - * @js NA - * @lua NA - */ - Point operator-() const; - /** - * @js NA - * @lua NA - */ - bool operator==(const Point& right); - /** - * @js NA - * @lua NA - */ - bool operator!=(const Point& right); - /** - * @js NA - * @lua NA - */ - Point operator*(float a) const; - /** - * @js NA - * @lua NA - */ - Point operator/(float a) const; - /** - * @js NA - * @lua NA - */ - void setPoint(float x, float y); - /** - * @js NA - */ - bool equals(const Point& target) const; - - /** @returns if points have fuzzy equality which means equal with some degree of variance. - @since v2.1.4 - * @js NA - * @lua NA - */ - bool fuzzyEquals(const Point& target, float variance) const; - - /** Calculates distance between point an origin - @return float - @since v2.1.4 - * @js NA - * @lua NA - */ - inline float getLength() const { - return sqrtf(x*x + y*y); - }; - - /** Calculates the square length of a Point (not calling sqrt() ) - @return float - @since v2.1.4 - * @js NA - * @lua NA - */ - inline float getLengthSq() const { - return dot(*this); //x*x + y*y; - }; - - /** Calculates the square distance between two points (not calling sqrt() ) - @return float - @since v2.1.4 - * @js NA - * @lua NA - */ - inline float getDistanceSq(const Point& other) const { - return (*this - other).getLengthSq(); - }; - - /** Calculates the distance between two points - @return float - @since v2.1.4 - * @js NA - * @lua NA - */ - inline float getDistance(const Point& other) const { - return (*this - other).getLength(); - }; - - /** @returns the angle in radians between this vector and the x axis - @since v2.1.4 - * @js NA - * @lua NA - */ - inline float getAngle() const { - return atan2f(y, x); - }; - - /** @returns the angle in radians between two vector directions - @since v2.1.4 - * @js NA - * @lua NA - */ - float getAngle(const Point& other) const; - - /** Calculates dot product of two points. - @return float - @since v2.1.4 - * @js NA - * @lua NA - */ - inline float dot(const Point& other) const { - return x*other.x + y*other.y; - }; - - /** Calculates cross product of two points. - @return float - @since v2.1.4 - * @js NA - * @lua NA - */ - inline float cross(const Point& other) const { - return x*other.y - y*other.x; - }; - - /** Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) >= 0 - @return Point - @since v2.1.4 - * @js NA - * @lua NA - */ - inline Point getPerp() const { - return Point(-y, x); - }; - - /** Calculates midpoint between two points. - @return Point - @since v3.0 - * @js NA - * @lua NA - */ - inline Point getMidpoint(const Point& other) const - { - return Point((x + other.x) / 2.0f, (y + other.y) / 2.0f); - } - - /** Clamp a point between from and to. - @since v3.0 - * @js NA - * @lua NA - */ - inline Point getClampPoint(const Point& min_inclusive, const Point& max_inclusive) const - { - return Point(clampf(x,min_inclusive.x,max_inclusive.x), clampf(y, min_inclusive.y, max_inclusive.y)); - } - - /** Run a math operation function on each point component - * absf, fllorf, ceilf, roundf - * any function that has the signature: float func(float); - * For example: let's try to take the floor of x,y - * p.compOp(floorf); - @since v3.0 - * @js NA - * @lua NA - */ - inline Point compOp(std::function function) const - { - return Point(function(x), function(y)); - } - - /** Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) <= 0 - @return Point - @since v2.1.4 - * @js NA - * @lua NA - */ - inline Point getRPerp() const { - return Point(y, -x); - }; - - /** Calculates the projection of this over other. - @return Point - @since v2.1.4 - * @js NA - * @lua NA - */ - inline Point project(const Point& other) const { - return other * (dot(other)/other.dot(other)); - }; - - /** Complex multiplication of two points ("rotates" two points). - @return Point vector with an angle of this.getAngle() + other.getAngle(), - and a length of this.getLength() * other.getLength(). - @since v2.1.4 - * @js NA - * @lua NA - */ - inline Point rotate(const Point& other) const { - return Point(x*other.x - y*other.y, x*other.y + y*other.x); - }; - - /** Unrotates two points. - @return Point vector with an angle of this.getAngle() - other.getAngle(), - and a length of this.getLength() * other.getLength(). - @since v2.1.4 - * @js NA - * @lua NA - */ - inline Point unrotate(const Point& other) const { - return Point(x*other.x + y*other.y, y*other.x - x*other.y); - }; - - /** Returns point multiplied to a length of 1. - * If the point is 0, it returns (1, 0) - @return Point - @since v2.1.4 - * @js NA - * @lua NA - */ - inline Point normalize() const { - float length = getLength(); - if(length == 0.) return Point(1.f, 0); - return *this / getLength(); - }; - - /** Linear Interpolation between two points a and b - @returns - alpha == 0 ? a - alpha == 1 ? b - otherwise a value between a..b - @since v2.1.4 - * @js NA - * @lua NA - */ - inline Point lerp(const Point& other, float alpha) const { - return *this * (1.f - alpha) + other * alpha; - }; - - /** Rotates a point counter clockwise by the angle around a pivot - @param pivot is the pivot, naturally - @param angle is the angle of rotation ccw in radians - @returns the rotated point - @since v2.1.4 - * @js NA - * @lua NA - */ - Point rotateByAngle(const Point& pivot, float angle) const; - - /** - * @js NA - * @lua NA - */ - static inline Point forAngle(const float a) - { - return Point(cosf(a), sinf(a)); - } - - /** A general line-line intersection test - @param A the startpoint for the first line L1 = (A - B) - @param B the endpoint for the first line L1 = (A - B) - @param C the startpoint for the second line L2 = (C - D) - @param D the endpoint for the second line L2 = (C - D) - @param S the range for a hitpoint in L1 (p = A + S*(B - A)) - @param T the range for a hitpoint in L2 (p = C + T*(D - C)) - @returns whether these two lines interects. - - Note that to truly test intersection for segments we have to make - sure that S & T lie within [0..1] and for rays, make sure S & T > 0 - the hit point is C + T * (D - C); - the hit point also is A + S * (B - A); - @since 3.0 - * @js NA - * @lua NA - */ - static bool isLineIntersect(const Point& A, const Point& B, - const Point& C, const Point& D, - float *S = nullptr, float *T = nullptr); - - /** - returns true if Line A-B overlap with segment C-D - @since v3.0 - * @js NA - * @lua NA - */ - static bool isLineOverlap(const Point& A, const Point& B, - const Point& C, const Point& D); - - /** - returns true if Line A-B parallel with segment C-D - @since v3.0 - * @js NA - * @lua NA - */ - static bool isLineParallel(const Point& A, const Point& B, - const Point& C, const Point& D); - - /** - returns true if Segment A-B overlap with segment C-D - @since v3.0 - * @js NA - * @lua NA - */ - static bool isSegmentOverlap(const Point& A, const Point& B, - const Point& C, const Point& D, - Point* S = nullptr, Point* E = nullptr); - - /** - returns true if Segment A-B intersects with segment C-D - @since v3.0 - * @js NA - * @lua NA - */ - static bool isSegmentIntersect(const Point& A, const Point& B, const Point& C, const Point& D); - - /** - returns the intersection point of line A-B, C-D - @since v3.0 - * @js NA - * @lua NA - */ - static Point getIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D); - - static const Point ZERO; - -private: - // returns true if segment A-B intersects with segment C-D. S->E is the ovderlap part - static bool isOneDemensionSegmentOverlap(float A, float B, float C, float D, float *S, float * E); - - // cross procuct of 2 vector. A->B X C->D - static float crossProduct2Vector(const Point& A, const Point& B, const Point& C, const Point& D) { return (D.y - C.y) * (B.x - A.x) - (D.x - C.x) * (B.y - A.y); } -}; - -class CC_DLL Size -{ -public: - float width; - float height; - -public: - /** - * @js NA - */ - Size(); - /** - * @js NA - */ - Size(float width, float height); - /** - * @js NA - * @lua NA - */ - Size(const Size& other); - /** - * @js NA - * @lua NA - */ - explicit Size(const Point& point); - /** - * @js NA - * @lua NA - */ - Size& operator= (const Size& other); - /** - * @js NA - * @lua NA - */ - Size& operator= (const Point& point); - /** - * @js NA - * @lua NA - */ - Size operator+(const Size& right) const; - /** - * @js NA - * @lua NA - */ - Size operator-(const Size& right) const; - /** - * @js NA - * @lua NA - */ - Size operator*(float a) const; - /** - * @js NA - * @lua NA - */ - Size operator/(float a) const; - /** - * @js NA - * @lua NA - */ - void setSize(float width, float height); - /** - * @js NA - */ - bool equals(const Size& target) const; - - static const Size ZERO; -}; - -class CC_DLL Rect -{ -public: - Point origin; - Size size; - -public: - /** - * @js NA - */ - Rect(); - /** - * @js NA - */ - Rect(float x, float y, float width, float height); - /** - * @js NA - * @lua NA - */ - Rect(const Rect& other); - /** - * @js NA - * @lua NA - */ - Rect& operator= (const Rect& other); - /** - * @js NA - * @lua NA - */ - void setRect(float x, float y, float width, float height); - /** - * @js NA - */ - float getMinX() const; /// return the leftmost x-value of current rect - /** - * @js NA - */ - float getMidX() const; /// return the midpoint x-value of current rect - /** - * @js NA - */ - float getMaxX() const; /// return the rightmost x-value of current rect - /** - * @js NA - */ - float getMinY() const; /// return the bottommost y-value of current rect - /** - * @js NA - */ - float getMidY() const; /// return the midpoint y-value of current rect - /** - * @js NA - */ - float getMaxY() const; /// return the topmost y-value of current rect - /** - * @js NA - */ - bool equals(const Rect& rect) const; - /** - * @js NA - */ - bool containsPoint(const Point& point) const; - /** - * @js NA - */ - bool intersectsRect(const Rect& rect) const; - /** - * @js NA - * @lua NA - */ - Rect unionWithRect(const Rect & rect) const; - - static const Rect ZERO; -}; - -// end of data_structure group -/// @} - -NS_CC_END - -#endif // __CCGEMETRY_H__ diff --git a/cocos2dx/physics/CCPhysicsBody.h b/cocos2dx/physics/CCPhysicsBody.h deleted file mode 100644 index 869c7be1da..0000000000 --- a/cocos2dx/physics/CCPhysicsBody.h +++ /dev/null @@ -1,292 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsSetting.h" -#ifdef CC_USE_PHYSICS - -#ifndef __CCPHYSICS_BODY_H__ -#define __CCPHYSICS_BODY_H__ - -#include "cocoa/CCObject.h" -#include "cocoa/CCGeometry.h" - -#include "CCPhysicsShape.h" - -#include - -NS_CC_BEGIN -class Sprite; -class PhysicsWorld; -class PhysicsJoint; - -class PhysicsBodyInfo; - - -const PhysicsMaterial PHYSICSBODY_MATERIAL_DEFAULT = {0.0f, 1.0f, 1.0f}; - -/** - * A body affect by physics. - * it can attach one or more shapes. - */ -class PhysicsBody : public Object//, public Clonable -{ -public: - static PhysicsBody* create(); - /** - * @brief Create a body contains a circle shape. - */ - static PhysicsBody* createCircle(float radius, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT); - /** - * @brief Create a body contains a box shape. - */ - static PhysicsBody* createBox(Size size, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT); - /** - * @brief Create a body contains a polygon shape. - * points is an array of Point structs defining a convex hull with a clockwise winding. - */ - static PhysicsBody* createPolygon(Point* points, int count, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT); - - /** - * @brief Create a body contains a EdgeSegment shape. - */ - static PhysicsBody* createEdgeSegment(Point a, Point b, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1); - /** - * @brief Create a body contains a EdgeBox shape. - */ - static PhysicsBody* createEdgeBox(Size size, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1); - /** - * @brief Create a body contains a EdgePolygon shape. - */ - static PhysicsBody* createEdgePolygon(Point* points, int count, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1); - /** - * @brief Create a body contains a EdgeChain shape. - */ - static PhysicsBody* createEdgeChain(Point* points, int count, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1); - - virtual void addShape(PhysicsShape* shape); - - /** - * @brief Applies a immediate force to body. - */ - virtual void applyForce(Point force); - /** - * @brief Applies a immediate force to body. - */ - virtual void applyForce(Point force, Point offset); - /** - * @brief Applies a continuous force to body. - */ - virtual void applyImpulse(Point impulse); - /** - * @brief Applies a continuous force to body. - */ - virtual void applyImpulse(Point impulse, Point offset); - /** - * @brief Applies a torque force to body. - */ - virtual void applyTorque(float torque); - - virtual void setVelocity(Point velocity); - virtual Point getVelocity(); - virtual void setAngularVelocity(float velocity); - virtual float getAngularVelocity(); - virtual void setVelocityLimit(float limit); - virtual float getVelocityLimit(); - virtual void setAngularVelocityLimit(float limit); - virtual float getAngularVelocityLimit(); - - /* - * @brief get the body shapes. - */ - inline std::vector& getShapes() { return _shapes; } - /* - * @brief get the first body shapes. - */ - inline PhysicsShape* getShape() { return _shapes.size() >= 1 ? _shapes.front() : nullptr; } - PhysicsShape* getShapeByTag(int tag); - /* - * @brief remove a shape from body - */ - void removeShape(PhysicsShape* shape); - void removeShapeByTag(int tag); - /* - * @brief remove all shapes - */ - void removeAllShapes(); - - /* - * @brief get the world body added to. - */ - inline PhysicsWorld* getWorld() const { return _world; } - /* - * @brief get all joints the body have - */ - inline const std::vector* getJoints() const { return &_joints; } - - /* - * @brief get the sprite the body set to. - */ - inline Sprite* getOwner() const { return _owner; } - - inline void setCategoryBitmask(int bitmask) { _categoryBitmask = bitmask; } - inline int getCategoryBitmask() const { return _categoryBitmask; } - inline void setContactTestBitmask(int bitmask) { _contactTestBitmask = bitmask; } - inline int getContactTestBitmask() const { return _contactTestBitmask; } - inline void setCollisionBitmask(int bitmask) { _collisionBitmask = bitmask; } - inline int getCollisionBitmask() const { return _collisionBitmask; } - - /* - * @brief get the body position. - */ - Point getPosition() const; - /* - * @brief get the body rotation. - */ - float getRotation() const; - - /* - * @brief test the body is dynamic or not. - * a dynamic body will effect with gravity. - */ - inline bool isDynamic() { return _dynamic; } - /* - * @brief set dynamic to body. - * a dynamic body will effect with gravity. - */ - void setDynamic(bool dynamic); - - /* - * @brief set the body mass. - * @note if you need add/subtract mass to body, don't use setMass(getMass() +/- mass), because the mass of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMass() instead. - */ - void setMass(float mass); - /* - * @brief get the body mass. - */ - inline float getMass() { return _mass; } - /* - * @brief add mass to body. - * if _mass(mass of the body) == PHYSICS_INFINITY, it remains. - * if mass == PHYSICS_INFINITY, _mass will be PHYSICS_INFINITY. - * if mass == -PHYSICS_INFINITY, _mass will not change. - * if mass + _mass <= 0, _mass will equal to MASS_DEFAULT(1.0) - * other wise, mass = mass + _mass; - */ - void addMass(float mass); - - /* - * @brief set the body moment of inertia. - * @note if you need add/subtract moment to body, don't use setMoment(getMoment() +/- moment), because the moment of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMoment() instead. - */ - void setMoment(float moment); - /* - * @brief get the body moment of inertia. - */ - inline float getMoment(float moment) { return _moment; } - /* - * @brief add moment of inertia to body. - * if _moment(moment of the body) == PHYSICS_INFINITY, it remains. - * if moment == PHYSICS_INFINITY, _moment will be PHYSICS_INFINITY. - * if moment == -PHYSICS_INFINITY, _moment will not change. - * if moment + _moment <= 0, _moment will equal to MASS_DEFAULT(1.0) - * other wise, moment = moment + _moment; - */ - void addMoment(float moment); - /* - * @brief set angular damping. - */ - //void setAngularDamping(float angularDamping); - /* - * @brief get angular damping. - */ - inline float getLinearDamping() { return _linearDamping; } - inline void setLinearDamping(float damping) { _linearDamping = damping; } - inline float getAngularDamping() { return _angularDamping; } - inline void setAngularDamping(float damping) { _angularDamping = damping; } - - //virtual Clonable* clone() const override; - - bool isResting(); - inline bool isEnable() { return _enable; } - void setEnable(bool enable); - - inline bool isRotationEnable() { return _rotationEnable; } - void setRotationEnable(bool enable); - - inline bool isGravityEnable() { return _gravityEnable; } - void setGravityEnable(bool enable); - - - inline int getTag() { return _tag; } - inline void setTag(int tag) { _tag = tag; } - - -protected: - - bool init(); - - virtual void setPosition(Point position); - virtual void setRotation(float rotation); - - virtual void update(float delta) override; - -protected: - PhysicsBody(); - virtual ~PhysicsBody(); - -protected: - Sprite* _owner; - std::vector _joints; - std::vector _shapes; - PhysicsWorld* _world; - PhysicsBodyInfo* _info; - bool _dynamic; - bool _enable; - bool _rotationEnable; - bool _gravityEnable; - bool _massDefault; - bool _momentDefault; - float _mass; - float _area; - float _density; - float _moment; - float _linearDamping; - float _angularDamping; - int _tag; - - int _categoryBitmask; - int _contactTestBitmask; - int _collisionBitmask; - - friend class PhysicsWorld; - friend class PhysicsShape; - friend class PhysicsJoint; - friend class Node; -}; - -NS_CC_END - -#endif // __CCPHYSICS_BODY_H__ - -#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/CCPhysicsContact.h b/cocos2dx/physics/CCPhysicsContact.h deleted file mode 100644 index df31ae7be3..0000000000 --- a/cocos2dx/physics/CCPhysicsContact.h +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsSetting.h" -#ifdef CC_USE_PHYSICS - -#ifndef __CCPHYSICS_CONTACT_H__ -#define __CCPHYSICS_CONTACT_H__ - -#include "cocoa/CCObject.h" -#include "cocoa/CCGeometry.h" - -NS_CC_BEGIN - -class PhysicsShape; -class PhysicsWorld; - -class PhysicsContactInfo; - -/** - * @brief Contact infomation. it will created automatically when two shape contact with each other. and it will destoried automatically when two shape separated. - */ -class PhysicsContact -{ -public: - /* - * @brief get contact shape A. - */ - inline PhysicsShape* getShapeA() const { return _shapeA; } - /* - * @brief get contact shape B. - */ - inline PhysicsShape* getShapeB() const { return _shapeB; } - /* - * @brief get data. - */ - inline void* getData() { return _data; } - /* - * @brief set data to contact. you must manage the memory yourself, Generally you can set data at contact begin, and distory it at contact end. - */ - inline void setData(void* data) { _data = data; } - -private: - static PhysicsContact* create(PhysicsShape* a, PhysicsShape* b); - bool init(PhysicsShape* a, PhysicsShape* b); - - inline bool getNotify() { return _notify; } - inline void setNotify(bool notify) { _notify = notify; } - -private: - PhysicsContact(); - ~PhysicsContact(); - -private: - PhysicsShape* _shapeA; - PhysicsShape* _shapeB; - PhysicsContactInfo* _info; - void* _data; - bool _notify; - - friend class PhysicsWorld; -}; - -/* - * @brief presolve value generated when onContactPreSolve called. - */ -class PhysicsContactPreSolve -{ -private: - PhysicsContactPreSolve(); - ~PhysicsContactPreSolve(); - - static PhysicsContactPreSolve* create(); - bool init(); - - friend class PhysicsWorld; -}; - -/* - * @brief postsolve value generated when onContactPostSolve called. - */ -class PhysicsContactPostSolve -{ -private: - PhysicsContactPostSolve(); - ~PhysicsContactPostSolve(); - - static PhysicsContactPostSolve* create(); - bool init(); - - friend class PhysicsWorld; -}; - -/* - * @brief contact listener. - */ -class PhysicsContactListener -{ -public: - PhysicsContactListener(); - virtual ~PhysicsContactListener(); - -public: - /* - * @brief it will called at two shapes start to contact, and only call it once. - */ - std::function onContactBegin; - /* - * @brief Two shapes are touching during this step. Return false from the callback to make world ignore the collision this step or true to process it normally. Additionally, you may override collision values, elasticity, or surface velocity values. - */ - std::function onContactPreSolve; - /* - * @brief Two shapes are touching and their collision response has been processed. You can retrieve the collision impulse or kinetic energy at this time if you want to use it to calculate sound volumes or damage amounts. See cpArbiter for more info - */ - std::function onContactPostSolve; - /* - * @brief it will called at two shapes separated, and only call it once. - * onContactBegin and onContactEnd will called in pairs. - */ - std::function onContactEnd; -}; - -NS_CC_END -#endif //__CCPHYSICS_CONTACT_H__ - -#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/CCPhysicsJoint.h b/cocos2dx/physics/CCPhysicsJoint.h deleted file mode 100644 index ebc7ceddc0..0000000000 --- a/cocos2dx/physics/CCPhysicsJoint.h +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsSetting.h" -#ifdef CC_USE_PHYSICS - -#ifndef __CCPHYSICS_JOINT_H__ -#define __CCPHYSICS_JOINT_H__ - -#include "cocoa/CCObject.h" -#include "cocoa/CCGeometry.h" - -NS_CC_BEGIN - -class PhysicsBody; -class PhysicsJointInfo; -class PhysicsBodyInfo; - -/* - * @brief An PhysicsJoint object connects two physics bodies together. - */ -class PhysicsJoint : public Object -{ -protected: - PhysicsJoint(); - virtual ~PhysicsJoint() = 0; - -public: - PhysicsBody* getBodyA() { return _bodyA; } - PhysicsBody* getBodyB() { return _bodyB; } - inline int getTag() { return _tag; } - inline void setTag(int tag) { _tag = tag; } - inline bool isEnable() { return _enable; } - void setEnable(bool enable); - inline bool isCollisionEnable() { return _collisionEnable; } - void setCollisionEnable(bool enable); - -protected: - bool init(PhysicsBody* a, PhysicsBody* b); - - /** - * PhysicsShape is PhysicsBody's friend class, but all the subclasses isn't. so this method is use for subclasses to catch the bodyInfo from PhysicsBody. - */ - PhysicsBodyInfo* bodyInfo(PhysicsBody* body) const; - -protected: - PhysicsBody* _bodyA; - PhysicsBody* _bodyB; - PhysicsJointInfo* _info; - bool _enable; - bool _collisionEnable; - int _tag; - - friend class PhysicsBody; - friend class PhysicsWorld; -}; - -/* - * @brief A fixed joint fuses the two bodies together at a reference point. Fixed joints are useful for creating complex shapes that can be broken apart later. - */ -class PhysicsJointFixed : public PhysicsJoint -{ -public: - PhysicsJointFixed* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr); - -protected: - bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr); - -protected: - PhysicsJointFixed(); - virtual ~PhysicsJointFixed(); -}; - -/* - * @brief A sliding joint allows the two bodies to slide along a chosen axis. - */ -class PhysicsJointSliding : public PhysicsJoint -{ -public: - PhysicsJointSliding* create(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); - -protected: - PhysicsJointSliding(); - virtual ~PhysicsJointSliding(); -}; - -/* - * @brief A spring joint connects the two bodies with a spring whose length is the initial distance between the two bodies. - */ -class PhysicsJointSpring : public PhysicsJoint -{ -public: - PhysicsJointSpring* create(); - -protected: - bool init(); - -protected: - PhysicsJointSpring(); - virtual ~PhysicsJointSpring(); -}; - -/* - * @brief A limit joint imposes a maximum distance between the two bodies, as if they were connected by a rope. - */ -class PhysicsJointLimit : public PhysicsJoint -{ -public: - PhysicsJointLimit* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); - - float getMin(); - void setMin(float min); - float getMax(); - void setMax(float max); - -protected: - bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); - -protected: - PhysicsJointLimit(); - virtual ~PhysicsJointLimit(); -}; - -/* - * @brief A pin joint allows the two bodies to independently rotate around the anchor point as if pinned together. - */ -class PhysicsJointPin : public PhysicsJoint -{ -public: - static PhysicsJointPin* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr); - -protected: - bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr); - -protected: - PhysicsJointPin(); - virtual ~PhysicsJointPin(); -}; - -NS_CC_END - -#endif // __CCPHYSICS_JOINT_H__ - -#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/CCPhysicsShape.h b/cocos2dx/physics/CCPhysicsShape.h deleted file mode 100644 index fcf70c7c19..0000000000 --- a/cocos2dx/physics/CCPhysicsShape.h +++ /dev/null @@ -1,296 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsSetting.h" -#ifdef CC_USE_PHYSICS - -#ifndef __CCPHYSICS_SHAPE_H__ -#define __CCPHYSICS_SHAPE_H__ - -#include "cocoa/CCObject.h" -#include "cocoa/CCGeometry.h" - -NS_CC_BEGIN - -class PhysicsShapeInfo; -class PhysicsBody; -class PhysicsBodyInfo; - - -typedef struct PhysicsMaterial -{ - float density; - float restitution; - float friction; - - PhysicsMaterial() - : density(0.0f) - , restitution(0.0f) - , friction(0.0f){} - - PhysicsMaterial(float density, float restitution, float friction) - : density(density) - , restitution(restitution) - , friction(friction){} -}PhysicsMaterial; - -const PhysicsMaterial PHYSICSSHAPE_MATERIAL_DEFAULT = {0.0f, 1.0f, 1.0f}; - -/** - * @brief A shape for body. You do not create PhysicsWorld objects directly, instead, you can view PhysicsBody to see how to create it. - */ -class PhysicsShape : public Object -{ -public: - enum class Type - { - UNKNOWN, - CIRCLE, - BOX, - POLYGEN, - EDGESEGMENT, - EDGEBOX, - EDGEPOLYGEN, - EDGECHAIN, - }; - -public: - inline PhysicsBody* getBody() const { return _body; } - inline Type getType() const { return _type; } - inline float getArea() const { return _area; } - inline float getMoment() const { return _moment; } - void setMoment(float moment); - inline void setTag(int tag) { _tag = tag; } - inline int getTag() const { return _tag; } - - inline float getMass() const { return _mass; } - void setMass(float mass); - inline float getDensity() const { return _material.density; } - void setDensity(float density); - void setRestitution(float restitution); - void setFriction(float friction); - void setMaterial(PhysicsMaterial material); - - virtual float calculateDefaultMoment() { return 0; } - virtual float calculateDefaultArea() { return 0; } - virtual Point getOffset() { return Point::ZERO; } - virtual Point getCenter() { return getOffset(); } - - static Point* recenterPoints(Point* points, int count, Point center); - static Point getPolyonCenter(Point* points, int count); - -protected: - bool init(Type type); - - /** - * @brief PhysicsShape is PhysicsBody's friend class, but all the subclasses isn't. so this method is use for subclasses to catch the bodyInfo from PhysicsBody. - */ - PhysicsBodyInfo* bodyInfo() const; - - void setBody(PhysicsBody* body); - -protected: - PhysicsShape(); - virtual ~PhysicsShape() = 0; - -protected: - PhysicsBody* _body; - PhysicsShapeInfo* _info; - Type _type; - float _area; - float _mass; - float _moment; - PhysicsMaterial _material; - int _tag; - - friend class PhysicsWorld; - friend class PhysicsBody; - friend class PhysicsJoint; -}; - -/** A circle shape */ -class PhysicsShapeCircle : public PhysicsShape -{ -public: - static PhysicsShapeCircle* create(float radius, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0)); - static float calculateArea(float radius); - static float calculateMoment(float mass, float radius, Point offset = Point(0, 0)); - - float calculateDefaultArea() override; - float calculateDefaultMoment() override; - - float getRadius(); - Point getOffset(); -protected: - bool init(float radius, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0)); - -protected: - PhysicsShapeCircle(); - ~PhysicsShapeCircle(); -}; - -/** A box shape */ -class PhysicsShapeBox : public PhysicsShape -{ -public: - static PhysicsShapeBox* create(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0)); - static float calculateArea(Size size); - static float calculateMoment(float mass, Size size, Point offset = Point(0, 0)); - - float calculateDefaultArea() override; - float calculateDefaultMoment() override; - - Point* getPoints(Point* points); - Size getSize(); - Point getOffset() override { return _offset; } - -protected: - bool init(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0)); - -protected: - PhysicsShapeBox(); - virtual ~PhysicsShapeBox(); - -protected: - Point _offset; -}; - -/** A polygon shape */ -class PhysicsShapePolygon : public PhysicsShape -{ -public: - static PhysicsShapePolygon* create(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0)); - static float calculateArea(Point* points, int count); - static float calculateMoment(float mass, Point* points, int count, Point offset = Point(0, 0)); - - float calculateDefaultArea() override; - float calculateDefaultMoment() override; - - Point* getPoints(Point* points); - int getPointsCount(); - Point getCenter() override; -protected: - bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0)); - -protected: - PhysicsShapePolygon(); - virtual ~PhysicsShapePolygon(); - -protected: - Point _center; -}; - -/** A segment shape */ -class PhysicsShapeEdgeSegment : public PhysicsShape -{ -public: - static PhysicsShapeEdgeSegment* create(Point a, Point b, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); - - Point getPointA(); - Point getPointB(); - Point getCenter() override; - -protected: - bool init(Point a, Point b, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); - -protected: - PhysicsShapeEdgeSegment(); - virtual ~PhysicsShapeEdgeSegment(); - -protected: - Point _center; - - friend class PhysicsBody; -}; - -/** An edge box shape */ -class PhysicsShapeEdgeBox : public PhysicsShape -{ -public: - static PhysicsShapeEdgeBox* create(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 0, Point offset = Point(0, 0)); - Point getOffset() override { return _offset; } - Point* getPoints(Point* points); - int getPointsCount(); - -protected: - bool init(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1, Point offset = Point(0, 0)); - -protected: - PhysicsShapeEdgeBox(); - virtual ~PhysicsShapeEdgeBox(); - -protected: - Point _offset; - - friend class PhysicsBody; -}; - -/** An edge polygon shape */ -class PhysicsShapeEdgePolygon : public PhysicsShape -{ -public: - static PhysicsShapeEdgePolygon* create(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); - Point getCenter() override; - Point* getPoints(Point* points); - int getPointsCount(); - -protected: - bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); - -protected: - PhysicsShapeEdgePolygon(); - virtual ~PhysicsShapeEdgePolygon(); - - friend class PhysicsBody; - -protected: - Point _center; -}; - -/** a chain shape */ -class PhysicsShapeEdgeChain : public PhysicsShape -{ -public: - static PhysicsShapeEdgeChain* create(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); - Point getCenter() override; - Point* getPoints(Point* points); - int getPointsCount(); - -protected: - bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); - -protected: - PhysicsShapeEdgeChain(); - virtual ~PhysicsShapeEdgeChain(); - -protected: - Point _center; - - friend class PhysicsBody; -}; - -NS_CC_END -#endif // __CCPHYSICS_FIXTURE_H__ - -#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/CCPhysicsWorld.cpp b/cocos2dx/physics/CCPhysicsWorld.cpp deleted file mode 100644 index afccdca8d9..0000000000 --- a/cocos2dx/physics/CCPhysicsWorld.cpp +++ /dev/null @@ -1,496 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsWorld.h" -#ifdef CC_USE_PHYSICS - -#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) -#include "chipmunk.h" -#elif (CC_PHYSICS_ENGINE == CCPHYSICS_BOX2D) -#include "Box2D.h" -#endif - -#include "CCPhysicsBody.h" -#include "CCPhysicsShape.h" -#include "CCPhysicsContact.h" -#include "CCPhysicsJoint.h" -#include "CCPhysicsContact.h" - -#include "chipmunk/CCPhysicsWorldInfo.h" -#include "Box2D/CCPhysicsWorldInfo.h" -#include "chipmunk/CCPhysicsBodyInfo.h" -#include "Box2D/CCPhysicsBodyInfo.h" -#include "chipmunk/CCPhysicsShapeInfo.h" -#include "Box2D/CCPhysicsShapeInfo.h" -#include "chipmunk/CCPhysicsContactInfo.h" -#include "Box2D/CCPhysicsContactInfo.h" -#include "chipmunk/CCPhysicsJointInfo.h" -#include "Box2D/CCPhysicsJointInfo.h" -#include "chipmunk/CCPhysicsHelper.h" - -#include "draw_nodes/CCDrawNode.h" -#include "cocoa/CCArray.h" -#include "layers_scenes_transitions_nodes/CCScene.h" -#include "CCDirector.h" - -#include - -NS_CC_BEGIN - -#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) - -const float PHYSICS_INFINITY = INFINITY; - -int PhysicsWorld::collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *space, void *data) -{ - PhysicsWorld* world = static_cast(data); - - CP_ARBITER_GET_SHAPES(arb, a, b); - - auto ita = PhysicsShapeInfo::map.find(a); - auto itb = PhysicsShapeInfo::map.find(b); - CC_ASSERT(ita != PhysicsShapeInfo::map.end() && itb != PhysicsShapeInfo::map.end()); - - PhysicsContact* contact = PhysicsContact::create(ita->second->shape, itb->second->shape); - arb->data = contact; - - return world->collisionBeginCallback(*static_cast(arb->data)); -} - -int PhysicsWorld::collisionPreSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data) -{ - PhysicsWorld* world = static_cast(data); - return world->collisionPreSolveCallback(*static_cast(arb->data), - PhysicsContactPreSolve()); -} - -void PhysicsWorld::collisionPostSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data) -{ - PhysicsWorld* world = static_cast(data); - world->collisionPostSolveCallback(*static_cast(arb->data), - PhysicsContactPostSolve()); -} - -void PhysicsWorld::collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, void *data) -{ - PhysicsWorld* world = static_cast(data); - PhysicsContact* contact = static_cast(arb->data); - - world->collisionSeparateCallback(*contact); - - delete contact; -} - -bool PhysicsWorld::init() -{ - _info = new PhysicsWorldInfo(); - - cpSpaceSetGravity(_info->space, PhysicsHelper::point2cpv(_gravity)); - - cpSpaceSetDefaultCollisionHandler(_info->space, - PhysicsWorld::collisionBeginCallbackFunc, - PhysicsWorld::collisionPreSolveCallbackFunc, - PhysicsWorld::collisionPostSolveCallbackFunc, - PhysicsWorld::collisionSeparateCallbackFunc, - this); - - return true; -} - -void PhysicsWorld::addJoint(PhysicsJoint* joint) -{ - auto it = std::find(_joints.begin(), _joints.end(), joint); - - if (it == _joints.end()) - { - _joints.push_back(joint); - - for (auto subjoint : joint->_info->joints) - { - if (!cpSpaceContainsConstraint(_info->space, subjoint)) - { - cpSpaceAddConstraint(_info->space, subjoint); - } - } - } - -} - -void PhysicsWorld::removeJoint(PhysicsJoint* joint) -{ - -} - -void PhysicsWorld::removeAllJoints() -{ - -} - -void PhysicsWorld::addShape(PhysicsShape* shape) -{ - for (auto cps : shape->_info->shapes) - { - if (cpSpaceContainsShape(_info->space, cps)) - { - continue; - } - - if (cpBodyIsStatic(shape->getBody()->_info->body)) - { - cpSpaceAddStaticShape(_info->space, cps); - }else - { - cpSpaceAddShape(_info->space, cps); - } - } -} - -void PhysicsWorld::addBody(PhysicsBody* body) -{ - CCASSERT(body != nullptr, "the body can not be nullptr"); - - if (body->isEnable()) - { - //is gravity enable - if (!body->isGravityEnable()) - { - body->applyForce(-_gravity); - } - - // add body to space - if (body->isDynamic()) - { - cpSpaceAddBody(_info->space, body->_info->body); - } - - // add shapes to space - for (auto shape : body->getShapes()) - { - addShape(shape); - } - } - - if (_bodys == nullptr) - { - _bodys = Array::create(body, NULL); - _bodys->retain(); - }else - { - _bodys->addObject(body); - } -} - -void PhysicsWorld::removeBody(PhysicsBody* body) -{ - CCASSERT(body != nullptr, "the body can not be nullptr"); - - if (body->getWorld() == this) - { - // reset the gravity - if (!body->isGravityEnable()) - { - body->applyForce(-_gravity); - } - } - - // remove shaps - for (auto shape : body->getShapes()) - { - for (auto cps : shape->_info->shapes) - { - if (cpSpaceContainsShape(_info->space, cps)) - { - cpSpaceRemoveShape(_info->space, cps); - } - } - } - - // remove body - if (cpSpaceContainsBody(_info->space, body->_info->body)) - { - cpSpaceRemoveBody(_info->space, body->_info->body); - } - - if (_bodys != nullptr) - { - _bodys->removeObject(body); - } -} - -void PhysicsWorld::removeBodyByTag(int tag) -{ - for (Object* obj : *_bodys) - { - PhysicsBody* body = dynamic_cast(obj); - if (body->getTag() == tag) - { - removeBody(body); - return; - } - } -} - -void PhysicsWorld::removeShape(PhysicsShape* shape) -{ - for (auto cps : shape->_info->shapes) - { - if (cpSpaceContainsShape(_info->space, cps)) - { - cpSpaceRemoveShape(_info->space, cps); - } - } -} - -void PhysicsWorld::update(float delta) -{ - for (auto body : *_bodys) - { - body->update(delta); - } - - cpSpaceStep(_info->space, delta); - - if (_drawNode) - { - _drawNode->removeFromParent(); - _drawNode = nullptr; - } - - if (_debugDraw) - { - debugDraw(); - } -} - -void PhysicsWorld::debugDraw() -{ - if (_debugDraw && _bodys != nullptr) - { - _drawNode= DrawNode::create(); - - for (Object* obj : *_bodys) - { - PhysicsBody* body = dynamic_cast(obj); - - std::vector shapes = body->getShapes(); - - for (auto shape : shapes) - { - drawWithShape(_drawNode, shape); - } - } - - if (_scene) - { - _scene->addChild(_drawNode); - } - } -} - -void PhysicsWorld::setScene(Scene *scene) -{ - _scene = scene; -} - -void PhysicsWorld::drawWithShape(DrawNode* node, PhysicsShape* shape) -{ - for (auto it = shape->_info->shapes.begin(); it != shape->_info->shapes.end(); ++it) - { - cpShape *shape = *it; - - switch ((*it)->klass_private->type) - { - case CP_CIRCLE_SHAPE: - { - float radius = PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(shape)); - Point centre = PhysicsHelper::cpv2point(cpBodyGetPos(cpShapeGetBody(shape))) - + PhysicsHelper::cpv2point(cpCircleShapeGetOffset(shape)); - - Point seg[4] = {}; - seg[0] = Point(centre.x - radius, centre.y - radius); - seg[1] = Point(centre.x - radius, centre.y + radius); - seg[2] = Point(centre.x + radius, centre.y + radius); - seg[3] = Point(centre.x + radius, centre.y - radius); - node->drawPolygon(seg, 4, Color4F(), 1, Color4F(1, 0, 0, 1)); - break; - } - case CP_SEGMENT_SHAPE: - { - cpSegmentShape *seg = (cpSegmentShape *)shape; - node->drawSegment(PhysicsHelper::cpv2point(seg->ta), - PhysicsHelper::cpv2point(seg->tb), - PhysicsHelper::cpfloat2float(seg->r==0 ? 1 : seg->r), Color4F(1, 0, 0, 1)); - break; - } - case CP_POLY_SHAPE: - { - cpPolyShape* poly = (cpPolyShape*)shape; - int num = poly->numVerts; - Point* seg = new Point[num]; - - PhysicsHelper::cpvs2points(poly->tVerts, seg, num); - - node->drawPolygon(seg, num, Color4F(1.0f, 0.0f, 0.0f, 0.3f), 1.0f, Color4F(1.0f, 0.0f, 0.0f, 1.0f)); - - delete[] seg; - break; - } - default: - break; - } - } -} - -int PhysicsWorld::collisionBeginCallback(PhysicsContact& contact) -{ - bool ret = true; - PhysicsBody* bodyA = contact.getShapeA()->getBody(); - PhysicsBody* bodyB = contact.getShapeB()->getBody(); - - if ((bodyA->getCategoryBitmask() & bodyB->getContactTestBitmask()) == 0) - { - contact.setNotify(false); - } - - if ((bodyA->getCategoryBitmask() & bodyB->getCollisionBitmask()) == 0) - { - ret = false; - } - - if (contact.getNotify() && _listener && _listener->onContactBegin) - { - // the mask has high priority than _listener->onContactBegin. - // so if the mask test is false, the two bodies won't have collision. - if (ret) - { - ret = _listener->onContactBegin(contact); - }else - { - _listener->onContactBegin(contact); - } - } - - return ret; -} - -int PhysicsWorld::collisionPreSolveCallback(PhysicsContact& contact, const PhysicsContactPreSolve& solve) -{ - if (!contact.getNotify()) - { - return true; - } - - if (_listener && _listener->onContactPreSolve) - { - return _listener->onContactPreSolve(contact, solve); - } - - return true; -} - -void PhysicsWorld::collisionPostSolveCallback(PhysicsContact& contact, const PhysicsContactPostSolve& solve) -{ - if (!contact.getNotify()) - { - return; - } - - if (_listener && _listener->onContactPreSolve) - { - _listener->onContactPostSolve(contact, solve); - } -} - -void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact) -{ - if (!contact.getNotify()) - { - return; - } - - if (_listener && _listener->onContactEnd) - { - _listener->onContactEnd(contact); - } -} - -void PhysicsWorld::setGravity(Point gravity) -{ - if (_bodys != nullptr) - { - for (auto child : *_bodys) - { - PhysicsBody* body = dynamic_cast(child); - - // reset gravity for body - if (!body->isGravityEnable()) - { - body->applyForce(-_gravity); - body->applyForce(gravity); - } - } - } - - _gravity = gravity; - cpSpaceSetGravity(_info->space, PhysicsHelper::point2cpv(gravity)); -} - -#elif (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) - -#endif - -PhysicsWorld* PhysicsWorld::create() -{ - PhysicsWorld * world = new PhysicsWorld(); - if(world && world->init()) - { - return world; - } - - CC_SAFE_DELETE(world); - return nullptr; -} - -PhysicsWorld::PhysicsWorld() -: _gravity(Point(0.0f, -98.0f)) -, _speed(1.0f) -, _info(nullptr) -, _listener(nullptr) -, _bodys(nullptr) -, _scene(nullptr) -, _debugDraw(false) -, _drawNode(nullptr) -{ - -} - -PhysicsWorld::~PhysicsWorld() -{ - CC_SAFE_DELETE(_info); - CC_SAFE_RELEASE(_bodys); -} - -NS_CC_END - -#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/CCPhysicsWorld.h b/cocos2dx/physics/CCPhysicsWorld.h deleted file mode 100644 index a0539ae81d..0000000000 --- a/cocos2dx/physics/CCPhysicsWorld.h +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsSetting.h" -#ifdef CC_USE_PHYSICS - -#ifndef __CCPHYSICS_WORLD_H__ -#define __CCPHYSICS_WORLD_H__ - -#include - -#include "cocoa/CCObject.h" -#include "cocoa/CCGeometry.h" - - -#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) -typedef struct cpArbiter cpArbiter; -typedef struct cpSpace cpSpace; -#endif - -NS_CC_BEGIN - -class PhysicsBody; -class PhysicsJoint; -class PhysicsWorldInfo; -class PhysicsShape; -class PhysicsContact; -class PhysicsContactPreSolve; -class PhysicsContactPostSolve; -class PhysicsContactListener; -class Array; - -class Sprite; -class Scene; -class DrawNode; - -/** - * @brief An PhysicsWorld object simulates collisions and other physical properties. You do not create PhysicsWorld objects directly; instead, you can get it from an Scene object. - */ -class PhysicsWorld -{ -public: - /** Adds a joint to the physics world.*/ - void addJoint(PhysicsJoint* joint); - /** Removes a joint from the physics world.*/ - void removeJoint(PhysicsJoint* joint); - /** Remove all joints from the physics world.*/ - void removeAllJoints(); - - Array* getBodysAlongRay(Point start, Point end) const; - Array* getBodysAtPoint(Point point) const; - Array* getBodysInRect(Rect rect) const; - Array* getAllBody() const; - - /** Register a listener to receive contact callbacks*/ - inline void registerContactListener(PhysicsContactListener* delegate) { _listener = delegate; } - /** Unregister a listener. */ - inline void unregisterContactListener() { _listener = nullptr; } - - /** get the gravity value */ - inline Point getGravity() { return _gravity; } - /** set the gravity value */ - void setGravity(Point gravity); - - /** test the debug draw is enabled */ - inline bool isDebugDraw() { return _debugDraw; } - /** set the debug draw */ - inline void setDebugDraw(bool debugDraw) { _debugDraw = debugDraw; } - - virtual void removeBody(PhysicsBody* body); - virtual void removeBodyByTag(int tag); - -protected: - static PhysicsWorld* create(); - bool init(); - - void setScene(Scene* scene); - - virtual void addBody(PhysicsBody* body); - virtual void addShape(PhysicsShape* shape); - virtual void removeShape(PhysicsShape* shape); - virtual void update(float delta); - - virtual void debugDraw(); - virtual void drawWithShape(DrawNode* node, PhysicsShape* shape); - - - virtual int collisionBeginCallback(PhysicsContact& contact); - virtual int collisionPreSolveCallback(PhysicsContact& contact, const PhysicsContactPreSolve& solve); - virtual void collisionPostSolveCallback(PhysicsContact& contact, const PhysicsContactPostSolve& solve); - virtual void collisionSeparateCallback(PhysicsContact& contact); - -#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) - static int collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *space, void *data); - static int collisionPreSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data); - static void collisionPostSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data); - static void collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, void *data); -#endif - -protected: - Point _gravity; - float _speed; - PhysicsWorldInfo* _info; - PhysicsContactListener* _listener; - - - Array* _bodys; - std::list _joints; - Scene* _scene; - - bool _debugDraw; - DrawNode* _drawNode; - -protected: - PhysicsWorld(); - virtual ~PhysicsWorld(); - - friend class Sprite; - friend class Scene; - friend class PhysicsBody; - friend class PhysicsShape; -}; - -NS_CC_END - -#endif // __CCPHYSICS_WORLD_H__ - -#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.h b/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.h deleted file mode 100644 index a394aa807b..0000000000 --- a/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "../CCPhysicsSetting.h" -#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) - -#ifndef __CCPHYSICS_BODY_INFO_H__ -#define __CCPHYSICS_BODY_INFO_H__ -#include "chipmunk.h" -#include "platform/CCPlatformMacros.h" -#include "cocoa/CCObject.h" - -NS_CC_BEGIN - -class PhysicsBodyInfo : public Clonable -{ -public: - cpBody* body; - cpGroup group; - -private: - PhysicsBodyInfo(); - ~PhysicsBodyInfo(); - - Clonable* clone() const override; - - friend class PhysicsBody; -}; - -NS_CC_END -#endif // __CCPHYSICS_BODY_INFO_H__ - -#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsHelper.h b/cocos2dx/physics/chipmunk/CCPhysicsHelper.h deleted file mode 100644 index 9334d87124..0000000000 --- a/cocos2dx/physics/chipmunk/CCPhysicsHelper.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "../CCPhysicsSetting.h" -#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) - -#ifndef __CCPHYSICS_HELPER_H__ -#define __CCPHYSICS_HELPER_H__ - -#include "chipmunk.h" -#include "platform/CCPlatformMacros.h" -#include "cocoa/CCGeometry.h" - -NS_CC_BEGIN - -class PhysicsHelper -{ -public: - static Point cpv2point(const cpVect& vec) { return Point(vec.x, vec.y); } - static cpVect point2cpv(const Point& point) { return cpv(point.x, point.y); } - static Size cpv2size(const cpVect& vec) { return Size(vec.x, vec.y); } - static cpVect size2cpv(const Size& size) { return cpv(size.width, size.height); } - static float cpfloat2float(cpFloat f) { return f; } - static cpFloat float2cpfloat(float f) { return f; } - - static Point* cpvs2points(const cpVect* cpvs, Point* points, int count) - { - for (int i = 0; i < count; ++i) - { - points[i] = cpv2point(cpvs[i]); - } - - return points; - } - - static cpVect* points2cpvs(const Point* points, cpVect* cpvs, int count) - { - for (int i = 0; i < count; ++i) - { - cpvs[i] = point2cpv(points[i]); - } - - return cpvs; - } -}; - -NS_CC_END -#endif // __CCPHYSICS_HELPER_H__ - -#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.h b/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.h deleted file mode 100644 index 1140b8783e..0000000000 --- a/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "../CCPhysicsSetting.h" -#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) - -#ifndef __CCPHYSICS_JOINT_INFO_H__ -#define __CCPHYSICS_JOINT_INFO_H__ -#include "chipmunk.h" -#include "platform/CCPlatformMacros.h" -#include -#include -NS_CC_BEGIN - -class PhysicsJoint; - -class PhysicsJointInfo -{ -public: - void add(cpConstraint* shape); - void remove(cpConstraint* shape); - void removeAll(); - -public: - std::vector joints; - PhysicsJoint* joint; - static std::map map; - -private: - PhysicsJointInfo(PhysicsJoint* joint); - ~PhysicsJointInfo(); - - friend class PhysicsJoint; -}; - -NS_CC_END -#endif // __CCPHYSICS_SHAPE_INFO_H__ - -#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.h b/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.h deleted file mode 100644 index f84f8613c6..0000000000 --- a/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "../CCPhysicsSetting.h" -#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) - -#ifndef __CCPHYSICS_SHAPE_INFO_H__ -#define __CCPHYSICS_SHAPE_INFO_H__ - -#include -#include -#include "chipmunk.h" -#include "platform/CCPlatformMacros.h" - -NS_CC_BEGIN - -class PhysicsShape; - -class PhysicsShapeInfo -{ -public: - void add(cpShape* shape); - void remove(cpShape* shape); - void removeAll(); - void setGroup(cpGroup group); - void setBody(cpBody* body); - -public: - std::vector shapes; - PhysicsShape* shape; - cpBody* body; - cpGroup group; - static std::map map; - static cpBody* shareBody; - -private: - PhysicsShapeInfo(PhysicsShape* shape); - ~PhysicsShapeInfo(); - - friend class PhysicsShape; -}; - -NS_CC_END -#endif // __CCPHYSICS_SHAPE_INFO_H__ - -#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp deleted file mode 100644 index f9bb30df89..0000000000 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ /dev/null @@ -1,1138 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2008-2010 Ricardo Quesada -Copyright (c) 2011 Zynga Inc. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#include "CCSpriteBatchNode.h" -#include -#include -#include "CCAnimation.h" -#include "CCAnimationCache.h" -#include "ccConfig.h" -#include "CCSprite.h" -#include "CCSpriteFrame.h" -#include "CCSpriteFrameCache.h" -#include "textures/CCTextureCache.h" -#include "draw_nodes/CCDrawingPrimitives.h" -#include "shaders/CCShaderCache.h" -#include "shaders/ccGLStateCache.h" -#include "shaders/CCGLProgram.h" -#include "CCDirector.h" -#include "cocoa/CCGeometry.h" -#include "textures/CCTexture2D.h" -#include "cocoa/CCAffineTransform.h" -#include "support/TransformUtils.h" -#include "support/CCProfiling.h" -// external -#include "kazmath/GL/matrix.h" - - -using namespace std; - -NS_CC_BEGIN - -#if CC_SPRITEBATCHNODE_RENDER_SUBPIXEL -#define RENDER_IN_SUBPIXEL -#else -#define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__)) -#endif - -Sprite* Sprite::createWithTexture(Texture2D *texture) -{ - Sprite *sprite = new Sprite(); - if (sprite && sprite->initWithTexture(texture)) - { - sprite->autorelease(); - return sprite; - } - CC_SAFE_DELETE(sprite); - return NULL; -} - -Sprite* Sprite::createWithTexture(Texture2D *texture, const Rect& rect) -{ - Sprite *sprite = new Sprite(); - if (sprite && sprite->initWithTexture(texture, rect)) - { - sprite->autorelease(); - return sprite; - } - CC_SAFE_DELETE(sprite); - return NULL; -} - -Sprite* Sprite::create(const char *filename) -{ - Sprite *sprite = new Sprite(); - if (sprite && sprite->initWithFile(filename)) - { - sprite->autorelease(); - return sprite; - } - CC_SAFE_DELETE(sprite); - return NULL; -} - -Sprite* Sprite::create(const char *filename, const Rect& rect) -{ - Sprite *sprite = new Sprite(); - if (sprite && sprite->initWithFile(filename, rect)) - { - sprite->autorelease(); - return sprite; - } - CC_SAFE_DELETE(sprite); - return NULL; -} - -Sprite* Sprite::createWithSpriteFrame(SpriteFrame *spriteFrame) -{ - Sprite *sprite = new Sprite(); - if (spriteFrame && sprite && sprite->initWithSpriteFrame(spriteFrame)) - { - sprite->autorelease(); - return sprite; - } - CC_SAFE_DELETE(sprite); - return NULL; -} - -Sprite* Sprite::createWithSpriteFrameName(const char *spriteFrameName) -{ - SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName); - -#if COCOS2D_DEBUG > 0 - char msg[256] = {0}; - sprintf(msg, "Invalid spriteFrameName: %s", spriteFrameName); - CCASSERT(frame != NULL, msg); -#endif - - return createWithSpriteFrame(frame); -} - -Sprite* Sprite::create() -{ - Sprite *sprite = new Sprite(); - if (sprite && sprite->init()) - { - sprite->autorelease(); - return sprite; - } - CC_SAFE_DELETE(sprite); - return NULL; -} - -bool Sprite::init(void) -{ - return initWithTexture(NULL, Rect::ZERO); -} - -// designated initializer -bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) -{ - if (NodeRGBA::init()) - { - _batchNode = NULL; - - _recursiveDirty = false; - setDirty(false); - - _opacityModifyRGB = true; - - _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; - - _flippedX = _flippedY = false; - - // default transform anchor: center - setAnchorPoint(Point(0.5f, 0.5f)); - - // zwoptex default values - _offsetPosition = Point::ZERO; - - _hasChildren = false; - - // clean the Quad - memset(&_quad, 0, sizeof(_quad)); - - // Atlas: Color - _quad.bl.colors = Color4B::WHITE; - _quad.br.colors = Color4B::WHITE; - _quad.tl.colors = Color4B::WHITE; - _quad.tr.colors = Color4B::WHITE; - - // shader program - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); - - // update texture (calls updateBlendFunc) - setTexture(texture); - setTextureRect(rect, rotated, rect.size); - - // by default use "Self Render". - // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" - setBatchNode(NULL); - - return true; - } - else - { - return false; - } -} - -bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect) -{ - return initWithTexture(texture, rect, false); -} - -bool Sprite::initWithTexture(Texture2D *texture) -{ - CCASSERT(texture != NULL, "Invalid texture for sprite"); - - Rect rect = Rect::ZERO; - rect.size = texture->getContentSize(); - - return initWithTexture(texture, rect); -} - -bool Sprite::initWithFile(const char *filename) -{ - CCASSERT(filename != NULL, "Invalid filename for sprite"); - - Texture2D *texture = TextureCache::getInstance()->addImage(filename); - if (texture) - { - Rect rect = Rect::ZERO; - rect.size = texture->getContentSize(); - return initWithTexture(texture, rect); - } - - // don't release here. - // when load texture failed, it's better to get a "transparent" sprite then a crashed program - // this->release(); - return false; -} - -bool Sprite::initWithFile(const char *filename, const Rect& rect) -{ - CCASSERT(filename != NULL, ""); - - Texture2D *texture = TextureCache::getInstance()->addImage(filename); - if (texture) - { - return initWithTexture(texture, rect); - } - - // don't release here. - // when load texture failed, it's better to get a "transparent" sprite then a crashed program - // this->release(); - return false; -} - -bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame) -{ - CCASSERT(spriteFrame != NULL, ""); - - bool bRet = initWithTexture(spriteFrame->getTexture(), spriteFrame->getRect()); - setDisplayFrame(spriteFrame); - - return bRet; -} - -bool Sprite::initWithSpriteFrameName(const char *spriteFrameName) -{ - CCASSERT(spriteFrameName != NULL, ""); - - SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName); - return initWithSpriteFrame(frame); -} - -// XXX: deprecated -/* -Sprite* Sprite::initWithCGImage(CGImageRef pImage) -{ - // todo - // because it is deprecated, so we do not implement it - - return NULL; -} -*/ - -/* -Sprite* Sprite::initWithCGImage(CGImageRef pImage, const char *pszKey) -{ - CCASSERT(pImage != NULL); - - // XXX: possible bug. See issue #349. New API should be added - Texture2D *texture = TextureCache::getInstance()->addCGImage(pImage, pszKey); - - const Size& size = texture->getContentSize(); - Rect rect = Rect(0 ,0, size.width, size.height); - - return initWithTexture(texture, rect); -} -*/ - -Sprite::Sprite(void) -: _shouldBeHidden(false) -, _texture(nullptr) -{ -} - -Sprite::~Sprite(void) -{ - CC_SAFE_RELEASE(_texture); -} - -void Sprite::setTextureRect(const Rect& rect) -{ - setTextureRect(rect, false, rect.size); -} - - -void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimmedSize) -{ - _rectRotated = rotated; - - setContentSize(untrimmedSize); - setVertexRect(rect); - setTextureCoords(rect); - - Point relativeOffset = _unflippedOffsetPositionFromCenter; - - // issue #732 - if (_flippedX) - { - relativeOffset.x = -relativeOffset.x; - } - if (_flippedY) - { - relativeOffset.y = -relativeOffset.y; - } - - _offsetPosition.x = relativeOffset.x + (_contentSize.width - _rect.size.width) / 2; - _offsetPosition.y = relativeOffset.y + (_contentSize.height - _rect.size.height) / 2; - - // rendering using batch node - if (_batchNode) - { - // update dirty_, don't update recursiveDirty_ - setDirty(true); - } - else - { - // self rendering - - // Atlas: Vertex - float x1 = 0 + _offsetPosition.x; - float y1 = 0 + _offsetPosition.y; - float x2 = x1 + _rect.size.width; - float y2 = y1 + _rect.size.height; - - // Don't update Z. - _quad.bl.vertices = Vertex3F(x1, y1, 0); - _quad.br.vertices = Vertex3F(x2, y1, 0); - _quad.tl.vertices = Vertex3F(x1, y2, 0); - _quad.tr.vertices = Vertex3F(x2, y2, 0); - } -} - -// override this method to generate "double scale" sprites -void Sprite::setVertexRect(const Rect& rect) -{ - _rect = rect; -} - -void Sprite::setTextureCoords(Rect rect) -{ - rect = CC_RECT_POINTS_TO_PIXELS(rect); - - Texture2D *tex = _batchNode ? _textureAtlas->getTexture() : _texture; - if (! tex) - { - return; - } - - float atlasWidth = (float)tex->getPixelsWide(); - float atlasHeight = (float)tex->getPixelsHigh(); - - float left, right, top, bottom; - - if (_rectRotated) - { -#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - left = (2*rect.origin.x+1)/(2*atlasWidth); - right = left+(rect.size.height*2-2)/(2*atlasWidth); - top = (2*rect.origin.y+1)/(2*atlasHeight); - bottom = top+(rect.size.width*2-2)/(2*atlasHeight); -#else - left = rect.origin.x/atlasWidth; - right = (rect.origin.x+rect.size.height) / atlasWidth; - top = rect.origin.y/atlasHeight; - bottom = (rect.origin.y+rect.size.width) / atlasHeight; -#endif // CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - - if (_flippedX) - { - CC_SWAP(top, bottom, float); - } - - if (_flippedY) - { - CC_SWAP(left, right, float); - } - - _quad.bl.texCoords.u = left; - _quad.bl.texCoords.v = top; - _quad.br.texCoords.u = left; - _quad.br.texCoords.v = bottom; - _quad.tl.texCoords.u = right; - _quad.tl.texCoords.v = top; - _quad.tr.texCoords.u = right; - _quad.tr.texCoords.v = bottom; - } - else - { -#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - left = (2*rect.origin.x+1)/(2*atlasWidth); - right = left + (rect.size.width*2-2)/(2*atlasWidth); - top = (2*rect.origin.y+1)/(2*atlasHeight); - bottom = top + (rect.size.height*2-2)/(2*atlasHeight); -#else - left = rect.origin.x/atlasWidth; - right = (rect.origin.x + rect.size.width) / atlasWidth; - top = rect.origin.y/atlasHeight; - bottom = (rect.origin.y + rect.size.height) / atlasHeight; -#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - - if(_flippedX) - { - CC_SWAP(left,right,float); - } - - if(_flippedY) - { - CC_SWAP(top,bottom,float); - } - - _quad.bl.texCoords.u = left; - _quad.bl.texCoords.v = bottom; - _quad.br.texCoords.u = right; - _quad.br.texCoords.v = bottom; - _quad.tl.texCoords.u = left; - _quad.tl.texCoords.v = top; - _quad.tr.texCoords.u = right; - _quad.tr.texCoords.v = top; - } -} - -void Sprite::updateTransform(void) -{ - CCASSERT(_batchNode, "updateTransform is only valid when Sprite is being rendered using an SpriteBatchNode"); - -#ifdef CC_USE_PHYSICS - updatePhysicsTransform(); - setDirty(true); -#endif - - // recalculate matrix only if it is dirty - if( isDirty() ) { - - // If it is not visible, or one of its ancestors is not visible, then do nothing: - if( !_visible || ( _parent && _parent != _batchNode && static_cast(_parent)->_shouldBeHidden) ) - { - _quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vertex3F(0,0,0); - _shouldBeHidden = true; - } - else - { - _shouldBeHidden = false; - - if( ! _parent || _parent == _batchNode ) - { - _transformToBatch = getNodeToParentTransform(); - } - else - { - CCASSERT( dynamic_cast(_parent), "Logic error in Sprite. Parent must be a Sprite"); - _transformToBatch = AffineTransformConcat( getNodeToParentTransform() , static_cast(_parent)->_transformToBatch ); - } - - // - // calculate the Quad based on the Affine Matrix - // - - Size size = _rect.size; - - float x1 = _offsetPosition.x; - float y1 = _offsetPosition.y; - - float x2 = x1 + size.width; - float y2 = y1 + size.height; - float x = _transformToBatch.tx; - float y = _transformToBatch.ty; - - float cr = _transformToBatch.a; - float sr = _transformToBatch.b; - float cr2 = _transformToBatch.d; - float sr2 = -_transformToBatch.c; - float ax = x1 * cr - y1 * sr2 + x; - float ay = x1 * sr + y1 * cr2 + y; - - float bx = x2 * cr - y1 * sr2 + x; - float by = x2 * sr + y1 * cr2 + y; - - float cx = x2 * cr - y2 * sr2 + x; - float cy = x2 * sr + y2 * cr2 + y; - - float dx = x1 * cr - y2 * sr2 + x; - float dy = x1 * sr + y2 * cr2 + y; - - _quad.bl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _vertexZ ); - _quad.br.vertices = Vertex3F( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _vertexZ ); - _quad.tl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _vertexZ ); - _quad.tr.vertices = Vertex3F( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _vertexZ ); - } - - // MARMALADE CHANGE: ADDED CHECK FOR NULL, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS - if (_textureAtlas) - { - _textureAtlas->updateQuad(&_quad, _atlasIndex); - } - - _recursiveDirty = false; - setDirty(false); - } - - // MARMALADE CHANGED - // recursively iterate over children -/* if( _hasChildren ) - { - // MARMALADE: CHANGED TO USE Node* - // NOTE THAT WE HAVE ALSO DEFINED virtual Node::updateTransform() - arrayMakeObjectsPerformSelector(_children, updateTransform, Sprite*); - }*/ - Node::updateTransform(); - -#if CC_SPRITE_DEBUG_DRAW - // draw bounding box - Point vertices[4] = { - Point( _quad.bl.vertices.x, _quad.bl.vertices.y ), - Point( _quad.br.vertices.x, _quad.br.vertices.y ), - Point( _quad.tr.vertices.x, _quad.tr.vertices.y ), - Point( _quad.tl.vertices.x, _quad.tl.vertices.y ), - }; - ccDrawPoly(vertices, 4, true); -#endif // CC_SPRITE_DEBUG_DRAW -} - -// draw - -void Sprite::draw(void) -{ - CC_PROFILER_START_CATEGORY(kProfilerCategorySprite, "CCSprite - draw"); - - CCASSERT(!_batchNode, "If Sprite is being rendered by SpriteBatchNode, Sprite#draw SHOULD NOT be called"); - - CC_NODE_DRAW_SETUP(); - - GL::blendFunc( _blendFunc.src, _blendFunc.dst ); - - GL::bindTexture2D( _texture->getName() ); - GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); - -#define kQuadSize sizeof(_quad.bl) -#ifdef EMSCRIPTEN - long offset = 0; - setGLBufferData(&_quad, 4 * kQuadSize, 0); -#else - long offset = (long)&_quad; -#endif // EMSCRIPTEN - - // vertex - int diff = offsetof( V3F_C4B_T2F, vertices); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); - - // texCoods - diff = offsetof( V3F_C4B_T2F, texCoords); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); - - // color - diff = offsetof( V3F_C4B_T2F, colors); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); - - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - CHECK_GL_ERROR_DEBUG(); - - -#if CC_SPRITE_DEBUG_DRAW == 1 - // draw bounding box - Point vertices[4]={ - Point(_quad.tl.vertices.x,_quad.tl.vertices.y), - Point(_quad.bl.vertices.x,_quad.bl.vertices.y), - Point(_quad.br.vertices.x,_quad.br.vertices.y), - Point(_quad.tr.vertices.x,_quad.tr.vertices.y), - }; - ccDrawPoly(vertices, 4, true); -#elif CC_SPRITE_DEBUG_DRAW == 2 - // draw texture box - Size s = this->getTextureRect().size; - Point offsetPix = this->getOffsetPosition(); - Point vertices[4] = { - Point(offsetPix.x,offsetPix.y), Point(offsetPix.x+s.width,offsetPix.y), - Point(offsetPix.x+s.width,offsetPix.y+s.height), Point(offsetPix.x,offsetPix.y+s.height) - }; - ccDrawPoly(vertices, 4, true); -#endif // CC_SPRITE_DEBUG_DRAW - - CC_INCREMENT_GL_DRAWS(1); - - CC_PROFILER_STOP_CATEGORY(kProfilerCategorySprite, "CCSprite - draw"); -} - -// Node overrides - -void Sprite::addChild(Node* child) -{ - Node::addChild(child); -} - -void Sprite::addChild(Node *child, int zOrder) -{ - Node::addChild(child, zOrder); -} - -void Sprite::addChild(Node *child, int zOrder, int tag) -{ - CCASSERT(child != NULL, "Argument must be non-NULL"); - - if (_batchNode) - { - Sprite* childSprite = dynamic_cast(child); - CCASSERT( childSprite, "CCSprite only supports Sprites as children when using SpriteBatchNode"); - CCASSERT(childSprite->getTexture()->getName() == _textureAtlas->getTexture()->getName(), ""); - //put it in descendants array of batch node - _batchNode->appendChild(childSprite); - - if (!_reorderChildDirty) - { - setReorderChildDirtyRecursively(); - } - } - //CCNode already sets isReorderChildDirty_ so this needs to be after batchNode check - Node::addChild(child, zOrder, tag); - _hasChildren = true; -} - -void Sprite::reorderChild(Node *child, int zOrder) -{ - CCASSERT(child != NULL, ""); - CCASSERT(_children->containsObject(child), ""); - - if (zOrder == child->getZOrder()) - { - return; - } - - if( _batchNode && ! _reorderChildDirty) - { - setReorderChildDirtyRecursively(); - _batchNode->reorderBatch(true); - } - - Node::reorderChild(child, zOrder); -} - -void Sprite::removeChild(Node *child, bool cleanup) -{ - if (_batchNode) - { - _batchNode->removeSpriteFromAtlas((Sprite*)(child)); - } - - Node::removeChild(child, cleanup); - -} - -void Sprite::removeAllChildrenWithCleanup(bool cleanup) -{ - if (_batchNode) - { - Object* object = NULL; - CCARRAY_FOREACH(_children, object) - { - Sprite* child = dynamic_cast(object); - if (child) - { - _batchNode->removeSpriteFromAtlas(child); - } - } - } - - Node::removeAllChildrenWithCleanup(cleanup); - - _hasChildren = false; -} - -void Sprite::sortAllChildren() -{ - if (_reorderChildDirty) - { -#if 0 - int i = 0, j = 0, length = _children->count(); - - // insertion sort - for(i=1; i( _children->getObjectAtIndex(i) ); - auto tempJ = static_cast( _children->getObjectAtIndex(j) ); - - //continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller - while(j>=0 && ( tempI->getZOrder() < tempJ->getZOrder() || - ( tempI->getZOrder() == tempJ->getZOrder() && - tempI->getOrderOfArrival() < tempJ->getOrderOfArrival() ) ) ) - { - _children->fastSetObject( tempJ, j+1 ); - j = j-1; - if(j>=0) - tempJ = static_cast( _children->getObjectAtIndex(j) ); - } - _children->fastSetObject(tempI, j+1); - } -#else - std::sort(std::begin(*_children), std::end(*_children), nodeComparisonLess); -#endif - - if ( _batchNode) - { - arrayMakeObjectsPerformSelector(_children, sortAllChildren, Sprite*); - } - - _reorderChildDirty = false; - } -} - -// -// Node property overloads -// used only when parent is SpriteBatchNode -// - -void Sprite::setReorderChildDirtyRecursively(void) -{ - //only set parents flag the first time - if ( ! _reorderChildDirty ) - { - _reorderChildDirty = true; - Node* node = static_cast(_parent); - while (node && node != _batchNode) - { - static_cast(node)->setReorderChildDirtyRecursively(); - node=node->getParent(); - } - } -} - - -void Sprite::setDirtyRecursively(bool bValue) -{ - _recursiveDirty = bValue; - setDirty(bValue); - // recursively set dirty - if (_hasChildren) - { - Object* object = NULL; - CCARRAY_FOREACH(_children, object) - { - Sprite* child = dynamic_cast(object); - if (child) - { - child->setDirtyRecursively(true); - } - } - } -} - -// XXX HACK: optimization -#define SET_DIRTY_RECURSIVELY() { \ - if (_batchNode && ! _recursiveDirty) { \ - _recursiveDirty = true; \ - setDirty(true); \ - if ( _hasChildren) \ - setDirtyRecursively(true); \ - } \ - } - -void Sprite::setPosition(const Point& pos) -{ - Node::setPosition(pos); - SET_DIRTY_RECURSIVELY(); -} - -void Sprite::setRotation(float rotation) -{ - Node::setRotation(rotation); - - SET_DIRTY_RECURSIVELY(); -} - -void Sprite::setRotationX(float fRotationX) -{ - Node::setRotationX(fRotationX); - SET_DIRTY_RECURSIVELY(); -} - -void Sprite::setRotationY(float fRotationY) -{ - Node::setRotationY(fRotationY); - SET_DIRTY_RECURSIVELY(); -} - -void Sprite::setSkewX(float sx) -{ - Node::setSkewX(sx); - SET_DIRTY_RECURSIVELY(); -} - -void Sprite::setSkewY(float sy) -{ - Node::setSkewY(sy); - SET_DIRTY_RECURSIVELY(); -} - -void Sprite::setScaleX(float scaleX) -{ - Node::setScaleX(scaleX); - SET_DIRTY_RECURSIVELY(); -} - -void Sprite::setScaleY(float scaleY) -{ - Node::setScaleY(scaleY); - SET_DIRTY_RECURSIVELY(); -} - -void Sprite::setScale(float fScale) -{ - Node::setScale(fScale); - SET_DIRTY_RECURSIVELY(); -} - -void Sprite::setVertexZ(float fVertexZ) -{ - Node::setVertexZ(fVertexZ); - SET_DIRTY_RECURSIVELY(); -} - -void Sprite::setAnchorPoint(const Point& anchor) -{ - Node::setAnchorPoint(anchor); - SET_DIRTY_RECURSIVELY(); -} - -void Sprite::ignoreAnchorPointForPosition(bool value) -{ - CCASSERT(! _batchNode, "ignoreAnchorPointForPosition is invalid in Sprite"); - Node::ignoreAnchorPointForPosition(value); -} - -void Sprite::setVisible(bool bVisible) -{ - Node::setVisible(bVisible); - SET_DIRTY_RECURSIVELY(); -} - -void Sprite::setFlippedX(bool flippedX) -{ - if (_flippedX != flippedX) - { - _flippedX = flippedX; - setTextureRect(_rect, _rectRotated, _contentSize); - } -} - -bool Sprite::isFlippedX(void) const -{ - return _flippedX; -} - -void Sprite::setFlippedY(bool flippedY) -{ - if (_flippedY != flippedY) - { - _flippedY = flippedY; - setTextureRect(_rect, _rectRotated, _contentSize); - } -} - -bool Sprite::isFlippedY(void) const -{ - return _flippedY; -} - -// -// RGBA protocol -// - -void Sprite::updateColor(void) -{ - Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity ); - - // special opacity for premultiplied textures - if (_opacityModifyRGB) - { - color4.r *= _displayedOpacity/255.0f; - color4.g *= _displayedOpacity/255.0f; - color4.b *= _displayedOpacity/255.0f; - } - - _quad.bl.colors = color4; - _quad.br.colors = color4; - _quad.tl.colors = color4; - _quad.tr.colors = color4; - - // renders using batch node - if (_batchNode) - { - if (_atlasIndex != INDEX_NOT_INITIALIZED) - { - _textureAtlas->updateQuad(&_quad, _atlasIndex); - } - else - { - // no need to set it recursively - // update dirty_, don't update recursiveDirty_ - setDirty(true); - } - } - - // self render - // do nothing -} - -void Sprite::setOpacity(GLubyte opacity) -{ - NodeRGBA::setOpacity(opacity); - - updateColor(); -} - -void Sprite::setColor(const Color3B& color3) -{ - NodeRGBA::setColor(color3); - - updateColor(); -} - -void Sprite::setOpacityModifyRGB(bool modify) -{ - if (_opacityModifyRGB != modify) - { - _opacityModifyRGB = modify; - updateColor(); - } -} - -bool Sprite::isOpacityModifyRGB(void) const -{ - return _opacityModifyRGB; -} - -void Sprite::updateDisplayedColor(const Color3B& parentColor) -{ - NodeRGBA::updateDisplayedColor(parentColor); - - updateColor(); -} - -void Sprite::updateDisplayedOpacity(GLubyte opacity) -{ - NodeRGBA::updateDisplayedOpacity(opacity); - - updateColor(); -} - -// Frames - -void Sprite::setDisplayFrame(SpriteFrame *pNewFrame) -{ - _unflippedOffsetPositionFromCenter = pNewFrame->getOffset(); - - Texture2D *pNewTexture = pNewFrame->getTexture(); - // update texture before updating texture rect - if (pNewTexture != _texture) - { - setTexture(pNewTexture); - } - - // update rect - _rectRotated = pNewFrame->isRotated(); - setTextureRect(pNewFrame->getRect(), _rectRotated, pNewFrame->getOriginalSize()); -} - -void Sprite::setDisplayFrameWithAnimationName(const char *animationName, int frameIndex) -{ - CCASSERT(animationName, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be NULL"); - - Animation *a = AnimationCache::getInstance()->getAnimation(animationName); - - CCASSERT(a, "CCSprite#setDisplayFrameWithAnimationName: Frame not found"); - - AnimationFrame* frame = static_cast( a->getFrames()->getObjectAtIndex(frameIndex) ); - - CCASSERT(frame, "CCSprite#setDisplayFrame. Invalid frame"); - - setDisplayFrame(frame->getSpriteFrame()); -} - -bool Sprite::isFrameDisplayed(SpriteFrame *frame) const -{ - Rect r = frame->getRect(); - - return (r.equals(_rect) && - frame->getTexture()->getName() == _texture->getName() && - frame->getOffset().equals(_unflippedOffsetPositionFromCenter)); -} - -SpriteFrame* Sprite::getDisplayFrame() -{ - return SpriteFrame::createWithTexture(_texture, - CC_RECT_POINTS_TO_PIXELS(_rect), - _rectRotated, - CC_POINT_POINTS_TO_PIXELS(_unflippedOffsetPositionFromCenter), - CC_SIZE_POINTS_TO_PIXELS(_contentSize)); -} - -SpriteBatchNode* Sprite::getBatchNode() -{ - return _batchNode; -} - -void Sprite::setBatchNode(SpriteBatchNode *spriteBatchNode) -{ - _batchNode = spriteBatchNode; // weak reference - - // self render - if( ! _batchNode ) { - _atlasIndex = INDEX_NOT_INITIALIZED; - setTextureAtlas(NULL); - _recursiveDirty = false; - setDirty(false); - - float x1 = _offsetPosition.x; - float y1 = _offsetPosition.y; - float x2 = x1 + _rect.size.width; - float y2 = y1 + _rect.size.height; - _quad.bl.vertices = Vertex3F( x1, y1, 0 ); - _quad.br.vertices = Vertex3F( x2, y1, 0 ); - _quad.tl.vertices = Vertex3F( x1, y2, 0 ); - _quad.tr.vertices = Vertex3F( x2, y2, 0 ); - - } else { - - // using batch - _transformToBatch = AffineTransformIdentity; - setTextureAtlas(_batchNode->getTextureAtlas()); // weak ref - } -} - -// Texture protocol - -void Sprite::updateBlendFunc(void) -{ - CCASSERT(! _batchNode, "CCSprite: updateBlendFunc doesn't work when the sprite is rendered using a SpriteBatchNode"); - - // it is possible to have an untextured sprite - if (! _texture || ! _texture->hasPremultipliedAlpha()) - { - _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; - setOpacityModifyRGB(false); - } - else - { - _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; - setOpacityModifyRGB(true); - } -} - -/* - * This array is the data of a white image with 2 by 2 dimension. - * It's used for creating a default texture when sprite's texture is set to NULL. - * Supposing codes as follows: - * - * auto sp = new Sprite(); - * sp->init(); // Texture was set to NULL, in order to make opacity and color to work correctly, we need to create a 2x2 white texture. - * - * The test is in "TestCpp/SpriteTest/Sprite without texture". - */ -static unsigned char cc_2x2_white_image[] = { - // RGBA8888 - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF -}; - -#define CC_2x2_WHITE_IMAGE_KEY "/cc_2x2_white_image" - -void Sprite::setTexture(Texture2D *texture) -{ - // If batchnode, then texture id should be the same - CCASSERT(! _batchNode || texture->getName() == _batchNode->getTexture()->getName(), "CCSprite: Batched sprites should use the same texture as the batchnode"); - // accept texture==nil as argument - CCASSERT( !texture || dynamic_cast(texture), "setTexture expects a Texture2D. Invalid argument"); - - if (NULL == texture) - { - // Gets the texture by key firstly. - texture = TextureCache::getInstance()->getTextureForKey(CC_2x2_WHITE_IMAGE_KEY); - - // If texture wasn't in cache, create it from RAW data. - if (NULL == texture) - { - Image* image = new Image(); - bool isOK = image->initWithRawData(cc_2x2_white_image, sizeof(cc_2x2_white_image), 2, 2, 8); - CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully."); - - texture = TextureCache::getInstance()->addImage(image, CC_2x2_WHITE_IMAGE_KEY); - CC_SAFE_RELEASE(image); - } - } - - if (!_batchNode && _texture != texture) - { - CC_SAFE_RETAIN(texture); - CC_SAFE_RELEASE(_texture); - _texture = texture; - updateBlendFunc(); - } -} - -Texture2D* Sprite::getTexture(void) const -{ - return _texture; -} - -NS_CC_END From 0cffe5121965fa77bab543e27e44d1456c6090cd Mon Sep 17 00:00:00 2001 From: samuelhu Date: Fri, 18 Oct 2013 18:08:05 +0800 Subject: [PATCH 27/48] fix libluajia.a search path bug --- build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index bb2117f6df..18265b616b 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -af3544581a6508d57d3fe3b1f999cdc091bad543 \ No newline at end of file +1c487d29bdc2d80516e86e2ee93b1664e9f7df2f \ No newline at end of file From 54ac8f3537bdbbf9c421c94e6bcad50e8a4a770d Mon Sep 17 00:00:00 2001 From: garfield_ho Date: Sat, 19 Oct 2013 16:44:14 +0800 Subject: [PATCH 28/48] Add cc.RESOLUTION_POLICY to jsb_cocos2d.js,so it can use setDesignResolutionSize in cc.EGLView --- .../javascript/script/jsb_cocos2d.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cocos/scripting/javascript/script/jsb_cocos2d.js b/cocos/scripting/javascript/script/jsb_cocos2d.js index 80ddb0a066..6ed7e19cba 100644 --- a/cocos/scripting/javascript/script/jsb_cocos2d.js +++ b/cocos/scripting/javascript/script/jsb_cocos2d.js @@ -4,6 +4,30 @@ var cc = cc || {}; +cc.RESOLUTION_POLICY = { + // The entire application is visible in the specified area without trying to preserve the original aspect ratio. + // Distortion can occur, and the application may appear stretched or compressed. +EXACTFIT:0, + // The entire application fills the specified area, without distortion but possibly with some cropping, + // while maintaining the original aspect ratio of the application. +NOBORDER:1, + // The entire application is visible in the specified area without distortion while maintaining the original + // aspect ratio of the application. Borders can appear on two sides of the application. +SHOW_ALL:2, + // The application takes the height of the design resolution size and modifies the width of the internal + // canvas so that it fits the aspect ratio of the device + // no distortion will occur however you must make sure your application works on different + // aspect ratios +HEIGHT:3, + // The application takes the width of the design resolution size and modifies the height of the internal + // canvas so that it fits the aspect ratio of the device + // no distortion will occur however you must make sure your application works on different + // aspect ratios +WIDTH:4, + +UNKNOWN:5 +}; + cc.LANGUAGE_ENGLISH = 0; cc.LANGUAGE_CHINESE = 1; cc.LANGUAGE_FRENCH = 2; From 464d1598d23a6bf667ca8e3d1d18d128e9d8d93a Mon Sep 17 00:00:00 2001 From: garfield_ho Date: Sat, 19 Oct 2013 16:48:57 +0800 Subject: [PATCH 29/48] fixed bug of CCBReader that can not autoplaySequence --- cocos/editor-support/cocosbuilder/CCBReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/editor-support/cocosbuilder/CCBReader.cpp b/cocos/editor-support/cocosbuilder/CCBReader.cpp index d2f57ecf88..938c595f46 100644 --- a/cocos/editor-support/cocosbuilder/CCBReader.cpp +++ b/cocos/editor-support/cocosbuilder/CCBReader.cpp @@ -273,7 +273,7 @@ Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size & Dictionary* animationManagers = Dictionary::create(); Node *pNodeGraph = readFileWithCleanUp(true, animationManagers); - if (pNodeGraph && _actionManager->getAutoPlaySequenceId() != -1 && !_jsControlled) + if (pNodeGraph && _actionManager->getAutoPlaySequenceId() != -1) { // Auto play animations _actionManager->runAnimationsForSequenceIdTweenDuration(_actionManager->getAutoPlaySequenceId(), 0); From f11dba586a17cfd46ea183c081ec7bba7796d7ee Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Mon, 21 Oct 2013 22:09:21 +0800 Subject: [PATCH 30/48] issue #2905:modification vs-project for folder structure change --- build/cocos2d-win32.vc2012.sln | 151 +- cocos/2d/cocos2d.vcxproj | 19 +- cocos/audio/proj.win32/CocosDenshion.vcxproj | 10 +- .../javascript/bindings/XMLHTTPRequest.cpp | 847 --------- .../javascript/bindings/XMLHTTPRequest.h | 112 -- .../cocos2d_specifics.cpp.REMOVED.git-id | 2 +- .../javascript/bindings/cocos2d_specifics.hpp | 19 - .../bindings/js_bindings_ccbreader.cpp | 324 ---- .../bindings/js_bindings_ccbreader.h | 60 - ...s_chipmunk_auto_classes.cpp.REMOVED.git-id | 1 - .../js_bindings_chipmunk_auto_classes.h | 66 - ...dings_chipmunk_auto_classes_registration.h | 29 - ...ings_chipmunk_functions.cpp.REMOVED.git-id | 1 - .../bindings/js_bindings_chipmunk_functions.h | 292 --- ...bindings_chipmunk_functions_registration.h | 285 --- .../bindings/js_bindings_chipmunk_manual.cpp | 1624 ----------------- .../bindings/js_bindings_chipmunk_manual.h | 103 -- .../js_bindings_chipmunk_registration.cpp | 67 - .../js_bindings_chipmunk_registration.h | 31 - .../javascript/bindings/js_bindings_core.cpp | 2 +- .../bindings/js_bindings_system_functions.cpp | 75 - .../bindings/js_bindings_system_functions.h | 23 - ...s_bindings_system_functions_registration.h | 15 - .../js_bindings_system_registration.cpp | 62 - .../js_bindings_system_registration.h | 31 - .../jsb_cocos2dx_extension_manual.cpp | 1015 ----------- .../bindings/jsb_cocos2dx_extension_manual.h | 16 - .../javascript/bindings/jsb_websocket.cpp | 382 ---- .../javascript/bindings/jsb_websocket.h | 34 - .../bindings/proj.win32/libJSBinding.vcxproj | 53 +- .../proj.win32/libJSBinding.vcxproj.filters | 127 +- cocos/scripting/lua/bindings/liblua.vcxproj | 88 +- .../lua/bindings/liblua.vcxproj.filters | 226 +-- extensions/proj.win32/libExtensions.vcxproj | 248 +-- .../proj.win32/libExtensions.vcxproj.filters | 847 +-------- .../AssetsManagerTest/Classes/AppDelegate.cpp | 1 + .../proj.android/build_native.cmd | 7 +- .../proj.win32/AssetsManagerTest.vcxproj | 43 +- .../HelloCpp/proj.android/build_native.cmd | 5 +- .../Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj | 11 +- .../SimpleGame/proj.android/build_native.cmd | 5 +- .../Cpp/TestCpp/proj.android/build_native.cmd | 12 +- .../Cpp/TestCpp/proj.win32/TestCpp.vcxproj | 32 +- .../CocosDragonJS/Classes/AppDelegate.cpp | 10 +- .../proj.android/build_native.cmd | 7 +- .../proj.win32/CocosDragonJS.vcxproj | 56 +- .../CrystalCraze/Classes/AppDelegate.cpp | 10 +- .../proj.android/build_native.cmd | 7 +- .../proj.win32/CrystalCraze.vcxproj | 62 +- .../MoonWarriors/Classes/AppDelegate.cpp | 10 +- .../proj.android/build_native.cmd | 9 +- .../proj.win32/MoonWarriors.vcxproj | 69 +- .../TestJavascript/Classes/AppDelegate.cpp | 21 +- .../proj.android/build_native.cmd | 6 +- .../proj.win32/TestJavascript.vcxproj | 79 +- .../WatermelonWithMe/Classes/AppDelegate.cpp | 10 +- .../proj.android/build_native.cmd | 7 +- .../proj.win32/WatermelonWithMe.vcxproj | 65 +- .../HelloLua/proj.android/build_native.cmd | 7 +- .../Lua/HelloLua/proj.win32/HelloLua.vcxproj | 47 +- .../Lua/TestLua/proj.android/build_native.cmd | 14 +- .../TestLua/proj.win32/TestLua.win32.vcxproj | 54 +- .../proj.android/build_native.cmd | 5 +- .../proj.win32/HelloCpp.sln | 37 +- .../proj.win32/HelloCpp.vcxproj | 32 +- .../multi-platform-js/Classes/AppDelegate.cpp | 17 +- .../proj.android/build_native.cmd | 6 +- .../proj.win32/HelloJavascript.sln | 47 +- .../proj.win32/HelloJavascript.vcxproj | 54 +- .../proj.android/build_native.cmd | 7 +- .../proj.win32/HelloLua.sln | 51 +- .../proj.win32/HelloLua.vcxproj | 47 +- tools/tojs/cocos2dx_extension.ini | 22 +- tools/tojs/genbindings.sh | 6 + 74 files changed, 1056 insertions(+), 7228 deletions(-) delete mode 100644 cocos/scripting/javascript/bindings/XMLHTTPRequest.cpp delete mode 100644 cocos/scripting/javascript/bindings/XMLHTTPRequest.h delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_ccbreader.cpp delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_ccbreader.h delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_chipmunk_auto_classes.cpp.REMOVED.git-id delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_chipmunk_auto_classes.h delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_chipmunk_auto_classes_registration.h delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_chipmunk_functions.cpp.REMOVED.git-id delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_chipmunk_functions.h delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_chipmunk_functions_registration.h delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_chipmunk_manual.h delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_chipmunk_registration.cpp delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_chipmunk_registration.h delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_system_functions.cpp delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_system_functions.h delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_system_functions_registration.h delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_system_registration.cpp delete mode 100644 cocos/scripting/javascript/bindings/js_bindings_system_registration.h delete mode 100644 cocos/scripting/javascript/bindings/jsb_cocos2dx_extension_manual.cpp delete mode 100644 cocos/scripting/javascript/bindings/jsb_cocos2dx_extension_manual.h delete mode 100644 cocos/scripting/javascript/bindings/jsb_websocket.cpp delete mode 100644 cocos/scripting/javascript/bindings/jsb_websocket.h diff --git a/build/cocos2d-win32.vc2012.sln b/build/cocos2d-win32.vc2012.sln index d8c443ec6d..c1f930fa51 100644 --- a/build/cocos2d-win32.vc2012.sln +++ b/build/cocos2d-win32.vc2012.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio", "..\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" EndProject @@ -15,6 +15,54 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\extensi EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCpp", "..\samples\Cpp\TestCpp\proj.win32\TestCpp.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosBuilder", "..\cocos\editor-support\cocosbuilder\proj.win32\libCocosBuilder.vcxproj", "{811C0DAB-7B96-4BD3-A154-B7572B58E4AB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosStudio", "..\cocos\editor-support\cocostudio\proj.win32\libCocosStudio.vcxproj", "{B57CF53F-2E49-4031-9822-047CC0E6BDE2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGUI", "..\cocos\gui\proj.win32\libGUI.vcxproj", "{7E06E92C-537A-442B-9E4A-4761C84F8A1A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libNetwork", "..\cocos\network\proj.win32\libNetwork.vcxproj", "{DF2638C0-8128-4847-867C-6EAFE3DEE7B5}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos\editor-support\spine\proj.win32\libSpine.vcxproj", "{B7C2A162-DEC9-4418-972E-240AB3CBFCAE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetsManagerTest", "..\samples\Cpp\AssetsManagerTest\proj.win32\AssetsManagerTest.vcxproj", "{6D37505F-A890-441D-BD3F-A61E2C0469CE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "..\cocos\scripting\javascript\bindings\proj.win32\libJSBinding.vcxproj", "{39379840-825A-45A0-B363-C09FFEF864BD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestJavascript", "..\samples\Javascript\TestJavascript\proj.win32\TestJavascript.vcxproj", "{D0F06A44-A245-4D13-A498-0120C203B539}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libLocalStorage", "..\cocos\storage\local-storage\proj.win32\libLocalStorage.vcxproj", "{632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CocosDragonJS", "..\samples\Javascript\CocosDragonJS\proj.win32\CocosDragonJS.vcxproj", "{68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrystalCraze", "..\samples\Javascript\CrystalCraze\proj.win32\CrystalCraze.vcxproj", "{9A17D9A4-4B11-4E32-94F6-895FF4909EC5}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MoonWarriors", "..\samples\Javascript\MoonWarriors\proj.win32\MoonWarriors.vcxproj", "{1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WatermelonWithMe", "..\samples\Javascript\WatermelonWithMe\proj.win32\WatermelonWithMe.vcxproj", "{BE092D9E-95AE-4F86-84CE-F4519E4F3F15}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "..\cocos\scripting\lua\bindings\liblua.vcxproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "..\samples\Lua\HelloLua\proj.win32\HelloLua.vcxproj", "{13E55395-94A2-4CD9-BFC2-1A051F80C17D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLua", "..\samples\Lua\TestLua\proj.win32\TestLua.win32.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleGame", "..\samples\Cpp\SimpleGame\proj.win32\SimpleGame.vcxproj", "{E0E282F4-8487-452C-BFAB-CB960EB4D22F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForBuilder", "..\cocos\scripting\javascript\bindings\cocosbuilder\libJSBindingForBuilder.vcxproj", "{F9DA0FC1-651B-457B-962E-A4D61CEBF5FD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForStudio", "..\cocos\scripting\javascript\bindings\cocostudio\libJSBindingForStudio.vcxproj", "{79D34511-E54E-410A-8BBA-EF175AD6C695}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForNetwork", "..\cocos\scripting\javascript\bindings\network\libJSBindingForNetwork.vcxproj", "{3BEC13F5-E227-4D80-BC77-1C857F83BCFC}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForExtension", "..\cocos\scripting\javascript\bindings\extension\libJSBindingForExtension.vcxproj", "{625F7391-9A91-48A1-8CFC-79508C822637}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libJSBinding", "libJSBinding", "{10F98A57-B9A1-47DA-9FBA-12D328E72ED1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForChipmunk", "..\cocos\scripting\javascript\bindings\chipmunk\libJSBindingForChipmunk.vcxproj", "{21070E58-EEC6-4E16-8B4F-6D083DF55790}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForLocalStorage", "..\cocos\scripting\javascript\bindings\localstorage\libJSBindingForLocalStorage.vcxproj", "{68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -49,10 +97,111 @@ Global {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.Build.0 = Debug|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.ActiveCfg = Release|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.Build.0 = Release|Win32 + {811C0DAB-7B96-4BD3-A154-B7572B58E4AB}.Debug|Win32.ActiveCfg = Debug|Win32 + {811C0DAB-7B96-4BD3-A154-B7572B58E4AB}.Debug|Win32.Build.0 = Debug|Win32 + {811C0DAB-7B96-4BD3-A154-B7572B58E4AB}.Release|Win32.ActiveCfg = Release|Win32 + {811C0DAB-7B96-4BD3-A154-B7572B58E4AB}.Release|Win32.Build.0 = Release|Win32 + {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Debug|Win32.ActiveCfg = Debug|Win32 + {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Debug|Win32.Build.0 = Debug|Win32 + {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Release|Win32.ActiveCfg = Release|Win32 + {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Release|Win32.Build.0 = Release|Win32 + {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Debug|Win32.ActiveCfg = Debug|Win32 + {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Debug|Win32.Build.0 = Debug|Win32 + {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Release|Win32.ActiveCfg = Release|Win32 + {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Release|Win32.Build.0 = Release|Win32 + {DF2638C0-8128-4847-867C-6EAFE3DEE7B5}.Debug|Win32.ActiveCfg = Debug|Win32 + {DF2638C0-8128-4847-867C-6EAFE3DEE7B5}.Debug|Win32.Build.0 = Debug|Win32 + {DF2638C0-8128-4847-867C-6EAFE3DEE7B5}.Release|Win32.ActiveCfg = Release|Win32 + {DF2638C0-8128-4847-867C-6EAFE3DEE7B5}.Release|Win32.Build.0 = Release|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.ActiveCfg = Debug|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.Build.0 = Debug|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.ActiveCfg = Release|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.Build.0 = Release|Win32 + {6D37505F-A890-441D-BD3F-A61E2C0469CE}.Debug|Win32.ActiveCfg = Debug|Win32 + {6D37505F-A890-441D-BD3F-A61E2C0469CE}.Debug|Win32.Build.0 = Debug|Win32 + {6D37505F-A890-441D-BD3F-A61E2C0469CE}.Release|Win32.ActiveCfg = Release|Win32 + {6D37505F-A890-441D-BD3F-A61E2C0469CE}.Release|Win32.Build.0 = Release|Win32 + {39379840-825A-45A0-B363-C09FFEF864BD}.Debug|Win32.ActiveCfg = Debug|Win32 + {39379840-825A-45A0-B363-C09FFEF864BD}.Debug|Win32.Build.0 = Debug|Win32 + {39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.ActiveCfg = Release|Win32 + {39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.Build.0 = Release|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.ActiveCfg = Debug|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.Build.0 = Debug|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.ActiveCfg = Release|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.Build.0 = Release|Win32 + {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}.Debug|Win32.ActiveCfg = Debug|Win32 + {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}.Debug|Win32.Build.0 = Debug|Win32 + {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}.Release|Win32.ActiveCfg = Release|Win32 + {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}.Release|Win32.Build.0 = Release|Win32 + {68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}.Debug|Win32.ActiveCfg = Debug|Win32 + {68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}.Debug|Win32.Build.0 = Debug|Win32 + {68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}.Release|Win32.ActiveCfg = Release|Win32 + {68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}.Release|Win32.Build.0 = Release|Win32 + {9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Debug|Win32.ActiveCfg = Debug|Win32 + {9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Debug|Win32.Build.0 = Debug|Win32 + {9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Release|Win32.ActiveCfg = Release|Win32 + {9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Release|Win32.Build.0 = Release|Win32 + {1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}.Debug|Win32.ActiveCfg = Debug|Win32 + {1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}.Debug|Win32.Build.0 = Debug|Win32 + {1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}.Release|Win32.ActiveCfg = Release|Win32 + {1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}.Release|Win32.Build.0 = Release|Win32 + {BE092D9E-95AE-4F86-84CE-F4519E4F3F15}.Debug|Win32.ActiveCfg = Debug|Win32 + {BE092D9E-95AE-4F86-84CE-F4519E4F3F15}.Debug|Win32.Build.0 = Debug|Win32 + {BE092D9E-95AE-4F86-84CE-F4519E4F3F15}.Release|Win32.ActiveCfg = Release|Win32 + {BE092D9E-95AE-4F86-84CE-F4519E4F3F15}.Release|Win32.Build.0 = Release|Win32 + {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.ActiveCfg = Debug|Win32 + {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.Build.0 = Debug|Win32 + {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.ActiveCfg = Release|Win32 + {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.Build.0 = Release|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.ActiveCfg = Debug|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.Build.0 = Debug|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.ActiveCfg = Release|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.Build.0 = Release|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.ActiveCfg = Debug|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.Build.0 = Debug|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.ActiveCfg = Release|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.Build.0 = Release|Win32 + {E0E282F4-8487-452C-BFAB-CB960EB4D22F}.Debug|Win32.ActiveCfg = Debug|Win32 + {E0E282F4-8487-452C-BFAB-CB960EB4D22F}.Debug|Win32.Build.0 = Debug|Win32 + {E0E282F4-8487-452C-BFAB-CB960EB4D22F}.Release|Win32.ActiveCfg = Release|Win32 + {E0E282F4-8487-452C-BFAB-CB960EB4D22F}.Release|Win32.Build.0 = Release|Win32 + {F9DA0FC1-651B-457B-962E-A4D61CEBF5FD}.Debug|Win32.ActiveCfg = Debug|Win32 + {F9DA0FC1-651B-457B-962E-A4D61CEBF5FD}.Debug|Win32.Build.0 = Debug|Win32 + {F9DA0FC1-651B-457B-962E-A4D61CEBF5FD}.Release|Win32.ActiveCfg = Release|Win32 + {F9DA0FC1-651B-457B-962E-A4D61CEBF5FD}.Release|Win32.Build.0 = Release|Win32 + {79D34511-E54E-410A-8BBA-EF175AD6C695}.Debug|Win32.ActiveCfg = Debug|Win32 + {79D34511-E54E-410A-8BBA-EF175AD6C695}.Debug|Win32.Build.0 = Debug|Win32 + {79D34511-E54E-410A-8BBA-EF175AD6C695}.Release|Win32.ActiveCfg = Release|Win32 + {79D34511-E54E-410A-8BBA-EF175AD6C695}.Release|Win32.Build.0 = Release|Win32 + {3BEC13F5-E227-4D80-BC77-1C857F83BCFC}.Debug|Win32.ActiveCfg = Debug|Win32 + {3BEC13F5-E227-4D80-BC77-1C857F83BCFC}.Debug|Win32.Build.0 = Debug|Win32 + {3BEC13F5-E227-4D80-BC77-1C857F83BCFC}.Release|Win32.ActiveCfg = Release|Win32 + {3BEC13F5-E227-4D80-BC77-1C857F83BCFC}.Release|Win32.Build.0 = Release|Win32 + {625F7391-9A91-48A1-8CFC-79508C822637}.Debug|Win32.ActiveCfg = Debug|Win32 + {625F7391-9A91-48A1-8CFC-79508C822637}.Debug|Win32.Build.0 = Debug|Win32 + {625F7391-9A91-48A1-8CFC-79508C822637}.Release|Win32.ActiveCfg = Release|Win32 + {625F7391-9A91-48A1-8CFC-79508C822637}.Release|Win32.Build.0 = Release|Win32 + {21070E58-EEC6-4E16-8B4F-6D083DF55790}.Debug|Win32.ActiveCfg = Debug|Win32 + {21070E58-EEC6-4E16-8B4F-6D083DF55790}.Debug|Win32.Build.0 = Debug|Win32 + {21070E58-EEC6-4E16-8B4F-6D083DF55790}.Release|Win32.ActiveCfg = Release|Win32 + {21070E58-EEC6-4E16-8B4F-6D083DF55790}.Release|Win32.Build.0 = Release|Win32 + {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Debug|Win32.ActiveCfg = Debug|Win32 + {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Debug|Win32.Build.0 = Debug|Win32 + {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Release|Win32.ActiveCfg = Release|Win32 + {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {39379840-825A-45A0-B363-C09FFEF864BD} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} + {F9DA0FC1-651B-457B-962E-A4D61CEBF5FD} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} + {625F7391-9A91-48A1-8CFC-79508C822637} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} + {3BEC13F5-E227-4D80-BC77-1C857F83BCFC} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} + {79D34511-E54E-410A-8BBA-EF175AD6C695} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} + {21070E58-EEC6-4E16-8B4F-6D083DF55790} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} + {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} + EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} EndGlobalSection diff --git a/cocos/2d/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj index 0c421489f9..a7f030bb9f 100644 --- a/cocos/2d/cocos2d.vcxproj +++ b/cocos/2d/cocos2d.vcxproj @@ -36,9 +36,13 @@ + + + + @@ -69,7 +73,7 @@ Disabled - $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir);$(ProjectDir)..\physics;$(ProjectDir)..\..\external\glfw3\include\win32;$(ProjectDir)..\base;$(ProjectDir)..\..\external\unzip;$(ProjectDir)..\..\external\tinyxml2;$(ProjectDir)platform\win32;$(ProjectDir)..\..\external\win32-specific\icon\include;$(ProjectDir)..\..\external\win32-specific\zlib\include;$(ProjectDir)..\..\external\png\include\win32;$(ProjectDir)..\..\external\jpeg\include\win32;$(ProjectDir)..\..\external\tiff\include\win32;$(ProjectDir)..\..\external\webp\include\win32;$(ProjectDir)..\..\external\freetype2\include\win32;$(ProjectDir)..\..\external\win32-specific\gles\include\OGLES;$(ProjectDir)..\math\kazmath\include;$(ProjectDir)platform\third_party\common\etc;$(ProjectDir)..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -116,7 +120,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir)..;$(ProjectDir)..\platform\win32;$(ProjectDir)..\platform\third_party\win32\iconv;$(ProjectDir)..\platform\third_party\win32\zlib;$(ProjectDir)..\platform\third_party\win32\libpng;$(ProjectDir)..\platform\third_party\win32\libjpeg;$(ProjectDir)..\platform\third_party\win32\libtiff;$(ProjectDir)..\platform\third_party\win32\libwebp;$(ProjectDir)..\platform\third_party\win32\libfreetype2;$(ProjectDir)..\platform\third_party\win32\OGLES;..\include;$(ProjectDir)..\kazmath\include;$(ProjectDir)..\platform\third_party\common\etc;%(AdditionalIncludeDirectories) + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL @@ -128,7 +132,16 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\external*\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\freetype2\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\glfw3\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\curl\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\jpeg\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\png\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\tiff\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\webp\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\zlib\prebuilt\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\icon\prebuilt\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(OutDir)" diff --git a/cocos/audio/proj.win32/CocosDenshion.vcxproj b/cocos/audio/proj.win32/CocosDenshion.vcxproj index b59c65d98c..ecde64b8c3 100644 --- a/cocos/audio/proj.win32/CocosDenshion.vcxproj +++ b/cocos/audio/proj.win32/CocosDenshion.vcxproj @@ -11,7 +11,7 @@ - audio + libAudio {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} CocosDenshion.win32 Win32Proj @@ -36,9 +36,13 @@ + + + + @@ -65,7 +69,7 @@ Disabled - $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;$(ProjectDir)..\..\physics;$(ProjectDir)..\..\base;$(ProjectDir)..\..\2d;$(ProjectDir)..\..\2d\platform\win32;$(ProjectDir)..\..\math\kazmath\include;$(ProjectDir)..\..\..\external\glfw3\include\win32;$(ProjectDir)..\..\..\external\win32-specific\gles\include\OGLES;%(AdditionalIncludeDirectories) + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -89,7 +93,7 @@ - $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;"$(ProjectDir)..\..\cocos2dx";"$(ProjectDir)..\..\cocos2dx\include";"$(ProjectDir)..\..\cocos2dx\kazmath\include";"$(ProjectDir)..\..\cocos2dx\platform\win32";"$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES";%(AdditionalIncludeDirectories) + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL diff --git a/cocos/scripting/javascript/bindings/XMLHTTPRequest.cpp b/cocos/scripting/javascript/bindings/XMLHTTPRequest.cpp deleted file mode 100644 index cc7b72c586..0000000000 --- a/cocos/scripting/javascript/bindings/XMLHTTPRequest.cpp +++ /dev/null @@ -1,847 +0,0 @@ -// -// XMLHTTPRequest.cpp -// XMLHttpRequest -// -// Created by Zynga 2013 -// -// Heavy based on: https://github.com/funkaster/FakeWebGL/blob/master/FakeWebGL/WebGL/XMLHTTPRequest.cpp -// Copyright (c) 2012 Rolando Abarca. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -#include "XMLHTTPRequest.h" -#include - -using namespace std; - -//#pragma mark - MinXmlHttpRequest - -/** - * @brief Implementation for header retrieving. - * @param header - */ -void MinXmlHttpRequest::_gotHeader(string header) -{ - // Get Header and Set StatusText - // Split String into Tokens - char * cstr = new char [header.length()+1]; - - // check for colon. - unsigned found_header_field = header.find_first_of(":"); - - if (found_header_field != std::string::npos) - { - // Found a header field. - string http_field; - string http_value; - - http_field = header.substr(0,found_header_field); - http_value = header.substr(found_header_field+1, header.length()); - - // Get rid of all \n - if (!http_value.empty() && http_value[http_value.size() - 1] == '\n') { - http_value.erase(http_value.size() - 1); - } - - _httpHeader[http_field] = http_value; - - } - else - { - // Seems like we have the response Code! Parse it and check for it. - char * pch; - strcpy(cstr, header.c_str()); - - pch = strtok(cstr," "); - while (pch != NULL) - { - - stringstream ss; - string val; - - ss << pch; - val = ss.str(); - unsigned found_http = val.find("HTTP"); - - // Check for HTTP Header to set statusText - if (found_http != std::string::npos) { - - stringstream mystream; - - // Get Response Status - pch = strtok (NULL, " "); - mystream << pch; - - pch = strtok (NULL, " "); - mystream << " " << pch; - - _statusText = mystream.str(); - - } - - pch = strtok (NULL, " "); - } - } - - CC_SAFE_DELETE_ARRAY(cstr); -} - -/** - * @brief Set Request header for next call. - * @param field Name of the Header to be set. - * @param value Value of the Headerfield - */ -void MinXmlHttpRequest::_setRequestHeader(const char* field, const char* value) -{ - stringstream header_s; - stringstream value_s; - string header; - - map::iterator iter = _requestHeader.find(field); - - // Concatenate values when header exists. - if (iter != _requestHeader.end()) - { - value_s << iter->second << "," << value; - } - else - { - value_s << value; - } - - _requestHeader[field] = value_s.str(); -} - -/** - * @brief If headers has been set, pass them to curl. - * - */ -void MinXmlHttpRequest::_setHttpRequestHeader() -{ - std::vector header; - - for (auto it = _requestHeader.begin(); it != _requestHeader.end(); ++it) - { - const char* first = it->first.c_str(); - const char* second = it->second.c_str(); - size_t len = sizeof(char) * (strlen(first) + 3 + strlen(second)); - char* test = (char*) malloc(len); - memset(test, 0,len); - - strcpy(test, first); - strcpy(test + strlen(first) , ": "); - strcpy(test + strlen(first) + 2, second); - - header.push_back(test); - - free(test); - - } - - if (!header.empty()) - { - _httpRequest->setHeaders(header); - } - -} - -/** - * @brief Callback for HTTPRequest. Handles the response and invokes Callback. - * @param sender Object which initialized callback - * @param respone Response object - */ -void MinXmlHttpRequest::handle_requestResponse(network::HttpClient *sender, network::HttpResponse *response) -{ - if (0 != strlen(response->getHttpRequest()->getTag())) - { - CCLOG("%s completed", response->getHttpRequest()->getTag()); - } - - int statusCode = response->getResponseCode(); - char statusString[64] = {}; - sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag()); - - if (!response->isSucceed()) - { - CCLOG("response failed"); - CCLOG("error buffer: %s", response->getErrorBuffer()); - return; - } - - // set header - std::vector *headers = response->getResponseHeader(); - - char* concatHeader = (char*) malloc(headers->size() + 1); - std::string header(headers->begin(), headers->end()); - strcpy(concatHeader, header.c_str()); - - std::istringstream stream(concatHeader); - std::string line; - while(std::getline(stream, line)) { - _gotHeader(line); - } - - /** get the response data **/ - std::vector *buffer = response->getResponseData(); - char* concatenated = (char*) malloc(buffer->size() + 1); - std::string s2(buffer->begin(), buffer->end()); - - strcpy(concatenated, s2.c_str()); - - if (statusCode == 200) - { - //Succeeded - _status = 200; - _readyState = DONE; - _data << concatenated; - _dataSize = buffer->size(); - } - else - { - _status = 0; - } - // Free Memory. - free((void*) concatHeader); - free((void*) concatenated); - - js_proxy_t * p; - void* ptr = (void*)this; - p = jsb_get_native_proxy(ptr); - - if(p) - { - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - - if (_onreadystateCallback) - { - //JS_IsExceptionPending(cx) && JS_ReportPendingException(cx); - jsval fval = OBJECT_TO_JSVAL(_onreadystateCallback); - jsval out; - JS_CallFunctionValue(cx, NULL, fval, 0, NULL, &out); - } - - } - -} -/** - * @brief Send out request and fire callback when done. - * @param cx Javascript context - */ -void MinXmlHttpRequest::_sendRequest(JSContext *cx) -{ - _httpRequest->setResponseCallback(this, httpresponse_selector(MinXmlHttpRequest::handle_requestResponse)); - network::HttpClient::getInstance()->send(_httpRequest); - _httpRequest->release(); -} - -/** - * @brief Constructor initializes cchttprequest and stuff - * - */ -MinXmlHttpRequest::MinXmlHttpRequest() : _onreadystateCallback(NULL), _isNetwork(true) -{ - _httpHeader.clear(); - _requestHeader.clear(); - _withCredentialsValue = true; - _cx = ScriptingCore::getInstance()->getGlobalContext(); - _httpRequest = new network::HttpRequest(); -} - -/** - * @brief Destructor cleans up _httpRequest and stuff - * - */ -MinXmlHttpRequest::~MinXmlHttpRequest() -{ - _httpHeader.clear(); - _requestHeader.clear(); - - if (_onreadystateCallback != NULL) - { - JS_RemoveObjectRoot(_cx, &_onreadystateCallback); - } - - if (_httpRequest) - { - // We don't need to release _httpRequest here since it will be released in the http callback. -// _httpRequest->release(); - } - -} - -/** - * @brief Initialize Object and needed properties. - * - */ -JS_BINDED_CLASS_GLUE_IMPL(MinXmlHttpRequest); - -/** - * @brief Implementation for the Javascript Constructor - * - */ -JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) -{ - MinXmlHttpRequest* req = new MinXmlHttpRequest(); - req->autorelease(); - - js_proxy_t *p; - jsval out; - - JSObject *obj = JS_NewObject(cx, &MinXmlHttpRequest::js_class, MinXmlHttpRequest::js_proto, MinXmlHttpRequest::js_parent); - - if (obj) { - JS_SetPrivate(obj, req); - out = OBJECT_TO_JSVAL(obj); - } - - JS_SET_RVAL(cx, vp, out); - p =jsb_new_proxy(req, obj); - - JS_AddNamedObjectRoot(cx, &p->obj, "XMLHttpRequest"); - return JS_TRUE; -} - -/** - * @brief get Callback function for Javascript - * - */ -JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, onreadystatechange) -{ - if (_onreadystateCallback) - { - JSString *tmpstr = JS_NewStringCopyZ(cx, "1"); - jsval tmpval = STRING_TO_JSVAL(tmpstr); - JS_SetProperty(cx, _onreadystateCallback, "readyState", &tmpval); - - jsval out = OBJECT_TO_JSVAL(_onreadystateCallback); - vp.set(out); - - } - else - { - vp.set(JSVAL_NULL); - } - return JS_TRUE; -} - -/** - * @brief Set Callback function coming from Javascript - * - * - */ -JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, onreadystatechange) -{ - jsval callback = vp.get(); - if (callback != JSVAL_NULL) - { - _onreadystateCallback = JSVAL_TO_OBJECT(callback); - JS_AddNamedObjectRoot(cx, &_onreadystateCallback, "onreadystateCallback"); - } - return JS_TRUE; -} - -/** - * @brief upload getter - TODO - * - * Placeholder for further implementations!! - */ -JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, upload) -{ - vp.set(JSVAL_NULL); - return JS_TRUE; -} - -/** - * @brief upload setter - TODO - * - * Placeholder for further implementations - */ -JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, upload) -{ - vp.set(JSVAL_NULL); - return JS_TRUE; -} - -/** - * @brief timeout getter - TODO - * - * Placeholder for further implementations - */ -JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, timeout) -{ - vp.set(INT_TO_JSVAL(_timeout)); - return JS_TRUE; -} - -/** - * @brief timeout setter - TODO - * - * Placeholder for further implementations - */ -JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, timeout) -{ - jsval timeout_ms = vp.get(); - - _timeout = JSVAL_TO_INT(timeout_ms); - //curl_easy_setopt(curlHandle, CURLOPT_CONNECTTIMEOUT_MS, timeout); - return JS_TRUE; - -} - -/** - * @brief get response type for actual XHR - * - * - */ -JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseType) -{ - JSString* str = JS_NewStringCopyN(cx, "", 0); - vp.set(STRING_TO_JSVAL(str)); - return JS_TRUE; -} - -/** - * @brief responseXML getter - TODO - * - * Placeholder for further implementation. - */ -JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseXML) -{ - vp.set(JSVAL_NULL); - return JS_TRUE; -} - -/** - * @brief set response type for actual XHR - * - * - */ -JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, responseType) -{ - jsval type = vp.get(); - if (type.isString()) { - JSString* str = type.toString(); - JSBool equal; - - JS_StringEqualsAscii(cx, str, "text", &equal); - if (equal) - { - _responseType = ResponseType::STRING; - return JS_TRUE; - } - - JS_StringEqualsAscii(cx, str, "arraybuffer", &equal); - if (equal) - { - _responseType = ResponseType::ARRAY_BUFFER; - return JS_TRUE; - } - - JS_StringEqualsAscii(cx, str, "json", &equal); - if (equal) - { - _responseType = ResponseType::JSON; - return JS_TRUE; - } - // ignore the rest of the response types for now - return JS_TRUE; - } - JS_ReportError(cx, "Invalid response type"); - return JS_FALSE; -} - -/** - * @brief get readyState for actual XHR - * - * - */ -JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, readyState) -{ - vp.set(INT_TO_JSVAL(_readyState)); - return JS_TRUE; -} - -/** - * @brief get status for actual XHR - * - * - */ -JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, status) -{ - vp.set(INT_TO_JSVAL(_status)); - return JS_TRUE; -} - -/** - * @brief get statusText for actual XHR - * - * - */ -JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, statusText) -{ - jsval strVal = std_string_to_jsval(cx, _statusText); - - if (strVal != JSVAL_NULL) - { - vp.set(strVal); - return JS_TRUE; - } - else - { - JS_ReportError(cx, "Error trying to create JSString from data"); - return JS_FALSE; - } -} - -/** - * @brief get value of withCredentials property. - * - */ -JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, withCredentials) -{ - vp.set(BOOLEAN_TO_JSVAL(_withCredentialsValue)); - return JS_TRUE; -} - -/** - * withCredentials - set value of withCredentials property. - * - */ -JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, withCredentials) -{ - jsval credential = vp.get(); - if (credential != JSVAL_NULL) - { - _withCredentialsValue = JSVAL_TO_BOOLEAN(credential); - } - - return JS_TRUE; -} - -/** - * @brief get (raw) responseText - * - */ -JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseText) -{ - jsval strVal = std_string_to_jsval(cx, _data.str()); - - if (strVal != JSVAL_NULL) - { - vp.set(strVal); - //JS_ReportError(cx, "Result: %s", data.str().c_str()); - return JS_TRUE; - } else { - JS_ReportError(cx, "Error trying to create JSString from data"); - return JS_FALSE; - } -} - -/** - * @brief get response of latest XHR - * - */ -JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, response) -{ - - if (_responseType == ResponseType::JSON) - { - jsval outVal; - - jsval strVal = std_string_to_jsval(cx, _data.str()); - if (JS_ParseJSON(cx, JS_GetStringCharsZ(cx, JSVAL_TO_STRING(strVal)), _dataSize, &outVal)) - { - vp.set(outVal); - return JS_TRUE; - } - } - else if (_responseType == ResponseType::ARRAY_BUFFER) - { - JSObject* tmp = JS_NewArrayBuffer(cx, _dataSize); - uint8_t* tmpData = JS_GetArrayBufferData(tmp); - _data.read((char*)tmpData, _dataSize); - jsval outVal = OBJECT_TO_JSVAL(tmp); - - vp.set(outVal); - return JS_TRUE; - } - // by default, return text - return _js_get_responseText(cx, id, vp); -} - -/** - * @brief initialize new xhr. - * - */ -JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, open) -{ - if (argc >= 2) - { - jsval* argv = JS_ARGV(cx, vp); - const char* method; - const char* urlstr; - JSBool async = true; - JSString* jsMethod = JS_ValueToString(cx, argv[0]); - JSString* jsURL = JS_ValueToString(cx, argv[1]); - - if (argc > 2) { - JS_ValueToBoolean(cx, argv[2], &async); - } - - JSStringWrapper w1(jsMethod); - JSStringWrapper w2(jsURL); - method = w1; - urlstr = w2; - - _url = urlstr; - _meth = method; - _readyState = 1; - _isAsync = async; - - if (_url.length() > 5 && _url.compare(_url.length() - 5, 5, ".json") == 0) - { - _responseType = ResponseType::JSON; - } - - if (_meth.compare("post") == 0 || _meth.compare("POST") == 0) - { - _httpRequest->setRequestType(network::HttpRequest::Type::POST); - } - else - { - _httpRequest->setRequestType(network::HttpRequest::Type::GET); - } - - _httpRequest->setUrl(_url.c_str()); - - _isNetwork = true; - _readyState = OPENED; - - return JS_TRUE; - } - - JS_ReportError(cx, "invalid call: %s", __FUNCTION__); - return JS_FALSE; - -} - -/** - * @brief send xhr - * - */ -JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, send) -{ - JSString *str = NULL; - std::string data; - - // Clean up header map. New request, new headers! - _httpHeader.clear(); - - if (argc == 1) - { - if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &str)) - { - return JS_FALSE; - } - JSStringWrapper strWrap(str); - data = strWrap.get(); - } - - - if (data.length() > 0 && (_meth.compare("post") == 0 || _meth.compare("POST") == 0)) - { - _httpRequest->setRequestData(data.c_str(), data.length()); - } - - _setHttpRequestHeader(); - _sendRequest(cx); - - return JS_TRUE; -} - -/** - * @brief abort function Placeholder! - * - */ -JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, abort) -{ - return JS_TRUE; -} - -/** - * @brief Get all response headers as a string - * - */ -JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getAllResponseHeaders) -{ - stringstream responseheaders; - string responseheader; - - for (auto it = _httpHeader.begin(); it != _httpHeader.end(); ++it) - { - responseheaders << it->first << ": " << it->second << "\n"; - } - - responseheader = responseheaders.str(); - - jsval strVal = std_string_to_jsval(cx, responseheader); - if (strVal != JSVAL_NULL) - { - JS_SET_RVAL(cx, vp, strVal); - return JS_TRUE; - } - else - { - JS_ReportError(cx, "Error trying to create JSString from data"); - return JS_FALSE; - } - - return JS_TRUE; -} - -/** - * @brief Get all response headers as a string - * - */ -JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getResponseHeader) -{ - JSString *header_value; - - if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &header_value)) { - return JS_FALSE; - }; - - std::string data; - JSStringWrapper strWrap(header_value); - data = strWrap.get(); - - stringstream streamdata; - - streamdata << data; - - string value = streamdata.str(); - - auto iter = _httpHeader.find(value); - if (iter != _httpHeader.end()) - { - jsval js_ret_val = std_string_to_jsval(cx, iter->second); - JS_SET_RVAL(cx, vp, js_ret_val); - return JS_TRUE; - } - else { - JS_SET_RVAL(cx, vp, JSVAL_NULL); - return JS_TRUE; - } -} - -/** - * @brief Set the given Fields to request Header. - * - * - */ -JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, setRequestHeader) -{ - if (argc >= 2) - { - jsval* argv = JS_ARGV(cx, vp); - const char* field; - const char* value; - - JSString* jsField = JS_ValueToString(cx, argv[0]); - JSString* jsValue = JS_ValueToString(cx, argv[1]); - - JSStringWrapper w1(jsField); - JSStringWrapper w2(jsValue); - field = w1; - value = w2; - - // Populate the request_header map. - _setRequestHeader(field, value); - - return JS_TRUE; - } - - return JS_FALSE; - -} - -/** - * @brief overrideMimeType function - TODO! - * - * Just a placeholder for further implementations. - */ -JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, overrideMimeType) -{ - return JS_TRUE; -} - -/** - * @brief destructor for Javascript - * - */ -static void basic_object_finalize(JSFreeOp *freeOp, JSObject *obj) -{ - CCLOG("basic_object_finalize %p ...", obj); -} - -/** - * @brief Register XMLHttpRequest to be usable in JS and add properties and Mehtods. - * @param cx Global Spidermonkey JS Context. - * @param global Global Spidermonkey Javascript object. - */ -void MinXmlHttpRequest::_js_register(JSContext *cx, JSObject *global) -{ - JSClass js_class = { - "XMLHttpRequest", JSCLASS_HAS_PRIVATE, JS_PropertyStub, - JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, - JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, - basic_object_finalize, JSCLASS_NO_OPTIONAL_MEMBERS - }; - - MinXmlHttpRequest::js_class = js_class; - static JSPropertySpec props[] = { - JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, onreadystatechange), - JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, responseType), - JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, withCredentials), - JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, readyState), - JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, status), - JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, statusText), - JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, responseText), - JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, responseXML), - JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, response), - {0, 0, 0, 0, 0} - }; - - static JSFunctionSpec funcs[] = { - JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, open), - JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, abort), - JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, send), - JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, setRequestHeader), - JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getAllResponseHeaders), - JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getResponseHeader), - JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, overrideMimeType), - JS_FS_END - }; - - MinXmlHttpRequest::js_parent = NULL; - MinXmlHttpRequest::js_proto = JS_InitClass(cx, global, NULL, &MinXmlHttpRequest::js_class , MinXmlHttpRequest::_js_constructor, 0, props, funcs, NULL, NULL); - -} - diff --git a/cocos/scripting/javascript/bindings/XMLHTTPRequest.h b/cocos/scripting/javascript/bindings/XMLHTTPRequest.h deleted file mode 100644 index 861e0a2536..0000000000 --- a/cocos/scripting/javascript/bindings/XMLHTTPRequest.h +++ /dev/null @@ -1,112 +0,0 @@ -// -// XMLHTTPRequest.h -// XMLHttpRequest -// -// Created by Zynga 2013 -// -// Heavy based on: https://github.com/funkaster/FakeWebGL/blob/master/FakeWebGL/WebGL/XMLHTTPRequest.h -// Copyright (c) 2012 Rolando Abarca. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -#ifndef __FAKE_XMLHTTPREQUEST_H__ -#define __FAKE_XMLHTTPREQUEST_H__ - -#include "network/HttpClient.h" -#include "js_bindings_config.h" -#include "ScriptingCore.h" -#include "jstypes.h" -#include "jsapi.h" -#include "jsfriendapi.h" -#include "jsb_helper.h" - -class MinXmlHttpRequest : public cocos2d::Object -{ -public: - enum class ResponseType - { - STRING, - ARRAY_BUFFER, - BLOB, - DOCUMENT, - JSON - }; - - // Ready States (http://www.w3.org/TR/XMLHttpRequest/#interface-xmlhttprequest) - static const unsigned short UNSENT = 0; - static const unsigned short OPENED = 1; - static const unsigned short HEADERS_RECEIVED = 2; - static const unsigned short LOADING = 3; - static const unsigned short DONE = 4; - - MinXmlHttpRequest(); - ~MinXmlHttpRequest(); - - JS_BINDED_CLASS_GLUE(MinXmlHttpRequest); - JS_BINDED_CONSTRUCTOR(MinXmlHttpRequest); - JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onreadystatechange); - JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, responseType); - JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, withCredentials); - JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, upload); - JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, timeout); - JS_BINDED_PROP_GET(MinXmlHttpRequest, readyState); - JS_BINDED_PROP_GET(MinXmlHttpRequest, status); - JS_BINDED_PROP_GET(MinXmlHttpRequest, statusText); - JS_BINDED_PROP_GET(MinXmlHttpRequest, responseText); - JS_BINDED_PROP_GET(MinXmlHttpRequest, response); - JS_BINDED_PROP_GET(MinXmlHttpRequest, responseXML); - JS_BINDED_FUNC(MinXmlHttpRequest, open); - JS_BINDED_FUNC(MinXmlHttpRequest, send); - JS_BINDED_FUNC(MinXmlHttpRequest, abort); - JS_BINDED_FUNC(MinXmlHttpRequest, getAllResponseHeaders); - JS_BINDED_FUNC(MinXmlHttpRequest, getResponseHeader); - JS_BINDED_FUNC(MinXmlHttpRequest, setRequestHeader); - JS_BINDED_FUNC(MinXmlHttpRequest, overrideMimeType); - - void handle_requestResponse(network::HttpClient *sender, network::HttpResponse *response); - - -private: - void _gotHeader(std::string header); - void _setRequestHeader(const char* field, const char* value); - void _setHttpRequestHeader(); - void _sendRequest(JSContext *cx); - - std::string _url; - JSContext* _cx; - std::string _meth; - std::string _type; - std::stringstream _data; - size_t _dataSize; - JSObject* _onreadystateCallback; - int _readyState; - int _status; - std::string _statusText; - ResponseType _responseType; - unsigned _timeout; - bool _isAsync; - network::HttpRequest* _httpRequest; - bool _isNetwork; - bool _withCredentialsValue; - std::map _httpHeader; - std::map _requestHeader; -}; - -#endif diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index b8cda9a498..082d55b8bd 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -bf994ad1fc8ac1044957d83708f7848e99ca59e6 \ No newline at end of file +33fef8c7bc7006ad55c27fd0ed9c9dd2c8064079 \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp b/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp index 1072cc8064..2981a726a8 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp @@ -101,25 +101,6 @@ protected: jsval _extraData; }; - -class JSCCBAnimationWrapper: public JSCallbackWrapper { -public: - JSCCBAnimationWrapper() {} - virtual ~JSCCBAnimationWrapper() {} - - void animationCompleteCallback() { - - JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - jsval retval = JSVAL_NULL; - - if(!JSVAL_IS_VOID(_jsCallback) && !JSVAL_IS_VOID(_jsThisObj)) { - JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(_jsThisObj), _jsCallback, 0, NULL, &retval); - } - } - -}; - - class JSCallFuncWrapper: public JSCallbackWrapper { public: JSCallFuncWrapper() {} diff --git a/cocos/scripting/javascript/bindings/js_bindings_ccbreader.cpp b/cocos/scripting/javascript/bindings/js_bindings_ccbreader.cpp deleted file mode 100644 index 733ac47b45..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_ccbreader.cpp +++ /dev/null @@ -1,324 +0,0 @@ -// -// js_bindings_ccbreader.cpp -// watermelon -// -// Created by Rohan Kuruvilla on 14/08/2012. -// -// - -#include "js_bindings_ccbreader.h" -#include "ScriptingCore.h" -#include "js_bindings_config.h" - -USING_NS_CC; -USING_NS_CC_EXT; -using namespace cocosbuilder; - -static void removeSelector(std::string &str) { - size_t found; - found = str.find(":"); - while (found!=std::string::npos){ - str.replace(found, found+1, ""); - found = str.find(":"); - } -} - -SEL_MenuHandler CCBScriptCallbackProxy::onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, - const char * pSelectorName) { - this->callBackProp = pSelectorName; - removeSelector(this->callBackProp); - return menu_selector(CCBScriptCallbackProxy::menuItemCallback); -} - -Control::Handler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(Object * pTarget, - const char * pSelectorName) { - - this->callBackProp = pSelectorName; - removeSelector(this->callBackProp); - return cccontrol_selector(CCBScriptCallbackProxy::controlCallback); -} - -bool CCBScriptCallbackProxy::onAssignCCBMemberVariable(Object * pTarget, - const char * pMemberVariableName, - Node * pNode) { - return true; -} - -void CCBScriptCallbackProxy::onNodeLoaded(Node * pNode, - NodeLoader * pNodeLoader) {} - -CCBSelectorResolver * CCBScriptCallbackProxy::createNew() { - CCBScriptCallbackProxy * ret = new CCBScriptCallbackProxy(); - ret->setJSOwner(this->owner); - return dynamic_cast(ret); -} - -void CCBScriptCallbackProxy::menuItemCallback(Object *pSender) { - ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() ); -} - -void CCBScriptCallbackProxy::controlCallback(Object *pSender, Control::EventType event) { - ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() ); -} - -void CCBScriptCallbackProxy::setCallbackProperty(const char *prop) { - callBackProp = prop; -} - -void CCBScriptCallbackProxy::setJSOwner(jsval ownr) { - owner = ownr; -} - -jsval CCBScriptCallbackProxy::getJSOwner() { - return owner; -} - -JSBool js_cocos2dx_CCBAnimationManager_animationCompleteCallback(JSContext *cx, uint32_t argc, jsval *vp) -{ - if (argc >= 1) { - jsval *argv = JS_ARGV(cx, vp); - - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocosbuilder::CCBAnimationManager *node = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); - - JSCCBAnimationWrapper *tmpCobj = new JSCCBAnimationWrapper(); - tmpCobj->autorelease(); - - tmpCobj->setJSCallbackThis(argv[0]); - if(argc >= 2) { - tmpCobj->setJSCallbackFunc(argv[1]); - } - - node->setAnimationCompletedCallback(tmpCobj, callfunc_selector(JSCCBAnimationWrapper::animationCompleteCallback)); - - JS_SetReservedSlot(proxy->obj, 0, argv[0]); - JS_SetReservedSlot(proxy->obj, 1, argv[1]); - return JS_TRUE; - } - return JS_FALSE; -} - -JSBool js_cocos2dx_CCBReader_readNodeGraphFromFile(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - JSBool ok = JS_TRUE; - JSObject *obj; - cocosbuilder::CCBReader* cobj; - obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, cobj) - - if (argc == 2) { - const char* arg0; - std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - cocos2d::Object* arg1; - do { - js_proxy_t *proxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); - proxy = jsb_get_js_proxy(tmpObj); - arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, arg1) - } while (0); - - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - - cocos2d::Node* ret = cobj->readNodeGraphFromFile(arg0, arg1); - jsval jsret; do { - if (ret) { - js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); - jsret = OBJECT_TO_JSVAL(proxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return JS_TRUE; - } - if (argc == 1) { - const char* arg0; - std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - - cocos2d::Node* ret = cobj->readNodeGraphFromFile(arg0); - jsval jsret; do { - if (ret) { - js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); - jsret = OBJECT_TO_JSVAL(proxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return JS_TRUE; - } - if (argc == 3) { - const char* arg0; - std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - cocos2d::Object* arg1; - do { - js_proxy_t *proxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); - proxy = jsb_get_js_proxy(tmpObj); - arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, arg1) - } while (0); - cocos2d::Size arg2; - ok &= jsval_to_ccsize(cx, argv[2], &arg2); - - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - - cocos2d::Node* ret = cobj->readNodeGraphFromFile(arg0, arg1, arg2); - jsval jsret; do { - if (ret) { - js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); - jsret = OBJECT_TO_JSVAL(proxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return JS_TRUE; - } - return JS_FALSE; -} - -JSBool js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - JSBool ok = JS_TRUE; - JSObject *obj; - cocosbuilder::CCBReader* cobj; - obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, cobj) - - if (argc == 2) { - const char* arg0; - std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - cocos2d::Object* arg1; - do { - js_proxy_t *proxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); - proxy = jsb_get_js_proxy(tmpObj); - arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, arg1) - } while (0); - - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - - cocos2d::Scene* ret = cobj->createSceneWithNodeGraphFromFile(arg0, arg1); - jsval jsret; do { - if (ret) { - js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); - jsret = OBJECT_TO_JSVAL(proxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return JS_TRUE; - } - if (argc == 1) { - const char* arg0; - std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - - cocos2d::Scene* ret = cobj->createSceneWithNodeGraphFromFile(arg0); - jsval jsret; do { - if (ret) { - js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); - jsret = OBJECT_TO_JSVAL(proxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return JS_TRUE; - } - if (argc == 3) { - const char* arg0; - std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - cocos2d::Object* arg1; - do { - js_proxy_t *proxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); - proxy = jsb_get_js_proxy(tmpObj); - arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, arg1) - } while (0); - cocos2d::Size arg2; - ok &= jsval_to_ccsize(cx, argv[2], &arg2); - - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - - cocos2d::Scene* ret = cobj->createSceneWithNodeGraphFromFile(arg0, arg1, arg2); - jsval jsret; do { - if (ret) { - js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); - jsret = OBJECT_TO_JSVAL(proxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return JS_TRUE; - } - - return JS_FALSE; -} - - -JSBool js_CocosBuilder_create(JSContext *cx, uint32_t argc, jsval *vp) -{ - - NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::getInstance(); - - ccNodeLoaderLibrary->registerNodeLoader("", JSLayerLoader::loader()); - - CCBReader * ret = new CCBReader(ccNodeLoaderLibrary); - ret->autorelease(); - - jsval jsret; - if (ret) { - js_proxy_t *proxy = jsb_get_native_proxy(ret); - if (proxy) { - jsret = OBJECT_TO_JSVAL(proxy->obj); - } else { - // create a new js obj of that class - proxy = js_get_or_create_proxy(cx, ret); - jsret = OBJECT_TO_JSVAL(proxy->obj); - } - } else { - jsret = JSVAL_NULL; - } - JS_SET_RVAL(cx, vp, jsret); - return JS_TRUE; - -} - -extern JSObject* jsb_CCBReader_prototype; -extern JSObject* jsb_CCBAnimationManager_prototype; - -void register_CCBuilderReader(JSContext *cx, JSObject *obj) { - jsval nsval; - JSObject *ns; - JS_GetProperty(cx, obj, "cc", &nsval); - if (nsval == JSVAL_VOID) { - ns = JS_NewObject(cx, NULL, NULL, NULL); - nsval = OBJECT_TO_JSVAL(ns); - JS_SetProperty(cx, obj, "cc", &nsval); - } else { - JS_ValueToObject(cx, nsval, &ns); - } - obj = ns; - - JSObject *tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, obj, "(function () { return cc._Reader; })()")); - JS_DefineFunction(cx, tmpObj, "create", js_CocosBuilder_create, 2, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, tmpObj, "loadScene", js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT); - - JS_DefineFunction(cx, jsb_CCBReader_prototype, "load", js_cocos2dx_CCBReader_readNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, jsb_CCBAnimationManager_prototype, "setCompletedAnimationCallback", js_cocos2dx_CCBAnimationManager_animationCompleteCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT); -} diff --git a/cocos/scripting/javascript/bindings/js_bindings_ccbreader.h b/cocos/scripting/javascript/bindings/js_bindings_ccbreader.h deleted file mode 100644 index 8bcdabd044..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_ccbreader.h +++ /dev/null @@ -1,60 +0,0 @@ -// -// js_bindings_ccbreader.h -// watermelon -// -// Created by Rohan Kuruvilla on 14/08/2012. -// -// -#ifndef __JS_BINDINGS_CCBREADER_H__ -#define __JS_BINDINGS_CCBREADER_H__ - -#include "jsapi.h" -#include "cocos2d_specifics.hpp" -#include "cocosbuilder/CocosBuilder.h" - -class CCBScriptCallbackProxy: public cocos2d::Layer -, public cocosbuilder::CCBSelectorResolver -, public cocosbuilder::CCBMemberVariableAssigner { - - std::string callBackProp; - jsval owner; - -public: - - - CCBScriptCallbackProxy () {} - virtual ~CCBScriptCallbackProxy() {} - - CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(CCBScriptCallbackProxy, create); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, - const char * pSelectorName); - - virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, - const char * pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, - cocos2d::Node * pNode); - virtual void onNodeLoaded(cocos2d::Node * pNode, - cocosbuilder::NodeLoader * pNodeLoader); - - virtual CCBSelectorResolver * createNew(); - void menuItemCallback(Object *pSender); - void controlCallback(Object *pSender, cocos2d::extension::Control::EventType event); - void setCallbackProperty(const char *prop); - void setJSOwner(jsval ownr); - jsval getJSOwner(); -}; - - -class JSLayerLoader : public cocosbuilder::LayerLoader { -public: - CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(JSLayerLoader, loader); - -protected: - CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCBScriptCallbackProxy); -}; - -void register_CCBuilderReader(JSContext *cx, JSObject *global); -JSBool js_CocosBuilder_Run(JSContext *cx, uint32_t argc, jsval *vp); - -#endif /* __JS_BINDINGS_CCBREADER_H__ */ - diff --git a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_auto_classes.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/js_bindings_chipmunk_auto_classes.cpp.REMOVED.git-id deleted file mode 100644 index c8c345c32c..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_auto_classes.cpp.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -6558be4f421be9227dc4fabf1b682d479825bd18 \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_auto_classes.h b/cocos/scripting/javascript/bindings/js_bindings_chipmunk_auto_classes.h deleted file mode 100644 index 42c8840236..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_auto_classes.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -* AUTOGENERATED FILE. DO NOT EDIT IT -* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 -* Script version: v0.3 -*/ -#include "js_bindings_config.h" -#ifdef JSB_INCLUDE_CHIPMUNK - -#include "js_bindings_chipmunk_manual.h" -extern JSObject *JSB_cpConstraint_object; -extern JSClass *JSB_cpConstraint_class; -void JSB_cpConstraint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpGrooveJoint_object; -extern JSClass *JSB_cpGrooveJoint_class; -void JSB_cpGrooveJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpSimpleMotor_object; -extern JSClass *JSB_cpSimpleMotor_class; -void JSB_cpSimpleMotor_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpPivotJoint_object; -extern JSClass *JSB_cpPivotJoint_class; -void JSB_cpPivotJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpPinJoint_object; -extern JSClass *JSB_cpPinJoint_class; -void JSB_cpPinJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpSlideJoint_object; -extern JSClass *JSB_cpSlideJoint_class; -void JSB_cpSlideJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpGearJoint_object; -extern JSClass *JSB_cpGearJoint_class; -void JSB_cpGearJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpDampedRotarySpring_object; -extern JSClass *JSB_cpDampedRotarySpring_class; -void JSB_cpDampedRotarySpring_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpDampedSpring_object; -extern JSClass *JSB_cpDampedSpring_class; -void JSB_cpDampedSpring_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpRatchetJoint_object; -extern JSClass *JSB_cpRatchetJoint_class; -void JSB_cpRatchetJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpRotaryLimitJoint_object; -extern JSClass *JSB_cpRotaryLimitJoint_class; -void JSB_cpRotaryLimitJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpArbiter_object; -extern JSClass *JSB_cpArbiter_class; -void JSB_cpArbiter_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpSpace_object; -extern JSClass *JSB_cpSpace_class; -void JSB_cpSpace_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpBody_object; -extern JSClass *JSB_cpBody_class; -void JSB_cpBody_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpShape_object; -extern JSClass *JSB_cpShape_class; -void JSB_cpShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpCircleShape_object; -extern JSClass *JSB_cpCircleShape_class; -void JSB_cpCircleShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpSegmentShape_object; -extern JSClass *JSB_cpSegmentShape_class; -void JSB_cpSegmentShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); -extern JSObject *JSB_cpPolyShape_object; -extern JSClass *JSB_cpPolyShape_class; -void JSB_cpPolyShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); - - -#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_auto_classes_registration.h b/cocos/scripting/javascript/bindings/js_bindings_chipmunk_auto_classes_registration.h deleted file mode 100644 index da26c49bb3..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_auto_classes_registration.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -* AUTOGENERATED FILE. DO NOT EDIT IT -* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 -* Script version: v0.3 -*/ -#include "js_bindings_config.h" -#ifdef JSB_INCLUDE_CHIPMUNK - -JSB_cpConstraint_createClass(_cx, chipmunk, "Constraint"); -JSB_cpGrooveJoint_createClass(_cx, chipmunk, "GrooveJoint"); -JSB_cpSimpleMotor_createClass(_cx, chipmunk, "SimpleMotor"); -JSB_cpPivotJoint_createClass(_cx, chipmunk, "PivotJoint"); -JSB_cpPinJoint_createClass(_cx, chipmunk, "PinJoint"); -JSB_cpSlideJoint_createClass(_cx, chipmunk, "SlideJoint"); -JSB_cpGearJoint_createClass(_cx, chipmunk, "GearJoint"); -JSB_cpDampedRotarySpring_createClass(_cx, chipmunk, "DampedRotarySpring"); -JSB_cpDampedSpring_createClass(_cx, chipmunk, "DampedSpring"); -JSB_cpRatchetJoint_createClass(_cx, chipmunk, "RatchetJoint"); -JSB_cpRotaryLimitJoint_createClass(_cx, chipmunk, "RotaryLimitJoint"); -JSB_cpArbiter_createClass(_cx, chipmunk, "Arbiter"); -JSB_cpSpace_createClass(_cx, chipmunk, "Space"); -JSB_cpBody_createClass(_cx, chipmunk, "Body"); -JSB_cpShape_createClass(_cx, chipmunk, "Shape"); -JSB_cpCircleShape_createClass(_cx, chipmunk, "CircleShape"); -JSB_cpSegmentShape_createClass(_cx, chipmunk, "SegmentShape"); -JSB_cpPolyShape_createClass(_cx, chipmunk, "PolyShape"); - - -#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_functions.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/js_bindings_chipmunk_functions.cpp.REMOVED.git-id deleted file mode 100644 index 5cf2a4495d..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_functions.cpp.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -1c5eb9cd58c82de77374cdfa5c9ff647cc8b2f02 \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_functions.h b/cocos/scripting/javascript/bindings/js_bindings_chipmunk_functions.h deleted file mode 100644 index accf523d5e..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_functions.h +++ /dev/null @@ -1,292 +0,0 @@ -/* -* AUTOGENERATED FILE. DO NOT EDIT IT -* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 -* Script version: v0.3 -*/ -#include "js_bindings_config.h" -#ifdef JSB_INCLUDE_CHIPMUNK -#include "js_bindings_chipmunk_manual.h" - -#ifdef __cplusplus -extern "C" { -#endif -JSBool JSB_cpArbiterGetCount(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterGetDepth(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterGetElasticity(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterGetFriction(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterGetNormal(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterGetPoint(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterGetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterIgnore(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterIsFirstContact(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterSetElasticity(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterSetFriction(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterSetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterTotalImpulse(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterTotalImpulseWithFriction(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterTotalKE(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpAreaForCircle(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpAreaForSegment(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBBArea(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBBClampVect(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBBContainsBB(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBBContainsVect(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBBExpand(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBBIntersects(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBBIntersectsSegment(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBBMerge(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBBMergedArea(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBBNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBBNewForCircle(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBBSegmentQuery(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBBWrapVect(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyActivate(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyActivateStatic(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyApplyForce(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyApplyImpulse(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyDestroy(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyFree(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetAngVel(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetAngle(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetForce(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetMass(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetMoment(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetPos(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetRot(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetSpace(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetTorque(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetVel(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetVelAtLocalPoint(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetVelAtWorldPoint(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyGetVelLimit(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyInit(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyInitStatic(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyIsRogue(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyIsSleeping(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyIsStatic(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyKineticEnergy(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyLocal2World(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyNewStatic(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyResetForces(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodySetAngVel(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodySetAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodySetAngle(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodySetForce(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodySetMass(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodySetMoment(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodySetPos(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodySetTorque(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodySetVel(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodySetVelLimit(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodySleep(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodySleepWithGroup(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyUpdatePosition(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyUpdateVelocity(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodyWorld2Local(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBoxShapeNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBoxShapeNew2(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpCircleShapeGetOffset(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpCircleShapeGetRadius(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpCircleShapeNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpConstraintActivateBodies(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpConstraintDestroy(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpConstraintFree(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpConstraintGetA(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpConstraintGetB(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpConstraintGetErrorBias(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpConstraintGetImpulse(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpConstraintGetMaxBias(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpConstraintGetMaxForce(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpConstraintGetSpace(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpConstraintSetErrorBias(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpConstraintSetMaxBias(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpConstraintSetMaxForce(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedRotarySpringGetDamping(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedRotarySpringGetRestAngle(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedRotarySpringGetStiffness(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedRotarySpringNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedRotarySpringSetDamping(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedRotarySpringSetRestAngle(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedRotarySpringSetStiffness(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedSpringGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedSpringGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedSpringGetDamping(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedSpringGetRestLength(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedSpringGetStiffness(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedSpringNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedSpringSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedSpringSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedSpringSetDamping(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedSpringSetRestLength(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpDampedSpringSetStiffness(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpGearJointGetPhase(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpGearJointGetRatio(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpGearJointNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpGearJointSetPhase(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpGearJointSetRatio(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpGrooveJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpGrooveJointGetGrooveA(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpGrooveJointGetGrooveB(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpGrooveJointNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpGrooveJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpGrooveJointSetGrooveA(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpGrooveJointSetGrooveB(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpInitChipmunk(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpMomentForBox(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpMomentForBox2(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpMomentForCircle(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpMomentForSegment(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPinJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPinJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPinJointGetDist(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPinJointNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPinJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPinJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPinJointSetDist(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPivotJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPivotJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPivotJointNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPivotJointNew2(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPivotJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPivotJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPolyShapeGetNumVerts(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpPolyShapeGetVert(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpRatchetJointGetAngle(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpRatchetJointGetPhase(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpRatchetJointGetRatchet(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpRatchetJointNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpRatchetJointSetAngle(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpRatchetJointSetPhase(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpRatchetJointSetRatchet(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpResetShapeIdCounter(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpRotaryLimitJointGetMax(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpRotaryLimitJointGetMin(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpRotaryLimitJointNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpRotaryLimitJointSetMax(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpRotaryLimitJointSetMin(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSegmentShapeGetA(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSegmentShapeGetB(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSegmentShapeGetNormal(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSegmentShapeGetRadius(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSegmentShapeNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSegmentShapeSetNeighbors(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeCacheBB(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeDestroy(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeFree(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeGetBB(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeGetBody(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeGetCollisionType(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeGetElasticity(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeGetFriction(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeGetGroup(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeGetLayers(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeGetSensor(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeGetSpace(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeGetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapePointQuery(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeSetBody(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeSetCollisionType(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeSetElasticity(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeSetFriction(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeSetGroup(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeSetLayers(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeSetSensor(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeSetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpShapeUpdate(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSimpleMotorGetRate(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSimpleMotorNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSimpleMotorSetRate(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSlideJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSlideJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSlideJointGetMax(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSlideJointGetMin(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSlideJointNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSlideJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSlideJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSlideJointSetMax(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSlideJointSetMin(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceActivateShapesTouchingShape(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceAddBody(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceAddConstraint(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceAddShape(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceAddStaticShape(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceContainsBody(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceContainsConstraint(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceContainsShape(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceDestroy(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceFree(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceGetCollisionBias(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceGetCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceGetCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceGetCurrentTimeStep(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceGetDamping(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceGetEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceGetGravity(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceGetIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceGetIterations(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceGetSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceGetStaticBody(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceInit(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceIsLocked(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceNew(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpacePointQueryFirst(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceReindexShape(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceReindexShapesForBody(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceReindexStatic(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceRemoveBody(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceRemoveConstraint(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceRemoveShape(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceRemoveStaticShape(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceSetCollisionBias(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceSetCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceSetCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceSetDamping(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceSetEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceSetGravity(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceSetIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceSetIterations(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceSetSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceStep(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceUseSpatialHash(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpfabs(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpfclamp(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpfclamp01(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpflerp(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpflerpconst(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpfmax(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpfmin(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvadd(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvclamp(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvcross(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvdist(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvdistsq(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvdot(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpveql(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvforangle(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvlength(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvlengthsq(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvlerp(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvlerpconst(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvmult(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvnear(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvneg(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvnormalize(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvnormalize_safe(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvperp(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvproject(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvrotate(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvrperp(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvslerp(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvslerpconst(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvsub(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvtoangle(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpvunrotate(JSContext *cx, uint32_t argc, jsval *vp); - -#ifdef __cplusplus -} -#endif - - -#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_functions_registration.h b/cocos/scripting/javascript/bindings/js_bindings_chipmunk_functions_registration.h deleted file mode 100644 index 2d84087c28..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_functions_registration.h +++ /dev/null @@ -1,285 +0,0 @@ -/* -* AUTOGENERATED FILE. DO NOT EDIT IT -* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-10-18 -* Script version: v0.3 -*/ -#include "js_bindings_config.h" -#ifdef JSB_INCLUDE_CHIPMUNK - -#include "js_bindings_chipmunk_manual.h" -JS_DefineFunction(_cx, chipmunk, "arbiterGetCount", JSB_cpArbiterGetCount, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterGetDepth", JSB_cpArbiterGetDepth, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterGetElasticity", JSB_cpArbiterGetElasticity, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterGetFriction", JSB_cpArbiterGetFriction, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterGetNormal", JSB_cpArbiterGetNormal, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterGetPoint", JSB_cpArbiterGetPoint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterGetSurfaceVelocity", JSB_cpArbiterGetSurfaceVelocity, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterIgnore", JSB_cpArbiterIgnore, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterIsFirstContact", JSB_cpArbiterIsFirstContact, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterSetElasticity", JSB_cpArbiterSetElasticity, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterSetFriction", JSB_cpArbiterSetFriction, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterSetSurfaceVelocity", JSB_cpArbiterSetSurfaceVelocity, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterTotalImpulse", JSB_cpArbiterTotalImpulse, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterTotalImpulseWithFriction", JSB_cpArbiterTotalImpulseWithFriction, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "arbiterTotalKE", JSB_cpArbiterTotalKE, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "areaForCircle", JSB_cpAreaForCircle, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "areaForSegment", JSB_cpAreaForSegment, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bBArea", JSB_cpBBArea, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bBClampVect", JSB_cpBBClampVect, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bBContainsBB", JSB_cpBBContainsBB, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bBContainsVect", JSB_cpBBContainsVect, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bBExpand", JSB_cpBBExpand, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bBIntersects", JSB_cpBBIntersects, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bBIntersectsSegment", JSB_cpBBIntersectsSegment, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bBMerge", JSB_cpBBMerge, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bBMergedArea", JSB_cpBBMergedArea, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bBNew", JSB_cpBBNew, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bBNewForCircle", JSB_cpBBNewForCircle, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bBSegmentQuery", JSB_cpBBSegmentQuery, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bBWrapVect", JSB_cpBBWrapVect, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyActivate", JSB_cpBodyActivate, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyActivateStatic", JSB_cpBodyActivateStatic, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyApplyForce", JSB_cpBodyApplyForce, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyApplyImpulse", JSB_cpBodyApplyImpulse, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyDestroy", JSB_cpBodyDestroy, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyFree", JSB_cpBodyFree, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetAngVel", JSB_cpBodyGetAngVel, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetAngVelLimit", JSB_cpBodyGetAngVelLimit, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetAngle", JSB_cpBodyGetAngle, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetForce", JSB_cpBodyGetForce, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetMass", JSB_cpBodyGetMass, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetMoment", JSB_cpBodyGetMoment, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetPos", JSB_cpBodyGetPos, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetRot", JSB_cpBodyGetRot, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetSpace", JSB_cpBodyGetSpace, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetTorque", JSB_cpBodyGetTorque, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetVel", JSB_cpBodyGetVel, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetVelAtLocalPoint", JSB_cpBodyGetVelAtLocalPoint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetVelAtWorldPoint", JSB_cpBodyGetVelAtWorldPoint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyGetVelLimit", JSB_cpBodyGetVelLimit, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyInit", JSB_cpBodyInit, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyInitStatic", JSB_cpBodyInitStatic, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyIsRogue", JSB_cpBodyIsRogue, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyIsSleeping", JSB_cpBodyIsSleeping, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyIsStatic", JSB_cpBodyIsStatic, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyKineticEnergy", JSB_cpBodyKineticEnergy, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyLocal2World", JSB_cpBodyLocal2World, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyNew", JSB_cpBodyNew, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyNewStatic", JSB_cpBodyNewStatic, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyResetForces", JSB_cpBodyResetForces, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodySetAngVel", JSB_cpBodySetAngVel, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodySetAngVelLimit", JSB_cpBodySetAngVelLimit, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodySetAngle", JSB_cpBodySetAngle, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodySetForce", JSB_cpBodySetForce, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodySetMass", JSB_cpBodySetMass, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodySetMoment", JSB_cpBodySetMoment, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodySetPos", JSB_cpBodySetPos, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodySetTorque", JSB_cpBodySetTorque, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodySetVel", JSB_cpBodySetVel, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodySetVelLimit", JSB_cpBodySetVelLimit, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodySleep", JSB_cpBodySleep, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodySleepWithGroup", JSB_cpBodySleepWithGroup, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyUpdatePosition", JSB_cpBodyUpdatePosition, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyUpdateVelocity", JSB_cpBodyUpdateVelocity, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "bodyWorld2Local", JSB_cpBodyWorld2Local, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "boxShapeNew", JSB_cpBoxShapeNew, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "boxShapeNew2", JSB_cpBoxShapeNew2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "circleShapeGetOffset", JSB_cpCircleShapeGetOffset, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "circleShapeGetRadius", JSB_cpCircleShapeGetRadius, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "circleShapeNew", JSB_cpCircleShapeNew, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "constraintActivateBodies", JSB_cpConstraintActivateBodies, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "constraintDestroy", JSB_cpConstraintDestroy, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "constraintFree", JSB_cpConstraintFree, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "constraintGetA", JSB_cpConstraintGetA, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "constraintGetB", JSB_cpConstraintGetB, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "constraintGetErrorBias", JSB_cpConstraintGetErrorBias, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "constraintGetImpulse", JSB_cpConstraintGetImpulse, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "constraintGetMaxBias", JSB_cpConstraintGetMaxBias, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "constraintGetMaxForce", JSB_cpConstraintGetMaxForce, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "constraintGetSpace", JSB_cpConstraintGetSpace, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "constraintSetErrorBias", JSB_cpConstraintSetErrorBias, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "constraintSetMaxBias", JSB_cpConstraintSetMaxBias, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "constraintSetMaxForce", JSB_cpConstraintSetMaxForce, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringGetDamping", JSB_cpDampedRotarySpringGetDamping, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringGetRestAngle", JSB_cpDampedRotarySpringGetRestAngle, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringGetStiffness", JSB_cpDampedRotarySpringGetStiffness, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringNew", JSB_cpDampedRotarySpringNew, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringSetDamping", JSB_cpDampedRotarySpringSetDamping, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringSetRestAngle", JSB_cpDampedRotarySpringSetRestAngle, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringSetStiffness", JSB_cpDampedRotarySpringSetStiffness, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedSpringGetAnchr1", JSB_cpDampedSpringGetAnchr1, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedSpringGetAnchr2", JSB_cpDampedSpringGetAnchr2, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedSpringGetDamping", JSB_cpDampedSpringGetDamping, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedSpringGetRestLength", JSB_cpDampedSpringGetRestLength, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedSpringGetStiffness", JSB_cpDampedSpringGetStiffness, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedSpringNew", JSB_cpDampedSpringNew, 7, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedSpringSetAnchr1", JSB_cpDampedSpringSetAnchr1, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedSpringSetAnchr2", JSB_cpDampedSpringSetAnchr2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedSpringSetDamping", JSB_cpDampedSpringSetDamping, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedSpringSetRestLength", JSB_cpDampedSpringSetRestLength, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "dampedSpringSetStiffness", JSB_cpDampedSpringSetStiffness, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "gearJointGetPhase", JSB_cpGearJointGetPhase, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "gearJointGetRatio", JSB_cpGearJointGetRatio, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "gearJointNew", JSB_cpGearJointNew, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "gearJointSetPhase", JSB_cpGearJointSetPhase, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "gearJointSetRatio", JSB_cpGearJointSetRatio, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "grooveJointGetAnchr2", JSB_cpGrooveJointGetAnchr2, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "grooveJointGetGrooveA", JSB_cpGrooveJointGetGrooveA, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "grooveJointGetGrooveB", JSB_cpGrooveJointGetGrooveB, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "grooveJointNew", JSB_cpGrooveJointNew, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "grooveJointSetAnchr2", JSB_cpGrooveJointSetAnchr2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "grooveJointSetGrooveA", JSB_cpGrooveJointSetGrooveA, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "grooveJointSetGrooveB", JSB_cpGrooveJointSetGrooveB, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "initChipmunk", JSB_cpInitChipmunk, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "momentForBox", JSB_cpMomentForBox, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "momentForBox2", JSB_cpMomentForBox2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "momentForCircle", JSB_cpMomentForCircle, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "momentForSegment", JSB_cpMomentForSegment, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "pinJointGetAnchr1", JSB_cpPinJointGetAnchr1, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "pinJointGetAnchr2", JSB_cpPinJointGetAnchr2, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "pinJointGetDist", JSB_cpPinJointGetDist, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "pinJointNew", JSB_cpPinJointNew, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "pinJointSetAnchr1", JSB_cpPinJointSetAnchr1, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "pinJointSetAnchr2", JSB_cpPinJointSetAnchr2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "pinJointSetDist", JSB_cpPinJointSetDist, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "pivotJointGetAnchr1", JSB_cpPivotJointGetAnchr1, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "pivotJointGetAnchr2", JSB_cpPivotJointGetAnchr2, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "pivotJointNew", JSB_cpPivotJointNew, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "pivotJointNew2", JSB_cpPivotJointNew2, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "pivotJointSetAnchr1", JSB_cpPivotJointSetAnchr1, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "pivotJointSetAnchr2", JSB_cpPivotJointSetAnchr2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "polyShapeGetNumVerts", JSB_cpPolyShapeGetNumVerts, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "polyShapeGetVert", JSB_cpPolyShapeGetVert, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "ratchetJointGetAngle", JSB_cpRatchetJointGetAngle, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "ratchetJointGetPhase", JSB_cpRatchetJointGetPhase, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "ratchetJointGetRatchet", JSB_cpRatchetJointGetRatchet, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "ratchetJointNew", JSB_cpRatchetJointNew, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "ratchetJointSetAngle", JSB_cpRatchetJointSetAngle, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "ratchetJointSetPhase", JSB_cpRatchetJointSetPhase, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "ratchetJointSetRatchet", JSB_cpRatchetJointSetRatchet, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "resetShapeIdCounter", JSB_cpResetShapeIdCounter, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "rotaryLimitJointGetMax", JSB_cpRotaryLimitJointGetMax, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "rotaryLimitJointGetMin", JSB_cpRotaryLimitJointGetMin, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "rotaryLimitJointNew", JSB_cpRotaryLimitJointNew, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "rotaryLimitJointSetMax", JSB_cpRotaryLimitJointSetMax, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "rotaryLimitJointSetMin", JSB_cpRotaryLimitJointSetMin, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "segmentShapeGetA", JSB_cpSegmentShapeGetA, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "segmentShapeGetB", JSB_cpSegmentShapeGetB, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "segmentShapeGetNormal", JSB_cpSegmentShapeGetNormal, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "segmentShapeGetRadius", JSB_cpSegmentShapeGetRadius, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "segmentShapeNew", JSB_cpSegmentShapeNew, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "segmentShapeSetNeighbors", JSB_cpSegmentShapeSetNeighbors, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeCacheBB", JSB_cpShapeCacheBB, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeDestroy", JSB_cpShapeDestroy, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeFree", JSB_cpShapeFree, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeGetBB", JSB_cpShapeGetBB, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeGetBody", JSB_cpShapeGetBody, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeGetCollisionType", JSB_cpShapeGetCollisionType, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeGetElasticity", JSB_cpShapeGetElasticity, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeGetFriction", JSB_cpShapeGetFriction, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeGetGroup", JSB_cpShapeGetGroup, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeGetLayers", JSB_cpShapeGetLayers, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeGetSensor", JSB_cpShapeGetSensor, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeGetSpace", JSB_cpShapeGetSpace, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeGetSurfaceVelocity", JSB_cpShapeGetSurfaceVelocity, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapePointQuery", JSB_cpShapePointQuery, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeSetBody", JSB_cpShapeSetBody, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeSetCollisionType", JSB_cpShapeSetCollisionType, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeSetElasticity", JSB_cpShapeSetElasticity, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeSetFriction", JSB_cpShapeSetFriction, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeSetGroup", JSB_cpShapeSetGroup, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeSetLayers", JSB_cpShapeSetLayers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeSetSensor", JSB_cpShapeSetSensor, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeSetSurfaceVelocity", JSB_cpShapeSetSurfaceVelocity, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "shapeUpdate", JSB_cpShapeUpdate, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "simpleMotorGetRate", JSB_cpSimpleMotorGetRate, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "simpleMotorNew", JSB_cpSimpleMotorNew, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "simpleMotorSetRate", JSB_cpSimpleMotorSetRate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "slideJointGetAnchr1", JSB_cpSlideJointGetAnchr1, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "slideJointGetAnchr2", JSB_cpSlideJointGetAnchr2, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "slideJointGetMax", JSB_cpSlideJointGetMax, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "slideJointGetMin", JSB_cpSlideJointGetMin, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "slideJointNew", JSB_cpSlideJointNew, 6, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "slideJointSetAnchr1", JSB_cpSlideJointSetAnchr1, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "slideJointSetAnchr2", JSB_cpSlideJointSetAnchr2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "slideJointSetMax", JSB_cpSlideJointSetMax, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "slideJointSetMin", JSB_cpSlideJointSetMin, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceActivateShapesTouchingShape", JSB_cpSpaceActivateShapesTouchingShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceAddBody", JSB_cpSpaceAddBody, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceAddConstraint", JSB_cpSpaceAddConstraint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceAddShape", JSB_cpSpaceAddShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceAddStaticShape", JSB_cpSpaceAddStaticShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceContainsBody", JSB_cpSpaceContainsBody, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceContainsConstraint", JSB_cpSpaceContainsConstraint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceContainsShape", JSB_cpSpaceContainsShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceDestroy", JSB_cpSpaceDestroy, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceFree", JSB_cpSpaceFree, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceGetCollisionBias", JSB_cpSpaceGetCollisionBias, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceGetCollisionPersistence", JSB_cpSpaceGetCollisionPersistence, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceGetCollisionSlop", JSB_cpSpaceGetCollisionSlop, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceGetCurrentTimeStep", JSB_cpSpaceGetCurrentTimeStep, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceGetDamping", JSB_cpSpaceGetDamping, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceGetEnableContactGraph", JSB_cpSpaceGetEnableContactGraph, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceGetGravity", JSB_cpSpaceGetGravity, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceGetIdleSpeedThreshold", JSB_cpSpaceGetIdleSpeedThreshold, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceGetIterations", JSB_cpSpaceGetIterations, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceGetSleepTimeThreshold", JSB_cpSpaceGetSleepTimeThreshold, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceGetStaticBody", JSB_cpSpaceGetStaticBody, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceInit", JSB_cpSpaceInit, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceIsLocked", JSB_cpSpaceIsLocked, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceNew", JSB_cpSpaceNew, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spacePointQueryFirst", JSB_cpSpacePointQueryFirst, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceReindexShape", JSB_cpSpaceReindexShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceReindexShapesForBody", JSB_cpSpaceReindexShapesForBody, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceReindexStatic", JSB_cpSpaceReindexStatic, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceRemoveBody", JSB_cpSpaceRemoveBody, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceRemoveConstraint", JSB_cpSpaceRemoveConstraint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceRemoveShape", JSB_cpSpaceRemoveShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceRemoveStaticShape", JSB_cpSpaceRemoveStaticShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceSetCollisionBias", JSB_cpSpaceSetCollisionBias, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceSetCollisionPersistence", JSB_cpSpaceSetCollisionPersistence, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceSetCollisionSlop", JSB_cpSpaceSetCollisionSlop, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceSetDamping", JSB_cpSpaceSetDamping, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceSetEnableContactGraph", JSB_cpSpaceSetEnableContactGraph, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceSetGravity", JSB_cpSpaceSetGravity, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceSetIdleSpeedThreshold", JSB_cpSpaceSetIdleSpeedThreshold, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceSetIterations", JSB_cpSpaceSetIterations, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceSetSleepTimeThreshold", JSB_cpSpaceSetSleepTimeThreshold, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceStep", JSB_cpSpaceStep, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "spaceUseSpatialHash", JSB_cpSpaceUseSpatialHash, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "fabs", JSB_cpfabs, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "fclamp", JSB_cpfclamp, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "fclamp01", JSB_cpfclamp01, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "flerp", JSB_cpflerp, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "flerpconst", JSB_cpflerpconst, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "fmax", JSB_cpfmax, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "fmin", JSB_cpfmin, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vadd", JSB_cpvadd, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vclamp", JSB_cpvclamp, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vcross", JSB_cpvcross, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vdist", JSB_cpvdist, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vdistsq", JSB_cpvdistsq, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vdot", JSB_cpvdot, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "veql", JSB_cpveql, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vforangle", JSB_cpvforangle, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vlength", JSB_cpvlength, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vlengthsq", JSB_cpvlengthsq, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vlerp", JSB_cpvlerp, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vlerpconst", JSB_cpvlerpconst, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vmult", JSB_cpvmult, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vnear", JSB_cpvnear, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vneg", JSB_cpvneg, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vnormalize", JSB_cpvnormalize, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vnormalize_safe", JSB_cpvnormalize_safe, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vperp", JSB_cpvperp, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vproject", JSB_cpvproject, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vrotate", JSB_cpvrotate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vrperp", JSB_cpvrperp, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vslerp", JSB_cpvslerp, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vslerpconst", JSB_cpvslerpconst, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vsub", JSB_cpvsub, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vtoangle", JSB_cpvtoangle, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, chipmunk, "vunrotate", JSB_cpvunrotate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); - - -#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp b/cocos/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp deleted file mode 100644 index 14a88c87bb..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp +++ /dev/null @@ -1,1624 +0,0 @@ -/* - * JS Bindings: https://github.com/zynga/jsbindings - * - * Copyright (c) 2012 Zynga Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "extensions/cocos-ext.h" -#include "js_bindings_config.h" -#ifdef JSB_INCLUDE_CHIPMUNK - -#include "jsapi.h" -#include "jsfriendapi.h" - -#include "js_bindings_chipmunk_manual.h" -#include "js_manual_conversions.h" - -USING_NS_CC_EXT; -// Function declarations -void static freeSpaceChildren(cpSpace *space); - -template -static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { - TypeTest t; - T* cobj = new T(); - cobj->autorelease(); - js_type_class_t *p; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, p); - assert(p); - JSObject *_tmp = JS_NewObject(cx, p->jsclass, p->proto, p->parentProto); - js_proxy_t *pp = jsb_new_proxy(cobj, _tmp); - JS_AddObjectRoot(cx, &pp->obj); - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp)); - - return JS_TRUE; -} - -#pragma mark - convertions - -/* - * PhysicsSprite - */ -#pragma mark - PhysicsSprite - -JSClass* JSPROXY_CCPhysicsSprite_class = NULL; -JSObject* JSPROXY_CCPhysicsSprite_object = NULL; -// Constructor - -// Destructor -void JSPROXY_CCPhysicsSprite_finalize(JSFreeOp *fop, JSObject *obj) -{ - CCLOGINFO("jsbindings: finalizing JS object %p (PhysicsSprite)", obj); -} - -// Arguments: -// Ret value: cpBody* (N/A) -JSBool JSPROXY_CCPhysicsSprite_getCPBody(JSContext *cx, uint32_t argc, jsval *vp) { - - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, real) - cpBody* ret_val; - - ret_val = real->getCPBody(); - jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpBody_object, JSB_cpBody_class, "cpBody" ); - JS_SET_RVAL(cx, vp, ret_jsval); - - return JS_TRUE; -} - -// Arguments: -// Ret value: BOOL (b) -JSBool JSPROXY_CCPhysicsSprite_ignoreBodyRotation(JSContext *cx, uint32_t argc, jsval *vp) { - - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, real) - - bool ret_val; - - ret_val = real->isIgnoreBodyRotation(); - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret_val)); - return JS_TRUE; -} - -// Arguments: cpBody* -// Ret value: void (None) -JSBool JSPROXY_CCPhysicsSprite_setCPBody_(JSContext *cx, uint32_t argc, jsval *vp) { - - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, real) - - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - - cpBody* arg0; - - ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); - if( ! ok ) return JS_FALSE; - - real->setCPBody((cpBody*)arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; -} - -// Arguments: BOOL -// Ret value: void (None) -JSBool JSPROXY_CCPhysicsSprite_setIgnoreBodyRotation_(JSContext *cx, uint32_t argc, jsval *vp) { - - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, real) - - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - JSBool arg0; - - ok &= JS_ValueToBoolean( cx, *argvp++, &arg0 ); - if( ! ok ) return JS_FALSE; - - real->setIgnoreBodyRotation((bool)arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; -} - -/* - * PhysicsDebugNode - */ -//#pragma mark - PhysicsDebugNode - -JSClass* JSB_CCPhysicsDebugNode_class = NULL; -JSObject* JSB_CCPhysicsDebugNode_object = NULL; -extern JSObject *js_cocos2dx_CCDrawNode_prototype; - -// Constructor - -// Destructor -void JSB_CCPhysicsDebugNode_finalize(JSFreeOp *fop, JSObject *obj) -{ - CCLOGINFO("jsbindings: finalizing JS object %p (PhysicsDebugNode)", obj); -} - -// Arguments: cpSpace* -// Ret value: PhysicsDebugNode* (o) -JSBool JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static(JSContext *cx, uint32_t argc, jsval *vp) { - JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpSpace* arg0; - - ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - - PhysicsDebugNode* ret = PhysicsDebugNode::create(arg0); - jsval jsret; - do { - if (ret) { - TypeTest t; - js_type_class_t *typeClass; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - jsret = OBJECT_TO_JSVAL(obj); - js_proxy_t *p = jsb_new_proxy(ret, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "CCDebugNode"); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - - return JS_TRUE; -} - -// Arguments: cpSpace* -// Ret value: void (None) -JSBool JSB_CCPhysicsDebugNode_setSpace_(JSContext *cx, uint32_t argc, jsval *vp) { - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(jsthis); - PhysicsDebugNode* real = (PhysicsDebugNode *)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, real) - - JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpSpace* arg0; - - ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - - real->setSpace(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; -} - -// Arguments: -// Ret value: cpSpace* (N/A) -JSBool JSB_CCPhysicsDebugNode_space(JSContext *cx, uint32_t argc, jsval *vp) { - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(jsthis); - PhysicsDebugNode* real = (PhysicsDebugNode *)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, real) - JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); - cpSpace* ret_val; - - ret_val = real->getSpace(); - - jsval ret_jsval = opaque_to_jsval( cx, ret_val ); - JS_SET_RVAL(cx, vp, ret_jsval); - - return JS_TRUE; -} - -void JSB_CCPhysicsDebugNode_createClass(JSContext *cx, JSObject* globalObj, const char* name ) -{ - JSB_CCPhysicsDebugNode_class = (JSClass *)calloc(1, sizeof(JSClass)); - JSB_CCPhysicsDebugNode_class->name = name; - JSB_CCPhysicsDebugNode_class->addProperty = JS_PropertyStub; - JSB_CCPhysicsDebugNode_class->delProperty = JS_DeletePropertyStub; - JSB_CCPhysicsDebugNode_class->getProperty = JS_PropertyStub; - JSB_CCPhysicsDebugNode_class->setProperty = JS_StrictPropertyStub; - JSB_CCPhysicsDebugNode_class->enumerate = JS_EnumerateStub; - JSB_CCPhysicsDebugNode_class->resolve = JS_ResolveStub; - JSB_CCPhysicsDebugNode_class->convert = JS_ConvertStub; - JSB_CCPhysicsDebugNode_class->finalize = JSB_CCPhysicsDebugNode_finalize; - JSB_CCPhysicsDebugNode_class->flags = 0; - - static JSPropertySpec properties[] = { - {0, 0, 0, 0, 0} - }; - static JSFunctionSpec funcs[] = { - JS_FN("_setSpace", JSB_CCPhysicsDebugNode_setSpace_, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getSpace", JSB_CCPhysicsDebugNode_space, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - static JSFunctionSpec st_funcs[] = { - JS_FN("_create", JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - TypeTest t1; - js_type_class_t *typeClass; - uint32_t typeId = t1.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); - - JSB_CCPhysicsDebugNode_object = JS_InitClass(cx, globalObj, typeClass->proto, JSB_CCPhysicsDebugNode_class, dummy_constructor, 0,properties,funcs,NULL,st_funcs); - - TypeTest t; - js_type_class_t *p; - typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, p); - if (!p) { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->type = typeId; - p->jsclass = JSB_CCPhysicsDebugNode_class; - p->proto = JSB_CCPhysicsDebugNode_object; - p->parentProto = typeClass->proto; - HASH_ADD_INT(_js_global_type_ht, type, p); - } -} - -// Arguments: NSString*, CGRect -// Ret value: PhysicsSprite* (o) -JSBool JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static(JSContext *cx, uint32_t argc, jsval *vp) { - - jsval *argv = JS_ARGV(cx, vp); - JSBool ok = JS_TRUE; - if (argc == 2) { - const char* arg0; - std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - - PhysicsSprite* ret = PhysicsSprite::create(arg0, arg1); - - jsval jsret; - do { - if (ret) { - TypeTest t; - js_type_class_t *typeClass; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - jsret = OBJECT_TO_JSVAL(obj); - js_proxy_t *p = jsb_new_proxy(ret, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return JS_TRUE; - } - if (argc == 1) { - const char* arg0; - std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - - PhysicsSprite* ret = PhysicsSprite::create(arg0); - - jsval jsret; - do { - if (ret) { - TypeTest t; - js_type_class_t *typeClass; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - jsret = OBJECT_TO_JSVAL(obj); - js_proxy_t *p = jsb_new_proxy(ret, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return JS_TRUE; - } - return JS_FALSE; - -} - -// Arguments: SpriteFrame* -// Ret value: PhysicsSprite* (o) -JSBool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static(JSContext *cx, uint32_t argc, jsval *vp) { - jsval *argv = JS_ARGV(cx, vp); - cocos2d::SpriteFrame* arg0; - if (argc >= 1) { - do { - js_proxy_t *proxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - proxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, arg0) - } while (0); - } - PhysicsSprite* ret = PhysicsSprite::createWithSpriteFrame(arg0); - - jsval jsret; - do { - if (ret) { - TypeTest t; - js_type_class_t *typeClass; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - jsret = OBJECT_TO_JSVAL(obj); - js_proxy_t *p = jsb_new_proxy(ret, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return JS_TRUE; -} - -// Arguments: NSString* -// Ret value: PhysicsSprite* (o) -JSBool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, uint32_t argc, jsval *vp) { - jsval *argv = JS_ARGV(cx, vp); - JSBool ok = JS_TRUE; - const char* arg0; - std::string arg0_tmp; - if (argc >= 1) { - ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - } - PhysicsSprite* ret = PhysicsSprite::createWithSpriteFrameName(arg0); - - jsval jsret; - do { - if (ret) { - TypeTest t; - js_type_class_t *typeClass; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - jsret = OBJECT_TO_JSVAL(obj); - js_proxy_t *p = jsb_new_proxy(ret, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return JS_TRUE; -} - -void JSPROXY_CCPhysicsSprite_createClass(JSContext *cx, JSObject* globalObj) -{ - JSPROXY_CCPhysicsSprite_class = (JSClass *)calloc(1, sizeof(JSClass)); - JSPROXY_CCPhysicsSprite_class->name = "PhysicsSprite"; - JSPROXY_CCPhysicsSprite_class->addProperty = JS_PropertyStub; - JSPROXY_CCPhysicsSprite_class->delProperty = JS_DeletePropertyStub; - JSPROXY_CCPhysicsSprite_class->getProperty = JS_PropertyStub; - JSPROXY_CCPhysicsSprite_class->setProperty = JS_StrictPropertyStub; - JSPROXY_CCPhysicsSprite_class->enumerate = JS_EnumerateStub; - JSPROXY_CCPhysicsSprite_class->resolve = JS_ResolveStub; - JSPROXY_CCPhysicsSprite_class->convert = JS_ConvertStub; - JSPROXY_CCPhysicsSprite_class->finalize = JSPROXY_CCPhysicsSprite_finalize; - JSPROXY_CCPhysicsSprite_class->flags = 0; - - static JSPropertySpec properties[] = { - {0, 0, 0, 0, 0} - }; - static JSFunctionSpec funcs[] = { - JS_FN("getCPBody", JSPROXY_CCPhysicsSprite_getCPBody, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getIgnoreBodyRotation", JSPROXY_CCPhysicsSprite_ignoreBodyRotation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("_setCPBody", JSPROXY_CCPhysicsSprite_setCPBody_, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setIgnoreBodyRotation", JSPROXY_CCPhysicsSprite_setIgnoreBodyRotation_, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - static JSFunctionSpec st_funcs[] = { - JS_FN("create", JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("createWithSpriteFrame", JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("createWithSpriteFrameName", JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - TypeTest t1; - js_type_class_t *typeClass; - uint32_t typeId = t1.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); - - JSPROXY_CCPhysicsSprite_object = JS_InitClass(cx, globalObj, typeClass->proto, JSPROXY_CCPhysicsSprite_class, dummy_constructor, 0,properties,funcs,NULL,st_funcs); - - TypeTest t; - js_type_class_t *p; - typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, p); - if (!p) { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->type = typeId; - p->jsclass = JSPROXY_CCPhysicsSprite_class; - p->proto = JSPROXY_CCPhysicsSprite_object; - p->parentProto = typeClass->proto; - HASH_ADD_INT(_js_global_type_ht, type, p); - } -} - - -void register_CCPhysicsSprite(JSContext *cx, JSObject *obj) { - jsval nsval; - JSObject *ns; - JS_GetProperty(cx, obj, "cc", &nsval); - if (nsval == JSVAL_VOID) { - ns = JS_NewObject(cx, NULL, NULL, NULL); - nsval = OBJECT_TO_JSVAL(ns); - JS_SetProperty(cx, obj, "cc", &nsval); - } else { - JS_ValueToObject(cx, nsval, &ns); - } - obj = ns; - JSPROXY_CCPhysicsSprite_createClass(cx, obj); -} - -void register_CCPhysicsDebugNode(JSContext *cx, JSObject *obj) { - jsval nsval; - JSObject *ns; - JS_GetProperty(cx, obj, "cc", &nsval); - if (nsval == JSVAL_VOID) { - ns = JS_NewObject(cx, NULL, NULL, NULL); - nsval = OBJECT_TO_JSVAL(ns); - JS_SetProperty(cx, obj, "cc", &nsval); - } else { - JS_ValueToObject(cx, nsval, &ns); - } - obj = ns; - JSB_CCPhysicsDebugNode_createClass(cx, obj, "PhysicsDebugNode"); -} - -JSBool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ) -{ - JSObject *jsobj; - JSBool ok = JS_ValueToObject( cx, vp, &jsobj ); - JSB_PRECONDITION( ok, "Error converting value to object"); - JSB_PRECONDITION( jsobj, "Not a valid JS object"); - - jsval vall, valb, valr, valt; - ok = JS_TRUE; - ok &= JS_GetProperty(cx, jsobj, "l", &vall); - ok &= JS_GetProperty(cx, jsobj, "b", &valb); - ok &= JS_GetProperty(cx, jsobj, "r", &valr); - ok &= JS_GetProperty(cx, jsobj, "t", &valt); - JSB_PRECONDITION( ok, "Error obtaining point properties"); - - double l, b, r, t; - ok &= JS_ValueToNumber(cx, vall, &l); - ok &= JS_ValueToNumber(cx, valb, &b); - ok &= JS_ValueToNumber(cx, valr, &r); - ok &= JS_ValueToNumber(cx, valt, &t); - JSB_PRECONDITION( ok, "Error converting value to numbers"); - - ret->l = l; - ret->b = b; - ret->r = r; - ret->t = t; - - return JS_TRUE; -} - -jsval cpBB_to_jsval(JSContext *cx, cpBB bb ) -{ - JSObject *object = JS_NewObject(cx, NULL, NULL, NULL ); - if (!object) - return JSVAL_VOID; - - if (!JS_DefineProperty(cx, object, "l", DOUBLE_TO_JSVAL(bb.l), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || - !JS_DefineProperty(cx, object, "b", DOUBLE_TO_JSVAL(bb.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || - !JS_DefineProperty(cx, object, "r", DOUBLE_TO_JSVAL(bb.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || - !JS_DefineProperty(cx, object, "t", DOUBLE_TO_JSVAL(bb.t), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) - return JSVAL_VOID; - - return OBJECT_TO_JSVAL(object); -} - -// In order to be compatible with Chipmunk-JS API, -// this function expect to receive an array of numbers, and not an array of vects -// OK: [1,2, 3,4, 5,6] <- expected -// BAD: [{x:1, y:2}, {x:3,y:4}, {x:5, y:6}] <- not expected -JSBool jsval_to_array_of_cpvect( JSContext *cx, jsval vp, cpVect**verts, int *numVerts) -{ - // Parsing sequence - JSObject *jsobj; - JSBool ok = JS_ValueToObject( cx, vp, &jsobj ); - JSB_PRECONDITION( ok, "Error converting value to object"); - - JSB_PRECONDITION( jsobj && JS_IsArrayObject( cx, jsobj), "Object must be an array"); - - uint32_t len; - JS_GetArrayLength(cx, jsobj, &len); - - JSB_PRECONDITION( len%2==0, "Array lenght should be even"); - - cpVect *array = (cpVect*)malloc( sizeof(cpVect) * len/2); - - for( uint32_t i=0; i< len;i++ ) { - jsval valarg; - JS_GetElement(cx, jsobj, i, &valarg); - - double value; - ok = JS_ValueToNumber(cx, valarg, &value); - JSB_PRECONDITION( ok, "Error converting value to nsobject"); - - if(i%2==0) - array[i/2].x = value; - else - array[i/2].y = value; - } - - *numVerts = len/2; - *verts = array; - - return JS_TRUE; -} - -#pragma mark - Collision Handler - -struct collision_handler { - cpCollisionType typeA; - cpCollisionType typeB; - - JSObject *begin; - JSObject *pre; - JSObject *post; - JSObject *separate; - JSObject *jsthis; - JSContext *cx; - - // "owner" of the collision handler - // Needed when the space goes out of scope, it will remove all the allocated collision handlers for him. - cpSpace *space; - - unsigned long hash_key; - - unsigned int is_oo; // Objected oriented API ? - UT_hash_handle hh; -}; - -// hash -struct collision_handler* collision_handler_hash = NULL; - -// helper pair -static unsigned long pair_ints( unsigned long A, unsigned long B ) -{ - // order is not important - unsigned long k1 = MIN(A, B ); - unsigned long k2 = MAX(A, B ); - - return (k1 + k2) * (k1 + k2 + 1) /2 + k2; -} - -static cpBool myCollisionBegin(cpArbiter *arb, cpSpace *space, void *data) -{ - struct collision_handler *handler = (struct collision_handler*) data; - - jsval args[2]; - if( handler->is_oo ) { - args[0] = c_class_to_jsval(handler->cx, arb, JSB_cpArbiter_object, JSB_cpArbiter_class, "cpArbiter"); - args[1] = c_class_to_jsval(handler->cx, space, JSB_cpSpace_object, JSB_cpSpace_class, "cpArbiter"); - } else { - args[0] = opaque_to_jsval( handler->cx, arb); - args[1] = opaque_to_jsval( handler->cx, space ); - } - - jsval rval; - JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->begin), 2, args, &rval); - JSB_PRECONDITION2(ok, handler->cx, cpFalse, "Error calling collision callback: begin"); - - if( JSVAL_IS_BOOLEAN(rval) ) { - JSBool ret = JSVAL_TO_BOOLEAN(rval); - return (cpBool)ret; - } - return cpTrue; -} - -static cpBool myCollisionPre(cpArbiter *arb, cpSpace *space, void *data) -{ - struct collision_handler *handler = (struct collision_handler*) data; - - jsval args[2]; - if( handler->is_oo ) { - args[0] = c_class_to_jsval(handler->cx, arb, JSB_cpArbiter_object, JSB_cpArbiter_class, "cpArbiter"); - args[1] = c_class_to_jsval(handler->cx, space, JSB_cpSpace_object, JSB_cpSpace_class, "cpArbiter"); - } else { - args[0] = opaque_to_jsval( handler->cx, arb); - args[1] = opaque_to_jsval( handler->cx, space ); - } - - jsval rval; - JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->pre), 2, args, &rval); - JSB_PRECONDITION2(ok, handler->cx, JS_FALSE, "Error calling collision callback: pre"); - - if( JSVAL_IS_BOOLEAN(rval) ) { - JSBool ret = JSVAL_TO_BOOLEAN(rval); - return (cpBool)ret; - } - return cpTrue; -} - -static void myCollisionPost(cpArbiter *arb, cpSpace *space, void *data) -{ - struct collision_handler *handler = (struct collision_handler*) data; - - jsval args[2]; - - if( handler->is_oo ) { - args[0] = c_class_to_jsval(handler->cx, arb, JSB_cpArbiter_object, JSB_cpArbiter_class, "cpArbiter"); - args[1] = c_class_to_jsval(handler->cx, space, JSB_cpSpace_object, JSB_cpSpace_class, "cpArbiter"); - } else { - args[0] = opaque_to_jsval( handler->cx, arb); - args[1] = opaque_to_jsval( handler->cx, space ); - } - - jsval ignore; - JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->post), 2, args, &ignore); - JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Post"); -} - -static void myCollisionSeparate(cpArbiter *arb, cpSpace *space, void *data) -{ - struct collision_handler *handler = (struct collision_handler*) data; - - jsval args[2]; - if( handler->is_oo ) { - args[0] = c_class_to_jsval(handler->cx, arb, JSB_cpArbiter_object, JSB_cpArbiter_class, "cpArbiter"); - args[1] = c_class_to_jsval(handler->cx, space, JSB_cpSpace_object, JSB_cpSpace_class, "cpArbiter"); - } else { - args[0] = opaque_to_jsval( handler->cx, arb); - args[1] = opaque_to_jsval( handler->cx, space ); - } - - jsval ignore; - JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->separate), 2, args, &ignore); - JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Separate");} - -#pragma mark - cpSpace - -#pragma mark constructor / destructor - -void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *jsthis) -{ - struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); - if( proxy ) { - CCLOGINFO("jsbindings: finalizing JS object %p (cpSpace), handle: %p", jsthis, proxy->handle); - - // space - cpSpace *space = (cpSpace*) proxy->handle; - - - // Remove collision handlers, since the user might have forgotten to manually remove them - struct collision_handler *current, *tmp; - HASH_ITER(hh, collision_handler_hash, current, tmp) { - if( current->space == space ) { - - JSContext *cx = current->cx; - - // unroot it - if( current->begin ) { - JS_RemoveObjectRoot(cx, ¤t->begin); - } - if( current->pre ) - JS_RemoveObjectRoot(cx, ¤t->pre); - if( current->post ) - JS_RemoveObjectRoot(cx, ¤t->post); - if( current->separate ) - JS_RemoveObjectRoot(cx, ¤t->separate); - - HASH_DEL(collision_handler_hash,current); /* delete; users advances to next */ - free(current); /* optional- if you want to free */ - } - } - - // Free Space Children - freeSpaceChildren(space); - - jsb_del_jsobject_for_proxy(space); - if(proxy->flags == JSB_C_FLAG_CALL_FREE) - cpSpaceFree(space); - jsb_del_c_proxy_for_jsobject(jsthis); - } -} - - -#pragma mark addCollisionHandler - -static -JSBool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, cpSpace *space, unsigned int is_oo) -{ - struct collision_handler *handler = (struct collision_handler*) malloc( sizeof(*handler) ); - - JSB_PRECONDITION(handler, "Error allocating memory"); - - JSBool ok = JS_TRUE; - - // args - ok &= jsval_to_int(cx, *argvp++, (int32_t*) &handler->typeA ); - ok &= jsval_to_int(cx, *argvp++, (int32_t*) &handler->typeB ); - - // this is no longer passed, so "this" is going to be "this". -// ok &= JS_ValueToObject(cx, *argvp++, &handler->jsthis ); - handler->jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - - handler->begin = !JSVAL_IS_NULL(*argvp) ? JSVAL_TO_OBJECT(*argvp) : NULL; - argvp++; - handler->pre = !JSVAL_IS_NULL(*argvp) ? JSVAL_TO_OBJECT(*argvp) : NULL; - argvp++; - handler->post = !JSVAL_IS_NULL(*argvp) ? JSVAL_TO_OBJECT(*argvp) : NULL; - argvp++; - handler->separate = !JSVAL_IS_NULL(*argvp) ? JSVAL_TO_OBJECT(*argvp) : NULL; - argvp++; - - JSB_PRECONDITION(ok, "Error parsing arguments"); - - // Object Oriented API ? - handler->is_oo = is_oo; - - // owner of the collision handler - handler->space = space; - - // Root it - if( handler->begin ) - JS_AddNamedObjectRoot(cx, &handler->begin, "begin collision_handler"); - if( handler->pre ) - JS_AddNamedObjectRoot(cx, &handler->pre, "pre collision_handler"); - if( handler->post ) - JS_AddNamedObjectRoot(cx, &handler->post, "post collision_handler"); - if( handler->separate ) - JS_AddNamedObjectRoot(cx, &handler->separate, "separate collision_handler"); - - handler->cx = cx; - - cpSpaceAddCollisionHandler(space, handler->typeA, handler->typeB, - !handler->begin ? NULL : &myCollisionBegin, - !handler->pre ? NULL : &myCollisionPre, - !handler->post ? NULL : &myCollisionPost, - !handler->separate ? NULL : &myCollisionSeparate, - handler ); - - - // - // Already added ? If so, remove it. - // Then add new entry - // - struct collision_handler *hashElement = NULL; - unsigned long paired_key = pair_ints(handler->typeA, handler->typeB ); - HASH_FIND_INT(collision_handler_hash, &paired_key, hashElement); - if( hashElement ) { - HASH_DEL( collision_handler_hash, hashElement ); - free( hashElement ); - } - - handler->hash_key = paired_key; - HASH_ADD_INT( collision_handler_hash, hash_key, handler ); - - - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; -} - -JSBool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==7, cx, JS_FALSE, "Invalid number of arguments"); - - - jsval *argvp = JS_ARGV(cx,vp); - - // args - cpSpace *space; - JSBool ok = jsval_to_opaque( cx, *argvp++, (void**)&space); - JSB_PRECONDITION(ok, "Error parsing arguments"); - - return __jsb_cpSpace_addCollisionHandler(cx, vp, argvp, space, 0); -} - -// method -JSBool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==6, cx, JS_FALSE, "Invalid number of arguments"); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - JSB_PRECONDITION( jsthis, "Invalid jsthis object"); - - struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); - void *handle = proxy->handle; - - return __jsb_cpSpace_addCollisionHandler(cx, vp, JS_ARGV(cx,vp), (cpSpace*)handle, 1); -} - -#pragma mark removeCollisionHandler - -static -JSBool __jsb_cpSpace_removeCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, cpSpace *space) -{ - JSBool ok = JS_TRUE; - - cpCollisionType typeA; - cpCollisionType typeB; - ok &= jsval_to_int(cx, *argvp++, (int32_t*) &typeA ); - ok &= jsval_to_int(cx, *argvp++, (int32_t*) &typeB ); - - JSB_PRECONDITION(ok, "Error parsing arguments"); - - cpSpaceRemoveCollisionHandler(space, typeA, typeB ); - - // Remove it - struct collision_handler *hashElement = NULL; - unsigned long key = pair_ints(typeA, typeB ); - HASH_FIND_INT(collision_handler_hash, &key, hashElement); - if( hashElement ) { - - // unroot it - if( hashElement->begin ) - JS_RemoveObjectRoot(cx, &hashElement->begin); - if( hashElement->pre ) - JS_RemoveObjectRoot(cx, &hashElement->pre); - if( hashElement->post ) - JS_RemoveObjectRoot(cx, &hashElement->post); - if( hashElement->separate ) - JS_RemoveObjectRoot(cx, &hashElement->separate); - - HASH_DEL( collision_handler_hash, hashElement ); - free( hashElement ); - } - - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; -} - -// Free function -JSBool JSB_cpSpaceRemoveCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==3, cx, JS_FALSE, "Invalid number of arguments"); - - jsval *argvp = JS_ARGV(cx,vp); - - cpSpace* space; - JSBool ok = jsval_to_opaque( cx, *argvp++, (void**)&space); - - JSB_PRECONDITION(ok, "Error parsing arguments"); - - return __jsb_cpSpace_removeCollisionHandler(cx, vp, argvp, space); -} - -// method -JSBool JSB_cpSpace_removeCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==2, cx, JS_FALSE, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - JSB_PRECONDITION( jsthis, "Invalid jsthis object"); - - struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); - void *handle = proxy->handle; - - return __jsb_cpSpace_removeCollisionHandler(cx, vp, JS_ARGV(cx,vp), (cpSpace*)handle); -} - -#pragma mark Add functios. Root JSObjects - -// Arguments: cpBody* -// Ret value: cpBody* -JSBool JSB_cpSpace_addBody(JSContext *cx, uint32_t argc, jsval *vp) { - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); - cpSpace* arg0 = (cpSpace*) proxy->handle; - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpBody* arg1; - - jsval retval = *argvp; struct jsb_c_proxy_s *retproxy; - ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); - JSB_PRECONDITION(ok, "Error processing arguments"); - - cpSpaceAddBody((cpSpace*)arg0 , (cpBody*)arg1 ); - - // Root it: - JS_AddNamedObjectRoot(cx, &retproxy->jsobj, "cpBody"); - - // addBody returns the same object that was added, so return it without conversions - JS_SET_RVAL(cx, vp, retval); - - return JS_TRUE; -} - -// Arguments: cpConstraint* -// Ret value: cpConstraint* -JSBool JSB_cpSpace_addConstraint(JSContext *cx, uint32_t argc, jsval *vp) { - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); - cpSpace* arg0 = (cpSpace*) proxy->handle; - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpConstraint* arg1; - - jsval retval = *argvp; struct jsb_c_proxy_s *retproxy; - ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); - JSB_PRECONDITION(ok, "Error processing arguments"); - - cpSpaceAddConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); - - // Root it: - JS_AddNamedObjectRoot(cx, &retproxy->jsobj, "cpConstraint"); - - // addConstraint returns the same object that was added, so return it without conversions - JS_SET_RVAL(cx, vp, retval); - - return JS_TRUE; -} - -// Arguments: cpShape* -// Ret value: cpShape* -JSBool JSB_cpSpace_addShape(JSContext *cx, uint32_t argc, jsval *vp) { - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); - cpSpace* arg0 = (cpSpace*) proxy->handle; - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpShape* arg1; - - jsval retval = *argvp; struct jsb_c_proxy_s *retproxy; - ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); - JSB_PRECONDITION(ok, "Error processing arguments"); - - cpSpaceAddShape((cpSpace*)arg0 , (cpShape*)arg1 ); - - // Root it: - JS_AddNamedObjectRoot(cx, &retproxy->jsobj, "cpShape"); - - // addShape returns the same object that was added, so return it without conversions - JS_SET_RVAL(cx, vp, retval); - - return JS_TRUE; -} - -// Arguments: cpShape* -// Ret value: cpShape* -JSBool JSB_cpSpace_addStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); - cpSpace* arg0 = (cpSpace*) proxy->handle; - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpShape* arg1; - - jsval retval = *argvp; struct jsb_c_proxy_s *retproxy; - ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); - JSB_PRECONDITION(ok, "Error processing arguments"); - - cpSpaceAddStaticShape((cpSpace*)arg0 , (cpShape*)arg1 ); - - // Root it: - JS_AddNamedObjectRoot(cx, &retproxy->jsobj, "cpShape (static)"); - - // addStaticShape returns the same object that was added, so return it without conversions - JS_SET_RVAL(cx, vp, retval); - - return JS_TRUE; -} - -#pragma mark Remove functios. Untoot JSObjects - -// Arguments: cpBody* -// Ret value: void -JSBool JSB_cpSpace_removeBody(JSContext *cx, uint32_t argc, jsval *vp) { - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); - cpSpace* arg0 = (cpSpace*) proxy->handle; - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpBody* arg1; - - struct jsb_c_proxy_s *retproxy; - ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); - JSB_PRECONDITION(ok, "Error processing arguments"); - - cpSpaceRemoveBody((cpSpace*)arg0 , (cpBody*)arg1 ); - JS_RemoveObjectRoot(cx, &retproxy->jsobj); - - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; -} - -// Arguments: cpConstraint* -// Ret value: void -JSBool JSB_cpSpace_removeConstraint(JSContext *cx, uint32_t argc, jsval *vp) { - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); - cpSpace* arg0 = (cpSpace*) proxy->handle; - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpConstraint* arg1; - - struct jsb_c_proxy_s *retproxy; - ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); - JSB_PRECONDITION(ok, "Error processing arguments"); - - cpSpaceRemoveConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); - JS_RemoveObjectRoot(cx, &retproxy->jsobj); - - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; -} - -// Arguments: cpShape* -// Ret value: void -JSBool JSB_cpSpace_removeShape(JSContext *cx, uint32_t argc, jsval *vp) { - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); - cpSpace* arg0 = (cpSpace*) proxy->handle; - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpShape* arg1; - - struct jsb_c_proxy_s *retproxy; - ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); - JSB_PRECONDITION(ok, "Error processing arguments"); - - cpSpaceRemoveShape((cpSpace*)arg0 , (cpShape*)arg1 ); - JS_RemoveObjectRoot(cx, &retproxy->jsobj); - - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; -} - -// Arguments: cpShape* -// Ret value: void -JSBool JSB_cpSpace_removeStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); - cpSpace* arg0 = (cpSpace*) proxy->handle; - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpShape* arg1; - - struct jsb_c_proxy_s *retproxy; - ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); - JSB_PRECONDITION(ok, "Error processing arguments"); - - cpSpaceRemoveStaticShape((cpSpace*)arg0 , (cpShape*)arg1 ); - JS_RemoveObjectRoot(cx, &retproxy->jsobj); - - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; -} -#pragma mark - Arbiter - -#pragma mark getBodies -static -JSBool __jsb_cpArbiter_getBodies(JSContext *cx, jsval *vp, jsval *argvp, cpArbiter *arbiter, unsigned int is_oo) -{ - cpBody *bodyA; - cpBody *bodyB; - cpArbiterGetBodies(arbiter, &bodyA, &bodyB); - - jsval valA, valB; - if( is_oo ) { - valA = c_class_to_jsval(cx, bodyA, JSB_cpBody_object, JSB_cpBody_class, "cpArbiter"); - valB = c_class_to_jsval(cx, bodyB, JSB_cpBody_object, JSB_cpBody_class, "cpArbiter"); - } else { - valA = opaque_to_jsval(cx, bodyA); - valB = opaque_to_jsval(cx, bodyB); - } - - JSObject *jsobj = JS_NewArrayObject(cx, 2, NULL); - JS_SetElement(cx, jsobj, 0, &valA); - JS_SetElement(cx, jsobj, 1, &valB); - - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); - - return JS_TRUE; -} - -// Free function -JSBool JSB_cpArbiterGetBodies(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - - jsval *argvp = JS_ARGV(cx,vp); - - cpArbiter* arbiter; - if( ! jsval_to_opaque( cx, *argvp++, (void**)&arbiter ) ) - return JS_FALSE; - - return __jsb_cpArbiter_getBodies(cx, vp, argvp, arbiter, 0); -} - -// Method -JSBool JSB_cpArbiter_getBodies(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - JSB_PRECONDITION( jsthis, "Invalid jsthis object"); - - struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); - JSB_PRECONDITION( proxy, "Invalid private object"); - void *handle = proxy->handle; - - return __jsb_cpArbiter_getBodies(cx, vp, JS_ARGV(cx,vp), (cpArbiter*)handle, 1); -} - -#pragma mark getShapes -static -JSBool __jsb_cpArbiter_getShapes(JSContext *cx, jsval *vp, jsval *argvp, cpArbiter *arbiter, unsigned int is_oo) -{ - cpShape *shapeA; - cpShape *shapeB; - cpArbiterGetShapes(arbiter, &shapeA, &shapeB); - - jsval valA, valB; - if( is_oo ) { - valA = c_class_to_jsval(cx, shapeA, JSB_cpShape_object, JSB_cpShape_class, "cpShape"); - valB = c_class_to_jsval(cx, shapeB, JSB_cpShape_object, JSB_cpShape_class, "cpShape"); - } else { - valA = opaque_to_jsval(cx, shapeA); - valB = opaque_to_jsval(cx, shapeB); - } - - JSObject *jsobj = JS_NewArrayObject(cx, 2, NULL); - JS_SetElement(cx, jsobj, 0, &valA); - JS_SetElement(cx, jsobj, 1, &valB); - - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); - - return JS_TRUE; -} - -// function -JSBool JSB_cpArbiterGetShapes(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - - jsval *argvp = JS_ARGV(cx,vp); - - cpArbiter* arbiter; - if( ! jsval_to_opaque( cx, *argvp++, (void**) &arbiter ) ) - return JS_FALSE; - - return __jsb_cpArbiter_getShapes(cx, vp, argvp, arbiter, 0); -} - -// method -JSBool JSB_cpArbiter_getShapes(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - JSB_PRECONDITION( jsthis, "Invalid jsthis object"); - - struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); - void *handle = proxy->handle; - - return __jsb_cpArbiter_getShapes(cx, vp, JS_ARGV(cx,vp), (cpArbiter*)handle, 1); -} - -#pragma mark - Body - -#pragma mark constructor - -// Manually added to identify static vs dynamic bodies -JSBool JSB_cpBody_constructor(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==2, cx, JS_FALSE, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpBody_class, JSB_cpBody_object, NULL); - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - double m; double i; - - ok &= JS_ValueToNumber( cx, *argvp++, &m ); - ok &= JS_ValueToNumber( cx, *argvp++, &i ); - JSB_PRECONDITION(ok, "Error processing arguments"); - - cpBody *ret_body = NULL; - if( m == INFINITY && i == INFINITY) { - ret_body = cpBodyNewStatic(); - - // XXX: Hack. IT WILL LEAK "rogue" objects., But at least it prevents a crash. - // The thing is that "rogue" bodies needs to be freed after the its shape, and I am not sure - // how to do it in a "js" way. - jsb_set_c_proxy_for_jsobject(jsobj, ret_body, JSB_C_FLAG_DO_NOT_CALL_FREE); - } else { - ret_body = cpBodyNew((cpFloat)m , (cpFloat)i ); - jsb_set_c_proxy_for_jsobject(jsobj, ret_body, JSB_C_FLAG_CALL_FREE); - } - - jsb_set_jsobject_for_proxy(jsobj, ret_body); - - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); - return JS_TRUE; -} - -#pragma mark getUserData - -static -JSBool __jsb_cpBody_getUserData(JSContext *cx, jsval *vp, jsval *argvp, cpBody *body) -{ - JSObject *data = (JSObject*) cpBodyGetUserData(body); - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(data)); - - return JS_TRUE; -} - -// free function -JSBool JSB_cpBodyGetUserData(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - - jsval *argvp = JS_ARGV(cx,vp); - cpBody *body; - if( ! jsval_to_opaque( cx, *argvp++, (void**) &body ) ) - return JS_FALSE; - - return __jsb_cpBody_getUserData(cx, vp, argvp, body); -} - -// method -JSBool JSB_cpBody_getUserData(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - JSB_PRECONDITION( jsthis, "Invalid jsthis object"); - - struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); - void *handle = proxy->handle; - - return __jsb_cpBody_getUserData(cx, vp, JS_ARGV(cx,vp), (cpBody*)handle); -} - - -#pragma mark setUserData - -static -JSBool __jsb_cpBody_setUserData(JSContext *cx, jsval *vp, jsval *argvp, cpBody *body) -{ - JSObject *jsobj; - - JSBool ok = JS_ValueToObject(cx, *argvp++, &jsobj); - - JSB_PRECONDITION(ok, "Error parsing arguments"); - - cpBodySetUserData(body, jsobj); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - - return JS_TRUE; -} - -// free function -JSBool JSB_cpBodySetUserData(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==2, cx, JS_FALSE, "Invalid number of arguments"); - - jsval *argvp = JS_ARGV(cx,vp); - cpBody *body; - JSBool ok = jsval_to_opaque( cx, *argvp++, (void**) &body ); - JSB_PRECONDITION(ok, "Error parsing arguments"); - return __jsb_cpBody_setUserData(cx, vp, argvp, body); -} - -// method -JSBool JSB_cpBody_setUserData(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - JSB_PRECONDITION( jsthis, "Invalid jsthis object"); - - struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); - void *handle = proxy->handle; - - return __jsb_cpBody_setUserData(cx, vp, JS_ARGV(cx,vp), (cpBody*)handle); -} - -#pragma mark - Poly related - -// cpFloat cpAreaForPoly(const int numVerts, const cpVect *verts); -JSBool JSB_cpAreaForPoly(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpVect *verts; - int numVerts; - - ok &= jsval_to_array_of_cpvect( cx, *argvp++, &verts, &numVerts); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error parsing array"); - - cpFloat area = cpAreaForPoly(numVerts, verts); - - free(verts); - - JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(area)); - return JS_TRUE; -} - -// cpFloat cpMomentForPoly(cpFloat m, int numVerts, const cpVect *verts, cpVect offset); -JSBool JSB_cpMomentForPoly(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==3, cx, JS_FALSE, "Invalid number of arguments"); - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpVect *verts; cpVect offset; - int numVerts; - double m; - - ok &= JS_ValueToNumber(cx, *argvp++, &m); - ok &= jsval_to_array_of_cpvect( cx, *argvp++, &verts, &numVerts); - ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &offset ); - - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error parsing args"); - - cpFloat moment = cpMomentForPoly((cpFloat)m, numVerts, verts, offset); - - free(verts); - - JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(moment)); - return JS_TRUE; -} - -// cpVect cpCentroidForPoly(const int numVerts, const cpVect *verts); -JSBool JSB_cpCentroidForPoly(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpVect *verts; - int numVerts; - - ok &= jsval_to_array_of_cpvect( cx, *argvp++, &verts, &numVerts); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error parsing args"); - - cpVect centroid = cpCentroidForPoly(numVerts, verts); - - free(verts); - - JS_SET_RVAL(cx, vp, cpVect_to_jsval(cx, (cpVect)centroid)); - return JS_TRUE; -} - -// void cpRecenterPoly(const int numVerts, cpVect *verts); -JSBool JSB_cpRecenterPoly(JSContext *cx, uint32_t argc, jsval *vp) -{ - CCASSERT(false, "NOT IMPLEMENTED"); - return JS_FALSE; -} - -#pragma mark - Object Oriented Chipmunk - -/* - * Chipmunk Base Object - */ - -JSClass* JSB_cpBase_class = NULL; -JSObject* JSB_cpBase_object = NULL; -// Constructor -JSBool JSB_cpBase_constructor(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2( argc==1, cx, JS_FALSE, "Invalid arguments. Expecting 1"); - - JSObject *jsobj = JS_NewObject(cx, JSB_cpBase_class, JSB_cpBase_object, NULL); - - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - - void *handle = NULL; - - ok = jsval_to_opaque(cx, *argvp++, &handle); - - JSB_PRECONDITION(ok, "Error converting arguments for JSB_cpBase_constructor"); - - jsb_set_c_proxy_for_jsobject(jsobj, handle, JSB_C_FLAG_DO_NOT_CALL_FREE); - jsb_set_jsobject_for_proxy(jsobj, handle); - - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); - return JS_TRUE; -} - -// Destructor -void JSB_cpBase_finalize(JSFreeOp *fop, JSObject *obj) -{ - CCLOGINFO("jsbindings: finalizing JS object %p (cpBase)", obj); - - // should not delete the handle since it was manually added -} - -JSBool JSB_cpBase_getHandle(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - JSB_PRECONDITION( jsthis, "Invalid jsthis object"); - JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); - - struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); - void *handle = proxy->handle; - - jsval ret_val = opaque_to_jsval(cx, handle); - JS_SET_RVAL(cx, vp, ret_val); - return JS_TRUE; -} - -JSBool JSB_cpBase_setHandle(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - JSB_PRECONDITION( jsthis, "Invalid jsthis object"); - JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); - - jsval *argvp = JS_ARGV(cx,vp); - - void *handle; - JSBool ok = jsval_to_opaque(cx, *argvp++, &handle); - JSB_PRECONDITION( ok, "Invalid parsing arguments"); - - jsb_set_c_proxy_for_jsobject(jsthis, handle, JSB_C_FLAG_DO_NOT_CALL_FREE); - jsb_set_jsobject_for_proxy(jsthis, handle); - - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; -} - - -void JSB_cpBase_createClass(JSContext *cx, JSObject* globalObj, const char* name ) -{ - JSB_cpBase_class = (JSClass *)calloc(1, sizeof(JSClass)); - JSB_cpBase_class->name = name; - JSB_cpBase_class->addProperty = JS_PropertyStub; - JSB_cpBase_class->delProperty = JS_DeletePropertyStub; - JSB_cpBase_class->getProperty = JS_PropertyStub; - JSB_cpBase_class->setProperty = JS_StrictPropertyStub; - JSB_cpBase_class->enumerate = JS_EnumerateStub; - JSB_cpBase_class->resolve = JS_ResolveStub; - JSB_cpBase_class->convert = JS_ConvertStub; - JSB_cpBase_class->finalize = JSB_cpBase_finalize; - JSB_cpBase_class->flags = JSCLASS_HAS_PRIVATE; - - static JSPropertySpec properties[] = { - {0, 0, 0, 0, 0} - }; - static JSFunctionSpec funcs[] = { - JS_FN("getHandle", JSB_cpBase_getHandle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setHandle", JSB_cpBase_setHandle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - static JSFunctionSpec st_funcs[] = { - JS_FS_END - }; - - JSB_cpBase_object = JS_InitClass(cx, globalObj, NULL, JSB_cpBase_class, JSB_cpBase_constructor,0,properties,funcs,NULL,st_funcs); - JSBool found; - JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); -} - -// Manual "methods" -// Constructor -JSBool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSB_PRECONDITION2(argc==3, cx, JS_FALSE, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpPolyShape_class, JSB_cpPolyShape_object, NULL); - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - cpBody* body; cpVect *verts; cpVect offset; - int numVerts; - - ok &= jsval_to_c_class( cx, *argvp++, (void**)&body, NULL ); - ok &= jsval_to_array_of_cpvect( cx, *argvp++, &verts, &numVerts); - ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &offset ); - JSB_PRECONDITION(ok, "Error processing arguments"); - cpShape *shape = cpPolyShapeNew(body, numVerts, verts, offset); - - jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_DO_NOT_CALL_FREE); - jsb_set_jsobject_for_proxy(jsobj, shape); - - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); - - free(verts); - - return JS_TRUE; -} - - -#pragma mark Space Free functions -// -// When the space is removed, it should all remove its children. But not "free" them. -// "free" will be performed by the JS Garbage Collector -// -// Functions copied & pasted from ChipmunkDemo.c -// https://github.com/slembcke/Chipmunk-Physics/blob/master/Demo/ChipmunkDemo.c#L89 -// - -static void unroot_jsobject_from_handle(void *handle) -{ - JSObject *jsobj = jsb_get_jsobject_for_proxy(handle); - struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsobj); - - // HACK context from global - JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_RemoveObjectRoot(cx, &proxy->jsobj); - -} -static void shapeFreeWrap(cpSpace *space, cpShape *shape, void *unused){ - cpSpaceRemoveShape(space, shape); - unroot_jsobject_from_handle(shape); -// cpShapeFree(shape); -} - -static void postShapeFree(cpShape *shape, cpSpace *space){ - cpSpaceAddPostStepCallback(space, (cpPostStepFunc)shapeFreeWrap, shape, NULL); -} - -static void constraintFreeWrap(cpSpace *space, cpConstraint *constraint, void *unused){ - cpSpaceRemoveConstraint(space, constraint); - unroot_jsobject_from_handle(constraint); -// cpConstraintFree(constraint); -} - -static void postConstraintFree(cpConstraint *constraint, cpSpace *space){ - cpSpaceAddPostStepCallback(space, (cpPostStepFunc)constraintFreeWrap, constraint, NULL); -} - -static void bodyFreeWrap(cpSpace *space, cpBody *body, void *unused){ - cpSpaceRemoveBody(space, body); - unroot_jsobject_from_handle(body); -// cpBodyFree(body); -} - -static void postBodyFree(cpBody *body, cpSpace *space){ - cpSpaceAddPostStepCallback(space, (cpPostStepFunc)bodyFreeWrap, body, NULL); -} - -// Safe and future proof way to remove and free all objects that have been added to the space. -void static freeSpaceChildren(cpSpace *space) -{ - // Must remove these BEFORE freeing the body or you will access dangling pointers. - cpSpaceEachShape(space, (cpSpaceShapeIteratorFunc)postShapeFree, space); - cpSpaceEachConstraint(space, (cpSpaceConstraintIteratorFunc)postConstraintFree, space); - - cpSpaceEachBody(space, (cpSpaceBodyIteratorFunc)postBodyFree, space); -} - -#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_manual.h b/cocos/scripting/javascript/bindings/js_bindings_chipmunk_manual.h deleted file mode 100644 index c6b40ca757..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_manual.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * JS Bindings: https://github.com/zynga/jsbindings - * - * Copyright (c) 2012 Zynga Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - - -#ifndef __js_bindings_chipmunk_manual -#define __js_bindings_chipmunk_manual - -#include "js_bindings_config.h" -#include "cocosjs_manual_conversions.h" -#include "js_manual_conversions.h" -#include "ScriptingCore.h" -#ifdef JSB_INCLUDE_CHIPMUNK - -#include "chipmunk.h" -#include "jsapi.h" - -#include "js_bindings_chipmunk_auto_classes.h" - -// Free Functions -JSBool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpaceRemoveCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); - -JSBool JSB_cpArbiterGetBodies(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiterGetShapes(JSContext *cx, uint32_t argc, jsval *vp); - -JSBool JSB_cpBodyGetUserData(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBodySetUserData(JSContext *cx, uint32_t argc, jsval *vp); - -// poly related -JSBool JSB_cpAreaForPoly(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpMomentForPoly(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpCentroidForPoly(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpRecenterPoly(JSContext *cx, uint32_t argc, jsval *vp); - -// "Methods" from the OO API -JSBool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpace_removeCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); - -// manually wrapped for rooting/unrooting purposes -JSBool JSB_cpSpace_addBody(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpace_addConstraint(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpace_addShape(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpace_addStaticShape(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpace_removeBody(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpace_removeConstraint(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpace_removeShape(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpSpace_removeStaticShape(JSContext *cx, uint32_t argc, jsval *vp); - - -JSBool JSB_cpArbiter_getBodies(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpArbiter_getShapes(JSContext *cx, uint32_t argc, jsval *vp); - -JSBool JSB_cpBody_constructor(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBody_getUserData(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_cpBody_setUserData(JSContext *cx, uint32_t argc, jsval *vp); - - -// convertions - -jsval cpBB_to_jsval(JSContext *cx, cpBB bb ); -JSBool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ); -JSBool jsval_to_array_of_cpvect( JSContext *cx, jsval vp, cpVect**verts, int *numVerts); - -// requires cocos2d -#define cpVect_to_jsval CGPoint_to_jsval -#define jsval_to_cpVect jsval_to_CGPoint - - -// Object Oriented Chipmunk -void JSB_cpBase_createClass(JSContext* cx, JSObject* globalObj, const char * name ); -extern JSObject* JSB_cpBase_object; -extern JSClass* JSB_cpBase_class; -extern void register_CCPhysicsSprite(JSContext *cx, JSObject *obj); -extern void register_CCPhysicsDebugNode(JSContext *cx, JSObject *obj); - -// Manual constructor / destructors -JSBool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp); -void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *obj); - -#endif // JSB_INCLUDE_CHIPMUNK - -#endif // __js_bindings_chipmunk_manual diff --git a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_registration.cpp b/cocos/scripting/javascript/bindings/js_bindings_chipmunk_registration.cpp deleted file mode 100644 index a96434eace..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_registration.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * JS Bindings: https://github.com/zynga/jsbindings - * - * Copyright (c) 2012 Zynga Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef JSB_INCLUDE_CHIPMUNK -#define JSB_INCLUDE_CHIPMUNK -#endif - -#include "js_bindings_config.h" -#include "ScriptingCore.h" - - -// chipmunk -#include "js_bindings_chipmunk_auto_classes.h" -#include "js_bindings_chipmunk_functions.h" -#include "js_bindings_chipmunk_manual.h" - - -void jsb_register_chipmunk(JSContext *_cx, JSObject *object) -{ - // - // Chipmunk - // - JSObject *chipmunk = JS_NewObject(_cx, NULL, NULL, NULL); - jsval chipmunkVal = OBJECT_TO_JSVAL(chipmunk); - JS_SetProperty(_cx, object, "cp", &chipmunkVal); - - JSB_cpBase_createClass(_cx, chipmunk, "Base"); // manual base class registration -#include "js_bindings_chipmunk_auto_classes_registration.h" -#include "js_bindings_chipmunk_functions_registration.h" - - // manual - JS_DefineFunction(_cx, chipmunk, "spaceAddCollisionHandler", JSB_cpSpaceAddCollisionHandler, 8, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); - JS_DefineFunction(_cx, chipmunk, "spaceRemoveCollisionHandler", JSB_cpSpaceRemoveCollisionHandler, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); - JS_DefineFunction(_cx, chipmunk, "arbiterGetBodies", JSB_cpArbiterGetBodies, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); - JS_DefineFunction(_cx, chipmunk, "arbiterGetShapes", JSB_cpArbiterGetShapes, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); - JS_DefineFunction(_cx, chipmunk, "bodyGetUserData", JSB_cpBodyGetUserData, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); - JS_DefineFunction(_cx, chipmunk, "bodySetUserData", JSB_cpBodySetUserData, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); - - JS_DefineFunction(_cx, chipmunk, "areaForPoly", JSB_cpAreaForPoly, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); - JS_DefineFunction(_cx, chipmunk, "momentForPoly", JSB_cpMomentForPoly, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); - JS_DefineFunction(_cx, chipmunk, "centroidForPoly", JSB_cpCentroidForPoly, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); - JS_DefineFunction(_cx, chipmunk, "recenterPoly", JSB_cpRecenterPoly, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); - register_CCPhysicsSprite(_cx, object); - register_CCPhysicsDebugNode(_cx, object); -} - diff --git a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_registration.h b/cocos/scripting/javascript/bindings/js_bindings_chipmunk_registration.h deleted file mode 100644 index 90bc320b87..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_chipmunk_registration.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * JS Bindings: https://github.com/zynga/jsbindings - * - * Copyright (c) 2012 Zynga Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - - -#ifndef __JSB_CHIPMUNK_REGISTRATION -#define __JSB_CHIPMUNK_REGISTRATION - -void jsb_register_chipmunk( JSContext *globalC, JSObject *globalO); - -#endif // __JSB_CHIPMUNK_REGISTRATION diff --git a/cocos/scripting/javascript/bindings/js_bindings_core.cpp b/cocos/scripting/javascript/bindings/js_bindings_core.cpp index 295184cbb8..fbb6e808fb 100644 --- a/cocos/scripting/javascript/bindings/js_bindings_core.cpp +++ b/cocos/scripting/javascript/bindings/js_bindings_core.cpp @@ -26,7 +26,7 @@ // cocos2d + chipmunk registration files -#include "js_bindings_chipmunk_registration.h" +#include "chipmunk/js_bindings_chipmunk_registration.h" //#pragma mark - Hash diff --git a/cocos/scripting/javascript/bindings/js_bindings_system_functions.cpp b/cocos/scripting/javascript/bindings/js_bindings_system_functions.cpp deleted file mode 100644 index 7d1a819fc8..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_system_functions.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -* AUTOGENERATED FILE. DO NOT EDIT IT -* Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 -* Script version: v0.5 -*/ -#include "cocos2d.h" -#include "js_bindings_config.h" -//#ifdef JSB_INCLUDE_SYSTEM - -#include "local-storage/LocalStorage.h" - -#include "jsfriendapi.h" -#include "js_bindings_config.h" -#include "js_bindings_core.h" -#include "js_manual_conversions.h" -#include "js_bindings_system_functions.h" -#include "ScriptingCore.h" - -USING_NS_CC; - -// Arguments: char* -// Ret value: const char* -JSBool JSB_localStorageGetItem(JSContext *cx, uint32_t argc, jsval *vp) { - JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - const char* arg0; - - ok &= jsval_to_charptr( cx, *argvp++, &arg0 ); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - const char* ret_val; - - ret_val = localStorageGetItem((char*)arg0 ); - - jsval ret_jsval = c_string_to_jsval(cx, ret_val ? ret_val : ""); - JS_SET_RVAL(cx, vp, ret_jsval ); - - return JS_TRUE; -} - -// Arguments: char* -// Ret value: void -JSBool JSB_localStorageRemoveItem(JSContext *cx, uint32_t argc, jsval *vp) { - JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - const char* arg0; - - ok &= jsval_to_charptr( cx, *argvp++, &arg0 ); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - - localStorageRemoveItem((char*)arg0 ); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; -} - -// Arguments: char*, char* -// Ret value: void -JSBool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp) { - JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); - jsval *argvp = JS_ARGV(cx,vp); - JSBool ok = JS_TRUE; - const char* arg0; const char* arg1; - - ok &= jsval_to_charptr( cx, *argvp++, &arg0 ); - ok &= jsval_to_charptr( cx, *argvp++, &arg1 ); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - - localStorageSetItem((char*)arg0 , (char*)arg1 ); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; -} - - -//#endif // JSB_INCLUDE_SYSTEM diff --git a/cocos/scripting/javascript/bindings/js_bindings_system_functions.h b/cocos/scripting/javascript/bindings/js_bindings_system_functions.h deleted file mode 100644 index 26d4a97c99..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_system_functions.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -* AUTOGENERATED FILE. DO NOT EDIT IT -* Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 -* Script version: v0.5 -*/ -#include "js_bindings_config.h" -//#ifdef JSB_INCLUDE_SYSTEM - -//#include "LocalStorage.h" - -#ifdef __cplusplus -extern "C" { -#endif -JSBool JSB_localStorageGetItem(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_localStorageRemoveItem(JSContext *cx, uint32_t argc, jsval *vp); -JSBool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp); - -#ifdef __cplusplus -} -#endif - - -//#endif // JSB_INCLUDE_SYSTEM diff --git a/cocos/scripting/javascript/bindings/js_bindings_system_functions_registration.h b/cocos/scripting/javascript/bindings/js_bindings_system_functions_registration.h deleted file mode 100644 index 5bce81d241..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_system_functions_registration.h +++ /dev/null @@ -1,15 +0,0 @@ -/* -* AUTOGENERATED FILE. DO NOT EDIT IT -* Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 -* Script version: v0.5 -*/ -#include "js_bindings_config.h" -//#ifdef JSB_INCLUDE_SYSTEM - -//#include "LocalStorage.h" -JS_DefineFunction(_cx, system, "getItem", JSB_localStorageGetItem, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, system, "removeItem", JSB_localStorageRemoveItem, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); -JS_DefineFunction(_cx, system, "setItem", JSB_localStorageSetItem, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); - - -//#endif // JSB_INCLUDE_SYSTEM diff --git a/cocos/scripting/javascript/bindings/js_bindings_system_registration.cpp b/cocos/scripting/javascript/bindings/js_bindings_system_registration.cpp deleted file mode 100644 index bf55e188f0..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_system_registration.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * JS Bindings: https://github.com/zynga/jsbindings - * - * Copyright (c) 2012 Zynga Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "js_bindings_config.h" -#include "js_bindings_core.h" -#include "local-storage/LocalStorage.h" -#include "cocos2d.h" - -// system -#include "js_bindings_system_functions.h" - - -void jsb_register_system( JSContext *_cx, JSObject *object) -{ - // - // sys - // - JSObject *sys = JS_NewObject(_cx, NULL, NULL, NULL); - jsval systemVal = OBJECT_TO_JSVAL(sys); - JS_SetProperty(_cx, object, "sys", &systemVal); - - - // sys.localStorage - JSObject *ls = JS_NewObject(_cx, NULL, NULL, NULL); - jsval lsVal = OBJECT_TO_JSVAL(ls); - JS_SetProperty(_cx, sys, "localStorage", &lsVal); - - // sys.localStorage functions - JSObject *system = ls; -#include "js_bindings_system_functions_registration.h" - - - // Init DB with full path - //NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; - //NSString *fullpath = [path stringByAppendingPathComponent:@"jsb.sqlite"]; - std::string strFilePath = cocos2d::FileUtils::getInstance()->getWritablePath(); - strFilePath += "/jsb.sqlite"; - localStorageInit(strFilePath.c_str()); - -} - diff --git a/cocos/scripting/javascript/bindings/js_bindings_system_registration.h b/cocos/scripting/javascript/bindings/js_bindings_system_registration.h deleted file mode 100644 index 1afb1b1081..0000000000 --- a/cocos/scripting/javascript/bindings/js_bindings_system_registration.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * JS Bindings: https://github.com/zynga/jsbindings - * - * Copyright (c) 2012 Zynga Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - - -#ifndef __JSB_SYSTEM_REGISTRATION -#define __JSB_SYSTEM_REGISTRATION - -void jsb_register_system( JSContext *globalC, JSObject *globalO); - -#endif // __JSB_CHIPMUNK_REGISTRATION diff --git a/cocos/scripting/javascript/bindings/jsb_cocos2dx_extension_manual.cpp b/cocos/scripting/javascript/bindings/jsb_cocos2dx_extension_manual.cpp deleted file mode 100644 index 413f941bca..0000000000 --- a/cocos/scripting/javascript/bindings/jsb_cocos2dx_extension_manual.cpp +++ /dev/null @@ -1,1015 +0,0 @@ -// -// jsb_cocos2d_extension_manual.cpp -// -// Created by James Chen on 3/11/13. -// -// - -#include "jsb_cocos2dx_extension_manual.h" -#include "extensions/cocos-ext.h" -#include "ScriptingCore.h" -#include "cocos2d_specifics.hpp" -#include "cocostudio/CocoStudio.h" - -USING_NS_CC; -USING_NS_CC_EXT; - - -class JSB_ScrollViewDelegate -: public Object -, public ScrollViewDelegate -{ -public: - JSB_ScrollViewDelegate() - : _JSDelegate(NULL) - , _needUnroot(false) - {} - - virtual ~JSB_ScrollViewDelegate() - { - if (_needUnroot) - { - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_RemoveObjectRoot(cx, &_JSDelegate); - } - } - - virtual void scrollViewDidScroll(ScrollView* view) - { - js_proxy_t * p = jsb_get_native_proxy(view); - if (!p) return; - - jsval arg = OBJECT_TO_JSVAL(p->obj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "scrollViewDidScroll", 1, &arg, NULL); - } - - virtual void scrollViewDidZoom(ScrollView* view) - { - js_proxy_t * p = jsb_get_native_proxy(view); - if (!p) return; - - jsval arg = OBJECT_TO_JSVAL(p->obj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "scrollViewDidZoom", 1, &arg, NULL); - } - - void setJSDelegate(JSObject* pJSDelegate) - { - _JSDelegate = pJSDelegate; - - // Check whether the js delegate is a pure js object. - js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); - if (!p) - { - _needUnroot = true; - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); - } - } -private: - JSObject* _JSDelegate; - bool _needUnroot; -}; - -static JSBool js_cocos2dx_CCScrollView_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - - if (argc == 1) - { - // save the delegate - JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); - JSB_ScrollViewDelegate* nativeDelegate = new JSB_ScrollViewDelegate(); - nativeDelegate->setJSDelegate(jsDelegate); - - cobj->setUserObject(nativeDelegate); - cobj->setDelegate(nativeDelegate); - - nativeDelegate->release(); - - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; - } - JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); - return JS_FALSE; -} - - -#define KEY_TABLEVIEW_DATA_SOURCE "TableViewDataSource" -#define KEY_TABLEVIEW_DELEGATE "TableViewDelegate" - -class JSB_TableViewDelegate -: public Object -, public TableViewDelegate -{ -public: - JSB_TableViewDelegate() - : _JSDelegate(NULL) - , _needUnroot(false) - {} - - virtual ~JSB_TableViewDelegate() - { - if (_needUnroot) - { - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_RemoveObjectRoot(cx, &_JSDelegate); - } - } - - virtual void scrollViewDidScroll(ScrollView* view) - { - callJSDelegate(view, "scrollViewDidScroll"); - } - - virtual void scrollViewDidZoom(ScrollView* view) - { - callJSDelegate(view, "scrollViewDidZoom"); - } - - virtual void tableCellTouched(TableView* table, TableViewCell* cell) - { - callJSDelegate(table, cell, "tableCellTouched"); - } - - virtual void tableCellHighlight(TableView* table, TableViewCell* cell) - { - callJSDelegate(table, cell, "tableCellHighlight"); - } - - virtual void tableCellUnhighlight(TableView* table, TableViewCell* cell) - { - callJSDelegate(table, cell, "tableCellUnhighlight"); - } - - virtual void tableCellWillRecycle(TableView* table, TableViewCell* cell) - { - callJSDelegate(table, cell, "tableCellWillRecycle"); - } - - void setJSDelegate(JSObject* pJSDelegate) - { - _JSDelegate = pJSDelegate; - - // Check whether the js delegate is a pure js object. - js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); - if (!p) - { - _needUnroot = true; - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); - } - } - - -private: - void callJSDelegate(ScrollView* view, std::string jsFunctionName) - { - js_proxy_t * p = jsb_get_native_proxy(view); - if (!p) return; - - jsval arg = OBJECT_TO_JSVAL(p->obj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), jsFunctionName.c_str(), 1, &arg, NULL); - } - - void callJSDelegate(TableView* table, TableViewCell* cell, std::string jsFunctionName) - { - js_proxy_t * p = jsb_get_native_proxy(table); - if (!p) return; - - js_proxy_t * pCellProxy = jsb_get_native_proxy(cell); - if (!pCellProxy) return; - - jsval args[2]; - args[0] = OBJECT_TO_JSVAL(p->obj); - args[1] = OBJECT_TO_JSVAL(pCellProxy->obj); - - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), jsFunctionName.c_str(), 2, args, NULL); - } - - JSObject* _JSDelegate; - bool _needUnroot; -}; - -static JSBool js_cocos2dx_CCTableView_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - - if (argc == 1) - { - // save the delegate - JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); - JSB_TableViewDelegate* nativeDelegate = new JSB_TableViewDelegate(); - nativeDelegate->setJSDelegate(jsDelegate); - - Dictionary* userDict = static_cast(cobj->getUserObject()); - if (NULL == userDict) - { - userDict = new Dictionary(); - cobj->setUserObject(userDict); - userDict->release(); - } - - userDict->setObject(nativeDelegate, KEY_TABLEVIEW_DELEGATE); - - cobj->setDelegate(nativeDelegate); - - nativeDelegate->release(); - - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; - } - JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); - return JS_FALSE; -} - -class JSB_TableViewDataSource -: public Object -, public TableViewDataSource -{ -public: - JSB_TableViewDataSource() - : _JSTableViewDataSource(NULL) - , _needUnroot(false) - {} - - virtual ~JSB_TableViewDataSource() - { - if (_needUnroot) - { - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_RemoveObjectRoot(cx, &_JSTableViewDataSource); - } - } - - virtual Size tableCellSizeForIndex(TableView *table, unsigned int idx) - { - jsval ret; - bool ok = callJSDelegate(table, idx, "tableCellSizeForIndex", ret); - if (!ok) - { - ok = callJSDelegate(table, "cellSizeForTable", ret); - } - if (ok) - { - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - Size size; - JSBool isSucceed = jsval_to_ccsize(cx, ret, &size); - if (isSucceed) return size; - } - return Size::ZERO; - - } - - virtual TableViewCell* tableCellAtIndex(TableView *table, unsigned int idx) - { - jsval ret; - bool ok = callJSDelegate(table, idx, "tableCellAtIndex", ret); - if (ok) - { - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - cocos2d::extension::TableViewCell* arg0; - do { - js_proxy_t *proxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(ret); - proxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::extension::TableViewCell*)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, NULL, "Invalid Native Object"); - } while (0); - return arg0; - } - return NULL; - } - - virtual unsigned int numberOfCellsInTableView(TableView *table) - { - jsval ret; - bool ok = callJSDelegate(table, "numberOfCellsInTableView", ret); - if (ok) - { - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - uint32_t count = 0; - JSBool isSucceed = jsval_to_uint32(cx, ret, &count); - if (isSucceed) return count; - } - return 0; - } - - - void setTableViewDataSource(JSObject* pJSSource) - { - _JSTableViewDataSource = pJSSource; - - // Check whether the js delegate is a pure js object. - js_proxy_t* p = jsb_get_js_proxy(_JSTableViewDataSource); - if (!p) - { - _needUnroot = true; - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_AddNamedObjectRoot(cx, &_JSTableViewDataSource, "TableViewDataSource"); - } - } - -private: - bool callJSDelegate(TableView* table, std::string jsFunctionName, jsval& retVal) - { - js_proxy_t * p = jsb_get_native_proxy(table); - if (!p) return false; - - JSBool hasAction; - jsval temp_retval; - jsval dataVal = OBJECT_TO_JSVAL(p->obj); - - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JSObject* obj = _JSTableViewDataSource; - - if (JS_HasProperty(cx, obj, jsFunctionName.c_str(), &hasAction) && hasAction) - { - if(!JS_GetProperty(cx, obj, jsFunctionName.c_str(), &temp_retval)) - { - return false; - } - if(temp_retval == JSVAL_VOID) - { - return false; - } - - JSAutoCompartment ac(cx, obj); - JS_CallFunctionName(cx, obj, jsFunctionName.c_str(), - 1, &dataVal, &retVal); - return true; - } - return false; - } - - bool callJSDelegate(TableView* table, int idx, std::string jsFunctionName, jsval& retVal) - { - js_proxy_t * p = jsb_get_native_proxy(table); - if (!p) return false; - - - JSBool hasAction; - jsval temp_retval; - jsval dataVal[2]; - dataVal[0] = OBJECT_TO_JSVAL(p->obj); - dataVal[1] = INT_TO_JSVAL(idx); - - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JSObject* obj = _JSTableViewDataSource; - - if (JS_HasProperty(cx, obj, jsFunctionName.c_str(), &hasAction) && hasAction) - { - if(!JS_GetProperty(cx, obj, jsFunctionName.c_str(), &temp_retval)) - { - return false; - } - - if(temp_retval == JSVAL_VOID) - { - return false; - } - - JSAutoCompartment ac(cx, obj); - JS_CallFunctionName(cx, obj, jsFunctionName.c_str(), - 2, dataVal, &retVal); - return true; - } - return false; - } - -private: - JSObject* _JSTableViewDataSource; - bool _needUnroot; -}; - -static JSBool js_cocos2dx_CCTableView_setDataSource(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - if (argc == 1) - { - JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); - pNativeSource->setTableViewDataSource(JSVAL_TO_OBJECT(argv[0])); - - Dictionary* userDict = static_cast(cobj->getUserObject()); - if (NULL == userDict) - { - userDict = new Dictionary(); - cobj->setUserObject(userDict); - userDict->release(); - } - - userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); - - cobj->setDataSource(pNativeSource); - - pNativeSource->release(); - - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; - } - - JS_ReportError(cx, "wrong number of arguments"); - return JS_FALSE; -} - -static JSBool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - JSBool ok = JS_TRUE; - if (argc == 3 || argc == 2) - { - - JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); - pNativeSource->setTableViewDataSource(JSVAL_TO_OBJECT(argv[0])); - - cocos2d::Size arg1; - ok &= jsval_to_ccsize(cx, argv[1], &arg1); - cocos2d::extension::TableView* ret = NULL; - ret = new TableView(); - ret->autorelease(); - - ret->setDataSource(pNativeSource); - - jsval jsret; - do { - if (ret) - { - js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); - jsret = OBJECT_TO_JSVAL(proxy->obj); - } - else - { - jsret = JSVAL_NULL; - } - } while (0); - - if (argc == 2) - { - ret->initWithViewSize(arg1); - } - else - { - cocos2d::Node* arg2; - do - { - js_proxy_t *proxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); - proxy = jsb_get_js_proxy(tmpObj); - arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - ret->initWithViewSize(arg1, arg2); - } - ret->reloadData(); - - Dictionary* userDict = new Dictionary(); - userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); - ret->setUserObject(userDict); - userDict->release(); - - pNativeSource->release(); - - JS_SET_RVAL(cx, vp, jsret); - return JS_TRUE; - } - - JS_ReportError(cx, "wrong number of arguments"); - return JS_FALSE; -} - -class JSB_EditBoxDelegate -: public Object -, public EditBoxDelegate -{ -public: - JSB_EditBoxDelegate() - : _JSDelegate(NULL) - , _needUnroot(false) - {} - - virtual ~JSB_EditBoxDelegate() - { - if (_needUnroot) - { - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_RemoveObjectRoot(cx, &_JSDelegate); - } - } - - virtual void editBoxEditingDidBegin(EditBox* editBox) - { - js_proxy_t * p = jsb_get_native_proxy(editBox); - if (!p) return; - - jsval arg = OBJECT_TO_JSVAL(p->obj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxEditingDidBegin", 1, &arg, NULL); - } - - virtual void editBoxEditingDidEnd(EditBox* editBox) - { - js_proxy_t * p = jsb_get_native_proxy(editBox); - if (!p) return; - - jsval arg = OBJECT_TO_JSVAL(p->obj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxEditingDidEnd", 1, &arg, NULL); - } - - virtual void editBoxTextChanged(EditBox* editBox, const std::string& text) - { - js_proxy_t * p = jsb_get_native_proxy(editBox); - if (!p) return; - - jsval dataVal[2]; - dataVal[0] = OBJECT_TO_JSVAL(p->obj); - std::string arg1 = text; - dataVal[1] = std_string_to_jsval(ScriptingCore::getInstance()->getGlobalContext(), arg1); - - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxTextChanged", 2, dataVal, NULL); - } - - virtual void editBoxReturn(EditBox* editBox) - { - js_proxy_t * p = jsb_get_native_proxy(editBox); - if (!p) return; - - jsval arg = OBJECT_TO_JSVAL(p->obj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxReturn", 1, &arg, NULL); - } - - void setJSDelegate(JSObject* pJSDelegate) - { - _JSDelegate = pJSDelegate; - - // Check whether the js delegate is a pure js object. - js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); - if (!p) - { - _needUnroot = true; - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); - } - } -private: - JSObject* _JSDelegate; - bool _needUnroot; -}; - -static JSBool js_cocos2dx_CCEditBox_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - - if (argc == 1) - { - // save the delegate - JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); - JSB_EditBoxDelegate* nativeDelegate = new JSB_EditBoxDelegate(); - nativeDelegate->setJSDelegate(jsDelegate); - - cobj->setUserObject(nativeDelegate); - cobj->setDelegate(nativeDelegate); - - nativeDelegate->release(); - - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; - } - JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); - return JS_FALSE; -} - - - -class JSB_ControlButtonTarget : public Object -{ -public: - JSB_ControlButtonTarget() - : _jsFunc(nullptr), - _type(Control::EventType::TOUCH_DOWN), - _jsTarget(nullptr), - _needUnroot(false) - {} - - virtual ~JSB_ControlButtonTarget() - { - CCLOGINFO("In the destruction of JSB_ControlButtonTarget ..."); - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - if (_needUnroot) - { - JS_RemoveObjectRoot(cx, &_jsTarget); - } - - JS_RemoveObjectRoot(cx, &_jsFunc); - - for (auto iter = _jsNativeTargetMap.begin(); iter != _jsNativeTargetMap.end(); ++iter) - { - if (this == iter->second) - { - _jsNativeTargetMap.erase(iter); - break; - } - } - } - - virtual void onEvent(Object *controlButton, Control::EventType event) - { - js_proxy_t * p; - JS_GET_PROXY(p, controlButton); - if (!p) - { - log("Failed to get proxy for control button"); - return; - } - - jsval dataVal[2]; - dataVal[0] = OBJECT_TO_JSVAL(p->obj); - int arg1 = (int)event; - dataVal[1] = INT_TO_JSVAL(arg1); - jsval jsRet; - - ScriptingCore::getInstance()->executeJSFunctionWithThisObj(OBJECT_TO_JSVAL(_jsTarget), OBJECT_TO_JSVAL(_jsFunc), 2, dataVal, &jsRet); - } - - void setJSTarget(JSObject* pJSTarget) - { - _jsTarget = pJSTarget; - - js_proxy_t* p = jsb_get_js_proxy(_jsTarget); - if (!p) - { - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_AddNamedObjectRoot(cx, &_jsTarget, "JSB_ControlButtonTarget, target"); - _needUnroot = true; - } - } - - void setJSAction(JSObject* jsFunc) - { - _jsFunc = jsFunc; - - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_AddNamedObjectRoot(cx, &_jsFunc, "JSB_ControlButtonTarget, func"); - } - - void setEventType(Control::EventType type) - { - _type = type; - } -public: - - static std::multimap _jsNativeTargetMap; - JSObject* _jsFunc; - Control::EventType _type; -private: - JSObject* _jsTarget; - bool _needUnroot; -}; - -std::multimap JSB_ControlButtonTarget::_jsNativeTargetMap; - -static JSBool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - - JSBool ok = JS_TRUE; - if (argc == 3) - { - JSObject* jsDelegate = JSVAL_TO_OBJECT(argv[0]); - JSObject* jsFunc = JSVAL_TO_OBJECT(argv[1]); - Control::EventType arg2; - ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing control event"); - - // Check whether the target already exists. - auto range = JSB_ControlButtonTarget::_jsNativeTargetMap.equal_range(jsDelegate); - for (auto it = range.first; it != range.second; ++it) - { - if (it->second->_jsFunc == jsFunc && arg2 == it->second->_type) - { - // Return true directly. - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; - } - } - - // save the delegate - JSB_ControlButtonTarget* nativeDelegate = new JSB_ControlButtonTarget(); - - nativeDelegate->setJSTarget(jsDelegate); - nativeDelegate->setJSAction(jsFunc); - nativeDelegate->setEventType(arg2); - - Array* nativeDelegateArray = static_cast(cobj->getUserObject()); - if (nullptr == nativeDelegateArray) - { - nativeDelegateArray = new Array(); - nativeDelegateArray->init(); - cobj->setUserObject(nativeDelegateArray); // The reference of nativeDelegateArray is added to 2 - nativeDelegateArray->release(); // Release nativeDelegateArray to make the reference to 1 - } - - nativeDelegateArray->addObject(nativeDelegate); // The reference of nativeDelegate is added to 2 - nativeDelegate->release(); // Release nativeDelegate to make the reference to 1 - - cobj->addTargetWithActionForControlEvents(nativeDelegate, cccontrol_selector(JSB_ControlButtonTarget::onEvent), arg2); - - JSB_ControlButtonTarget::_jsNativeTargetMap.insert(std::make_pair(jsDelegate, nativeDelegate)); - - JS_SET_RVAL(cx, vp, JSVAL_VOID); - - return JS_TRUE; - } - JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3); - return JS_FALSE; -} - -static JSBool js_cocos2dx_CCControl_removeTargetWithActionForControlEvents(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - - JSBool ok = JS_TRUE; - if (argc == 3) - { - Control::EventType arg2; - ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing control event"); - - obj = JSVAL_TO_OBJECT(argv[0]); - JSObject* jsFunc = JSVAL_TO_OBJECT(argv[1]); - - JSB_ControlButtonTarget* nativeTargetToRemoved = nullptr; - - auto range = JSB_ControlButtonTarget::_jsNativeTargetMap.equal_range(obj); - for (auto it = range.first; it != range.second; ++it) - { - if (it->second->_jsFunc == jsFunc && arg2 == it->second->_type) - { - nativeTargetToRemoved = it->second; - JSB_ControlButtonTarget::_jsNativeTargetMap.erase(it); - break; - } - } - - cobj->removeTargetWithActionForControlEvents(nativeTargetToRemoved, cccontrol_selector(JSB_ControlButtonTarget::onEvent), arg2); - - return JS_TRUE; - } - JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3); - return JS_FALSE; -} - -class JSArmatureWrapper: public JSCallbackWrapper { -public: - JSArmatureWrapper(); - virtual ~JSArmatureWrapper(); - - virtual void setJSCallbackThis(jsval thisObj); - - void movementCallbackFunc(cocostudio::Armature * pArmature, cocostudio::MovementEventType pMovementEventType, const char *pMovementId); - void frameCallbackFunc(cocostudio::Bone *pBone, const char *frameEventName, int originFrameIndex, int currentFrameIndex); - void addArmatureFileInfoAsyncCallbackFunc(float percent); - -private: - bool m_bNeedUnroot; -}; - -JSArmatureWrapper::JSArmatureWrapper() - : m_bNeedUnroot(false) -{ - -} - -JSArmatureWrapper::~JSArmatureWrapper() -{ - if (m_bNeedUnroot) - { - JSObject *thisObj = JSVAL_TO_OBJECT(_jsThisObj); - JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_RemoveObjectRoot(cx, &thisObj); - } -} - -void JSArmatureWrapper::setJSCallbackThis(jsval _jsThisObj) -{ - JSCallbackWrapper::setJSCallbackThis(_jsThisObj); - - JSObject *thisObj = JSVAL_TO_OBJECT(_jsThisObj); - js_proxy *p = jsb_get_js_proxy(thisObj); - if (!p) - { - JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - JS_AddObjectRoot(cx, &thisObj); - m_bNeedUnroot = true; - } -} - -void JSArmatureWrapper::movementCallbackFunc(cocostudio::Armature *pArmature, cocostudio::MovementEventType pMovementEventType, const char *pMovementId) -{ - JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); - js_proxy_t *proxy = js_get_or_create_proxy(cx, pArmature); - jsval retval; - if (_jsCallback != JSVAL_VOID) - { - int movementEventType = (int)pMovementEventType; - jsval movementVal = INT_TO_JSVAL(movementEventType); - - jsval idVal = c_string_to_jsval(cx, pMovementId); - - jsval valArr[3]; - valArr[0] = OBJECT_TO_JSVAL(proxy->obj); - valArr[1] = movementVal; - valArr[2] = idVal; - - JS_AddValueRoot(cx, valArr); - JS_CallFunctionValue(cx, thisObj, _jsCallback, 3, valArr, &retval); - JS_RemoveValueRoot(cx, valArr); - } -} - -void JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc(float percent) -{ - JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); - jsval retval; - if (_jsCallback != JSVAL_VOID) - { - jsval percentVal = DOUBLE_TO_JSVAL(percent); - - JS_AddValueRoot(cx, &percentVal); - JS_CallFunctionValue(cx, thisObj, _jsCallback, 1, &percentVal, &retval); - JS_RemoveValueRoot(cx, &percentVal); - } -} - - -void JSArmatureWrapper::frameCallbackFunc(cocostudio::Bone *pBone, const char *frameEventName, int originFrameIndex, int currentFrameIndex) -{ - JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); - js_proxy_t *proxy = js_get_or_create_proxy(cx, pBone); - jsval retval; - if (_jsCallback != JSVAL_VOID) - { - jsval nameVal = c_string_to_jsval(cx, frameEventName); - jsval originIndexVal = INT_TO_JSVAL(originFrameIndex); - jsval currentIndexVal = INT_TO_JSVAL(currentFrameIndex); - - jsval valArr[4]; - valArr[0] = OBJECT_TO_JSVAL(proxy->obj); - valArr[1] = nameVal; - valArr[2] = originIndexVal; - valArr[3] = currentIndexVal; - - JS_AddValueRoot(cx, valArr); - JS_CallFunctionValue(cx, thisObj, _jsCallback, 4, valArr, &retval); - JS_RemoveValueRoot(cx, valArr); - } -} - -static JSBool js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - - if (argc == 2) { - jsval *argv = JS_ARGV(cx, vp); - - JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); - tmpObj->autorelease(); - - tmpObj->setJSCallbackFunc(argv[0]); - tmpObj->setJSCallbackThis(argv[1]); - - cobj->setMovementEventCallFunc(tmpObj, movementEvent_selector(JSArmatureWrapper::movementCallbackFunc)); - - return JS_TRUE; - } - JS_ReportError(cx, "Invalid number of arguments"); - return JS_FALSE; -} - -static JSBool js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - - if (argc == 2) { - jsval *argv = JS_ARGV(cx, vp); - - JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); - tmpObj->autorelease(); - - tmpObj->setJSCallbackFunc(argv[0]); - tmpObj->setJSCallbackThis(argv[1]); - - cobj->setFrameEventCallFunc(tmpObj, frameEvent_selector(JSArmatureWrapper::frameCallbackFunc)); - - return JS_TRUE; - } - JS_ReportError(cx, "Invalid number of arguments"); - return JS_FALSE; -} - -static JSBool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - - if (argc == 3) { - jsval *argv = JS_ARGV(cx, vp); - - JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); - tmpObj->autorelease(); - - tmpObj->setJSCallbackFunc(argv[2]); - tmpObj->setJSCallbackThis(argv[1]); - - std::string ret; - jsval_to_std_string(cx, argv[0], &ret); - - cobj->addArmatureFileInfoAsync(ret.c_str(), tmpObj, schedule_selector(JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc)); - - return JS_TRUE; - } - - if(argc == 5){ - jsval *argv = JS_ARGV(cx, vp); - - JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); - tmpObj->autorelease(); - - tmpObj->setJSCallbackFunc(argv[4]); - tmpObj->setJSCallbackThis(argv[3]); - - std::string imagePath; - jsval_to_std_string(cx ,argv[0] , &imagePath); - - std::string plistPath; - jsval_to_std_string(cx ,argv[1] , &plistPath); - - std::string configFilePath; - jsval_to_std_string(cx ,argv[2] , &configFilePath); - - cobj->addArmatureFileInfoAsync(imagePath.c_str(), plistPath.c_str(), configFilePath.c_str(), tmpObj, schedule_selector(JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc)); - - return JS_TRUE; - } - JS_ReportError(cx, "Invalid number of arguments"); - return JS_FALSE; -} - -extern JSObject* jsb_ScrollView_prototype; -extern JSObject* jsb_TableView_prototype; -extern JSObject* jsb_EditBox_prototype; -extern JSObject* jsb_ArmatureAnimation_prototype; -extern JSObject* jsb_ArmatureDataManager_prototype; -extern JSObject* jsb_Control_prototype; - -void register_all_cocos2dx_extension_manual(JSContext* cx, JSObject* global) -{ - JS_DefineFunction(cx, jsb_ScrollView_prototype, "setDelegate", js_cocos2dx_CCScrollView_setDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, jsb_TableView_prototype, "setDelegate", js_cocos2dx_CCTableView_setDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, jsb_TableView_prototype, "setDataSource", js_cocos2dx_CCTableView_setDataSource, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, jsb_EditBox_prototype, "setDelegate", js_cocos2dx_CCEditBox_setDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, jsb_Control_prototype, "addTargetWithActionForControlEvents", js_cocos2dx_CCControl_addTargetWithActionForControlEvents, 3, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, jsb_Control_prototype, "removeTargetWithActionForControlEvents", js_cocos2dx_CCControl_removeTargetWithActionForControlEvents, 3, JSPROP_READONLY | JSPROP_PERMANENT); - - JS_DefineFunction(cx, jsb_ArmatureAnimation_prototype, "setMovementEventCallFunc", js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc, 2, JSPROP_READONLY | JSPROP_PERMANENT); - - JS_DefineFunction(cx, jsb_ArmatureAnimation_prototype, "setFrameEventCallFunc", js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc, 2, JSPROP_READONLY | JSPROP_PERMANENT); - - JS_DefineFunction(cx, jsb_ArmatureDataManager_prototype, "addArmatureFileInfoAsync", jsb_Animation_addArmatureFileInfoAsyncCallFunc, 3, JSPROP_READONLY | JSPROP_PERMANENT); - - JSObject *tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.TableView; })()")); - JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCTableView_create, 3, JSPROP_READONLY | JSPROP_PERMANENT); -} \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/jsb_cocos2dx_extension_manual.h b/cocos/scripting/javascript/bindings/jsb_cocos2dx_extension_manual.h deleted file mode 100644 index e8822b1370..0000000000 --- a/cocos/scripting/javascript/bindings/jsb_cocos2dx_extension_manual.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// jsb_cocos2d_extension_manual.h -// -// Created by James Chen on 3/11/13. -// -// - -#ifndef __jsb_cocos2dx_extension_manual__ -#define __jsb_cocos2dx_extension_manual__ - -#include "jsapi.h" -#include "jsfriendapi.h" - -void register_all_cocos2dx_extension_manual(JSContext* cx, JSObject* global); - -#endif /* defined(__jsb_cocos2dx_extension_manual__) */ diff --git a/cocos/scripting/javascript/bindings/jsb_websocket.cpp b/cocos/scripting/javascript/bindings/jsb_websocket.cpp deleted file mode 100644 index b5083ad268..0000000000 --- a/cocos/scripting/javascript/bindings/jsb_websocket.cpp +++ /dev/null @@ -1,382 +0,0 @@ -/**************************************************************************** -Copyright (c) 2013 cocos2d-x.org -Copyright (c) 2013 James Chen - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#include "jsb_websocket.h" -#include "cocos2d.h" -#include "network/WebSocket.h" -#include "spidermonkey_specifics.h" -#include "ScriptingCore.h" -#include "cocos2d_specifics.hpp" - -using namespace network; - -/* - [Constructor(in DOMString url, in optional DOMString protocols)] - [Constructor(in DOMString url, in optional DOMString[] protocols)] - interface WebSocket { - readonly attribute DOMString url; - - // ready state - const unsigned short CONNECTING = 0; - const unsigned short OPEN = 1; - const unsigned short CLOSING = 2; - const unsigned short CLOSED = 3; - readonly attribute unsigned short readyState; - readonly attribute unsigned long bufferedAmount; - - // networking - attribute Function onopen; - attribute Function onmessage; - attribute Function onerror; - attribute Function onclose; - readonly attribute DOMString protocol; - void send(in DOMString data); - void close(); - }; - WebSocket implements EventTarget; - */ - -class JSB_WebSocketDelegate : public WebSocket::Delegate -{ -public: - - virtual void onOpen(WebSocket* ws) - { - js_proxy_t * p = jsb_get_native_proxy(ws); - if (!p) return; - - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); - jsval vp = c_string_to_jsval(cx, "open"); - JS_SetProperty(cx, jsobj, "type", &vp); - - jsval args = OBJECT_TO_JSVAL(jsobj); - - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onopen", 1, &args); - } - - virtual void onMessage(WebSocket* ws, const WebSocket::Data& data) - { - js_proxy_t * p = jsb_get_native_proxy(ws); - if (!p) return; - - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); - jsval vp = c_string_to_jsval(cx, "message"); - JS_SetProperty(cx, jsobj, "type", &vp); - - jsval args = OBJECT_TO_JSVAL(jsobj); - - if (data.isBinary) - {// data is binary - JSObject* buffer = JS_NewArrayBuffer(cx, data.len); - uint8_t* bufdata = JS_GetArrayBufferData(buffer); - memcpy((void*)bufdata, (void*)data.bytes, data.len); - jsval dataVal = OBJECT_TO_JSVAL(buffer); - JS_SetProperty(cx, jsobj, "data", &dataVal); - } - else - {// data is string - jsval dataVal = c_string_to_jsval(cx, data.bytes); - JS_SetProperty(cx, jsobj, "data", &dataVal); - } - - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onmessage", 1, &args); - } - - virtual void onClose(WebSocket* ws) - { - js_proxy_t * p = jsb_get_native_proxy(ws); - if (!p) return; - - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); - jsval vp = c_string_to_jsval(cx, "close"); - JS_SetProperty(cx, jsobj, "type", &vp); - - jsval args = OBJECT_TO_JSVAL(jsobj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onclose", 1, &args); - - js_proxy_t* jsproxy = jsb_get_js_proxy(p->obj); - JS_RemoveObjectRoot(cx, &jsproxy->obj); - jsb_remove_proxy(p, jsproxy); - CC_SAFE_DELETE(ws); - } - - virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error) - { - js_proxy_t * p = jsb_get_native_proxy(ws); - if (!p) return; - - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); - jsval vp = c_string_to_jsval(cx, "error"); - JS_SetProperty(cx, jsobj, "type", &vp); - - jsval args = OBJECT_TO_JSVAL(jsobj); - - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onerror", 1, &args); - } - - void setJSDelegate(JSObject* pJSDelegate) - { - _JSDelegate = pJSDelegate; - } -private: - JSObject* _JSDelegate; -}; - -JSClass *js_cocos2dx_websocket_class; -JSObject *js_cocos2dx_websocket_prototype; - -void js_cocos2dx_WebSocket_finalize(JSFreeOp *fop, JSObject *obj) { - CCLOG("jsbindings: finalizing JS object %p (WebSocket)", obj); -} - -JSBool js_cocos2dx_extension_WebSocket_send(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - - if(argc == 1){ - do - { - if (JSVAL_IS_STRING(argv[0])) - { - std::string data; - jsval_to_std_string(cx, argv[0], &data); - cobj->send(data); - break; - } - - if (argv[0].isObject()) - { - uint8_t *bufdata = NULL; - uint32_t len = 0; - - JSObject* jsobj = JSVAL_TO_OBJECT(argv[0]); - if (JS_IsArrayBufferObject(jsobj)) - { - bufdata = JS_GetArrayBufferData(jsobj); - len = JS_GetArrayBufferByteLength(jsobj); - } - else if (JS_IsArrayBufferViewObject(jsobj)) - { - bufdata = (uint8_t*)JS_GetArrayBufferViewData(jsobj); - len = JS_GetArrayBufferViewByteLength(jsobj); - } - - if (bufdata && len > 0) - { - cobj->send(bufdata, len); - break; - } - } - - JS_ReportError(cx, "data type to be sent is unsupported."); - - } while (0); - - JS_SET_RVAL(cx, vp, JSVAL_VOID); - - return JS_TRUE; - } - JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); - return JS_TRUE; -} - -JSBool js_cocos2dx_extension_WebSocket_close(JSContext *cx, uint32_t argc, jsval *vp){ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - - if(argc == 0){ - cobj->close(); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; - } - JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); - return JS_FALSE; -} - -JSBool js_cocos2dx_extension_WebSocket_constructor(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - - if (argc == 1 || argc == 2) - { - - std::string url; - - do { - JSBool ok = jsval_to_std_string(cx, argv[0], &url); - JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error processing arguments"); - } while (0); - - JSObject *obj = JS_NewObject(cx, js_cocos2dx_websocket_class, js_cocos2dx_websocket_prototype, NULL); - - - WebSocket* cobj = new WebSocket(); - JSB_WebSocketDelegate* delegate = new JSB_WebSocketDelegate(); - delegate->setJSDelegate(obj); - - if (argc == 2) - { - std::vector protocols; - - if (JSVAL_IS_STRING(argv[1])) - { - std::string protocol; - do { - JSBool ok = jsval_to_std_string(cx, argv[1], &protocol); - JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error processing arguments"); - } while (0); - protocols.push_back(protocol); - } - else if (argv[1].isObject()) - { - JSBool ok = JS_TRUE; - JSObject* arg2 = JSVAL_TO_OBJECT(argv[1]); - JSB_PRECONDITION(JS_IsArrayObject( cx, arg2 ), "Object must be an array"); - - uint32_t len = 0; - JS_GetArrayLength(cx, arg2, &len); - - for( uint32_t i=0; i< len;i++ ) - { - jsval valarg; - JS_GetElement(cx, arg2, i, &valarg); - std::string protocol; - do { - ok = jsval_to_std_string(cx, valarg, &protocol); - JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error processing arguments"); - } while (0); - - protocols.push_back(protocol); - } - } - cobj->init(*delegate, url, &protocols); - } - else - { - cobj->init(*delegate, url); - } - - - JS_DefineProperty(cx, obj, "URL", argv[0] - , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); - - //protocol not support yet (always return "") - JS_DefineProperty(cx, obj, "protocol", c_string_to_jsval(cx, "") - , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); - - // link the native object with the javascript object - js_proxy_t *p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "WebSocket"); - - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); - return JS_TRUE; - } - - JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); - return JS_FALSE; -} - -static JSBool js_cocos2dx_extension_WebSocket_get_readyState(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp) -{ - JSObject* jsobj = obj.get(); - js_proxy_t *proxy = jsb_get_js_proxy(jsobj); - WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - - if (cobj) { - vp.set(INT_TO_JSVAL((int)cobj->getReadyState())); - return JS_TRUE; - } else { - JS_ReportError(cx, "Error: WebSocket instance is invalid."); - return JS_FALSE; - } -} - -void register_jsb_websocket(JSContext *cx, JSObject *global) { - - js_cocos2dx_websocket_class = (JSClass *)calloc(1, sizeof(JSClass)); - js_cocos2dx_websocket_class->name = "WebSocket"; - js_cocos2dx_websocket_class->addProperty = JS_PropertyStub; - js_cocos2dx_websocket_class->delProperty = JS_DeletePropertyStub; - js_cocos2dx_websocket_class->getProperty = JS_PropertyStub; - js_cocos2dx_websocket_class->setProperty = JS_StrictPropertyStub; - js_cocos2dx_websocket_class->enumerate = JS_EnumerateStub; - js_cocos2dx_websocket_class->resolve = JS_ResolveStub; - js_cocos2dx_websocket_class->convert = JS_ConvertStub; - js_cocos2dx_websocket_class->finalize = js_cocos2dx_WebSocket_finalize; - js_cocos2dx_websocket_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); - - static JSPropertySpec properties[] = { - {"readyState", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_cocos2dx_extension_WebSocket_get_readyState), NULL}, - {0, 0, 0, 0, 0} - }; - - static JSFunctionSpec funcs[] = { - JS_FN("send",js_cocos2dx_extension_WebSocket_send, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("close",js_cocos2dx_extension_WebSocket_close, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - static JSFunctionSpec st_funcs[] = { - JS_FS_END - }; - - js_cocos2dx_websocket_prototype = JS_InitClass( - cx, global, - NULL, - js_cocos2dx_websocket_class, - js_cocos2dx_extension_WebSocket_constructor, 0, // constructor - properties, - funcs, - NULL, // no static properties - st_funcs); - - JSObject* jsclassObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return WebSocket; })()")); - - JS_DefineProperty(cx, jsclassObj, "CONNECTING", INT_TO_JSVAL((int)WebSocket::State::CONNECTING) - , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); - JS_DefineProperty(cx, jsclassObj, "OPEN", INT_TO_JSVAL((int)WebSocket::State::OPEN) - , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); - JS_DefineProperty(cx, jsclassObj, "CLOSING", INT_TO_JSVAL((int)WebSocket::State::CLOSING) - , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); - JS_DefineProperty(cx, jsclassObj, "CLOSED", INT_TO_JSVAL((int)WebSocket::State::CLOSED) - , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); - - // make the class enumerable in the registered namespace - JSBool found; - JS_SetPropertyAttributes(cx, global, "WebSocket", JSPROP_ENUMERATE | JSPROP_READONLY, &found); -} - - diff --git a/cocos/scripting/javascript/bindings/jsb_websocket.h b/cocos/scripting/javascript/bindings/jsb_websocket.h deleted file mode 100644 index cde0f40b2e..0000000000 --- a/cocos/scripting/javascript/bindings/jsb_websocket.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** -Copyright (c) 2013 cocos2d-x.org -Copyright (c) 2013 James Chen - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __jsb_websocket__ -#define __jsb_websocket__ - -#include "jsapi.h" -#include "jsfriendapi.h" - -void register_jsb_websocket(JSContext* cx, JSObject* global); - -#endif /* defined(__jsb_websocket__) */ diff --git a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj index df73497bd8..11085f336c 100644 --- a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj +++ b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj @@ -12,68 +12,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + {39379840-825A-45A0-B363-C09FFEF864BD} @@ -102,9 +75,11 @@ + + @@ -126,7 +101,7 @@ Level3 Disabled WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;$(ProjectDir)..;$(ProjectDir)..\..\spidermonkey-win32\include;$(ProjectDir)..\..\..\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\extensions\LocalStorage;$(ProjectDir)..\..\..\..\extensions\network;%(AdditionalIncludeDirectories) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true false @@ -137,7 +112,7 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" @@ -149,7 +124,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(O true true WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;$(ProjectDir)..;$(ProjectDir)..\..\spidermonkey-win32\include;$(ProjectDir)..\..\..\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\extensions\LocalStorage;$(ProjectDir)..\..\..\..\extensions\network;%(AdditionalIncludeDirectories) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true @@ -161,7 +136,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(O if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" diff --git a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters index 4fdf5413d2..1d1e1d400a 100644 --- a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters +++ b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters @@ -20,21 +20,6 @@ manual - - manual - - - manual - - - manual - - - manual - - - manual - manual @@ -44,15 +29,6 @@ manual - - manual - - - manual - - - manual - manual @@ -65,18 +41,9 @@ manual - - manual - - - manual - generated - - generated - @@ -85,27 +52,6 @@ manual - - manual - - - manual - - - manual - - - manual - - - manual - - - manual - - - manual - manual @@ -121,18 +67,6 @@ manual - - manual - - - manual - - - manual - - - manual - manual @@ -145,55 +79,40 @@ manual - - manual - - - manual - manual generated - - generated - - - js - - - js - - - js - - - js - - - js - - - js - - - js - - - js - - - js - generated - - generated + + js + + + js + + + js + + + js + + + js + + + js + + + js + + + js \ No newline at end of file diff --git a/cocos/scripting/lua/bindings/liblua.vcxproj b/cocos/scripting/lua/bindings/liblua.vcxproj index 84026e44fd..ed1ef534ed 100644 --- a/cocos/scripting/lua/bindings/liblua.vcxproj +++ b/cocos/scripting/lua/bindings/liblua.vcxproj @@ -35,9 +35,11 @@ + + @@ -62,7 +64,7 @@ Disabled - $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\audio\include;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\extensions\network;$(ProjectDir)..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\tolua;$(ProjectDir)..\luajit\include;$(ProjectDir)..\..\auto-generated\lua-bindings;$(ProjectDir)..\cocos2dx_support;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(ProjectDir);$(ProjectDir)..\..\..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)extensions\network;$(EngineRoot)external;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -87,14 +89,14 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$(OutDir)" MaxSpeed true - $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\audio\include;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\extensions\network;$(ProjectDir)..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\tolua;$(ProjectDir)..\luajit\include;$(ProjectDir)..\..\auto-generated\lua-bindings;$(ProjectDir)..\cocos2dx_support;%(AdditionalIncludeDirectories) + $(ProjectDir);$(ProjectDir)..\..\..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)extensions\network;$(EngineRoot)external;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true @@ -118,55 +120,55 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)" if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$(OutDir)" + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/cocos/scripting/lua/bindings/liblua.vcxproj.filters b/cocos/scripting/lua/bindings/liblua.vcxproj.filters index a65b18d1ac..56f49872c4 100644 --- a/cocos/scripting/lua/bindings/liblua.vcxproj.filters +++ b/cocos/scripting/lua/bindings/liblua.vcxproj.filters @@ -18,135 +18,135 @@ - - tolua - - - tolua - - - tolua - - - tolua - - - tolua - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - cocos2dx_support\generated cocos2dx_support\generated - + + tolua + + + tolua + + + tolua + + + tolua + + + tolua + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + cocos2dx_support - - tolua - - - tolua - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - luajit\include - - - luajit\include - - - luajit\include - - - luajit\include - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - - - cocos2dx_support - cocos2dx_support\generated cocos2dx_support\generated - + + luajit\include + + + luajit\include + + + luajit\include + + + luajit\include + + + tolua + + + tolua + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + cocos2dx_support diff --git a/extensions/proj.win32/libExtensions.vcxproj b/extensions/proj.win32/libExtensions.vcxproj index 25597c43e3..7a3615643f 100644 --- a/extensions/proj.win32/libExtensions.vcxproj +++ b/extensions/proj.win32/libExtensions.vcxproj @@ -35,9 +35,11 @@ + + @@ -62,7 +64,7 @@ Disabled - $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir)..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\external\sqlite3\include;$(ProjectDir)..\..\external;$(ProjectDir)..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\cocos2dx;$(ProjectDir)..\..\cocos2dx\include;$(ProjectDir)..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\zlib;$(ProjectDir)..\..\audio\include;..\;%(AdditionalIncludeDirectories) + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\unzip;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\win32-specific\zlib\include;..\;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;_DEBUG;_LIB;COCOS2D_DEBUG=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -79,7 +81,7 @@ MaxSpeed true - $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir)..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\external\sqlite3\include;$(ProjectDir)..\..\external;$(ProjectDir)..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\cocos2dx;$(ProjectDir)..\..\cocos2dx\include;$(ProjectDir)..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\zlib;$(ProjectDir)..\..\audio\include;..\;%(AdditionalIncludeDirectories) + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\unzip;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\win32-specific\zlib\include;..\;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;NDEBUG;_LIB;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true @@ -92,89 +94,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -193,130 +113,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -339,44 +141,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - diff --git a/extensions/proj.win32/libExtensions.vcxproj.filters b/extensions/proj.win32/libExtensions.vcxproj.filters index 766af1001f..d43ac6197c 100644 --- a/extensions/proj.win32/libExtensions.vcxproj.filters +++ b/extensions/proj.win32/libExtensions.vcxproj.filters @@ -1,9 +1,6 @@  - - {d37545ef-285b-4315-9fca-40da6fc2a6c9} - {202b519b-b5e0-499f-b3b8-ed5da144b248} @@ -16,83 +13,17 @@ {d5806151-7ae1-4fef-af5a-2fa1d1c7377b} - - {4da8061d-80f3-45fd-aa7e-2c0a96701b79} - {5d186e3d-0aaf-4904-a5d8-e5cb0f35f4cc} {49487dbe-5758-436a-b014-8e2edc6b33ae} - - {ff4b5934-99d4-4ea7-9f50-a774192d9ca9} - - - {2a7741ff-87a5-41c8-8e51-d7a1cf0c8e4d} - - - {87250d95-2afd-45e7-bc9d-760478c4e709} - - - {5258a1e1-5d50-4fee-9216-da08d2ec19de} - - - {cf3469d5-421b-4990-a9be-4cd95129fb73} - - - {f48d1291-33fe-49a1-8f9f-4d203e782d4a} - - - {043f8489-822e-43c8-8d9d-5d171a701663} - - - {b8c65820-b5c9-4bd6-83c8-180fdc6100fb} - - - {fa9a165e-cc7c-45e9-ae4f-cae3c2f16e6a} - - - {5e5b3d7d-62a7-493e-a130-ed72ee7c65f2} - - - {d797adcd-2e59-4486-944e-b3e7f3a954b8} - - - {a824cea6-86d7-4230-8738-513a869a1882} - - - {d305abea-33cc-4ae8-b78d-b5fb59927e59} - - - {9af947f9-84cd-4051-953e-67291da6528c} - - - {9713ac75-d9ba-494a-8dcf-03e30f8ee2b2} - - - {2d6f3e38-bb46-4bec-9ec1-73d90cefb3ba} - - - {7556b22b-b7ca-4f3b-938d-0f9c8047892c} - - - {f66c34f1-f75a-4f06-9788-c48972bc0ff2} - - - {1c44450b-d06e-4638-9f0c-1ff62e67ec84} - - - {bec3cdd7-e05b-42d3-97b1-86e26a528a2d} - GUI\CCScrollView - - network - GUI\CCScrollView @@ -138,15 +69,6 @@ GUI\CCControlExtension - - physics_nodes - - - physics_nodes - - - LocalStorage - GUI\CCEditBox @@ -156,390 +78,14 @@ GUI\CCEditBox - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - network - - - network - - - - CocoStudio\Armature\animation - - - CocoStudio\Armature\animation - - - CocoStudio\Armature\animation - - - CocoStudio\Armature\datas - - - CocoStudio\Armature\display - - - CocoStudio\Armature\display - - - CocoStudio\Armature\display - - - CocoStudio\Armature\display - - - CocoStudio\Armature\display - - - CocoStudio\Armature\physics - - - CocoStudio\Armature\utils - - - CocoStudio\Armature\utils - - - CocoStudio\Armature\utils - - - CocoStudio\Armature\utils - - - CocoStudio\Armature\utils - - - CocoStudio\Armature\utils - - - CocoStudio\Armature - - - CocoStudio\Armature - - - CocoStudio\Armature\utils - - - CocoStudio\GUI\UIWidgets\ScrollWidget - - - CocoStudio\GUI\UIWidgets\ScrollWidget - - - CocoStudio\GUI\UIWidgets\ScrollWidget - - - CocoStudio\GUI\UIWidgets\ScrollWidget - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\BaseClasses - - - CocoStudio\GUI\BaseClasses - - - CocoStudio\GUI\Layouts - - - CocoStudio\GUI\Layouts - - - CocoStudio\GUI\Layouts - - - CocoStudio\GUI\System - - - CocoStudio\GUI\System - - - CocoStudio\GUI\System - - - CocoStudio\GUI\System - - - CocoStudio\GUI\UIWidgets\ScrollWidget - - - CocoStudio\GUI\UIWidgets\ScrollWidget - - - CocoStudio\GUI\UIWidgets\ScrollWidget - - - CocoStudio\GUI\UIWidgets\ScrollWidget - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\BaseClasses - - - CocoStudio\GUI\BaseClasses - - - CocoStudio\GUI\Layouts - - - CocoStudio\GUI\Layouts - - - CocoStudio\GUI\Layouts - - - CocoStudio\GUI\System - - - CocoStudio\GUI\System - - - CocoStudio\GUI\System - - - CocoStudio\GUI\System - - - CocoStudio\Reader - AssetsManager - - CCBReader + + physics_nodes - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CocoStudio\Action - - - CocoStudio\Action - - - CocoStudio\Action - - - CocoStudio\Action - - - CocoStudio\Action - - - CocoStudio\Components - - - CocoStudio\Components - - - CocoStudio\Components - - - CocoStudio\Components - - - CocoStudio\Components - - - CocoStudio\Reader - - - CocoStudio\Reader - - - CocoStudio\Json - - - CocoStudio\Json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json + + physics_nodes @@ -548,15 +94,6 @@ - - network - - - network - - - network - GUI\CCScrollView @@ -605,15 +142,6 @@ GUI\CCControlExtension - - physics_nodes - - - physics_nodes - - - LocalStorage - GUI\CCEditBox @@ -626,373 +154,14 @@ GUI\CCEditBox - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - network - - - network - - - CocoStudio\Armature\animation - - - CocoStudio\Armature\animation - - - CocoStudio\Armature\animation - - - CocoStudio\Armature\datas - - - CocoStudio\Armature\display - - - CocoStudio\Armature\display - - - CocoStudio\Armature\display - - - CocoStudio\Armature\display - - - CocoStudio\Armature\display - - - CocoStudio\Armature\physics - - - CocoStudio\Armature\utils - - - CocoStudio\Armature\utils - - - CocoStudio\Armature\utils - - - CocoStudio\Armature\utils - - - CocoStudio\Armature\utils - - - CocoStudio\Armature\utils - - - CocoStudio\Armature\utils - - - CocoStudio\Armature - - - CocoStudio\Armature - - - CocoStudio\GUI\UIWidgets\ScrollWidget - - - CocoStudio\GUI\UIWidgets\ScrollWidget - - - CocoStudio\GUI\UIWidgets\ScrollWidget - - - CocoStudio\GUI\UIWidgets\ScrollWidget - - - CocoStudio\GUI\UIWidgets\ScrollWidget - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\UIWidgets - - - CocoStudio\GUI\BaseClasses - - - CocoStudio\GUI\BaseClasses - - - CocoStudio\GUI\Layouts - - - CocoStudio\GUI\Layouts - - - CocoStudio\GUI\Layouts - - - CocoStudio\GUI\System - - - CocoStudio\GUI\System - - - CocoStudio\GUI\System - - - CocoStudio\GUI\System - AssetsManager - - CCBReader + + physics_nodes - - CCBReader + + physics_nodes - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CocoStudio\Action - - - CocoStudio\Action - - - CocoStudio\Action - - - CocoStudio\Action - - - CocoStudio\Action - - - CocoStudio\Components - - - CocoStudio\Components - - - CocoStudio\Components - - - CocoStudio\Components - - - CocoStudio\Components - - - CocoStudio\Reader - - - CocoStudio\Reader - - - CocoStudio\Json - - - CocoStudio\Json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - - - CocoStudio\Json\lib_json - \ No newline at end of file diff --git a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp index 8dadda36ac..31808c17b0 100644 --- a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp +++ b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp @@ -45,6 +45,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_all_cocos2dx); sc->addRegisterCallback(register_cocos2dx_js_extensions); + sc->start(); auto scene = Scene::create(); diff --git a/samples/Cpp/AssetsManagerTest/proj.android/build_native.cmd b/samples/Cpp/AssetsManagerTest/proj.android/build_native.cmd index 253059b2f8..d397bbc901 100644 --- a/samples/Cpp/AssetsManagerTest/proj.android/build_native.cmd +++ b/samples/Cpp/AssetsManagerTest/proj.android/build_native.cmd @@ -54,7 +54,7 @@ exit /b 1 set COCOS2DX_ROOT=%~dp0..\..\..\.. set APP_ROOT=%~dp0.. set APP_ANDROID_ROOT=%~dp0 -set BINDINGS_JS_ROOT=%APP_ROOT%\..\..\scripting\javascript\bindings\js +set BINDINGS_JS_ROOT=%COCOS2DX_ROOT%\cocos\scripting\javascript\script if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) :MODULE1 @@ -63,7 +63,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos;%COCOS2DX_ROOT%\external :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -76,7 +76,6 @@ rem make sure assets is exist if exist %APP_ANDROID_ROOT%\assets rd /q /s %APP_ANDROID_ROOT%\assets mkdir %APP_ANDROID_ROOT%\assets -mkdir %APP_ANDROID_ROOT%\assets\res rem copy Resources/* into assets' root xcopy /e /q /r /y %APP_ROOT%\Resources\* %APP_ANDROID_ROOT%\assets @@ -84,5 +83,5 @@ xcopy /e /q /r /y %APP_ROOT%\Resources\* %APP_ANDROID_ROOT%\assets rem copy bindings/*.js into assets' root xcopy /e /q /r /y %BINDINGS_JS_ROOT%\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 +call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 %* pause \ No newline at end of file diff --git a/samples/Cpp/AssetsManagerTest/proj.win32/AssetsManagerTest.vcxproj b/samples/Cpp/AssetsManagerTest/proj.win32/AssetsManagerTest.vcxproj index 9fdc714c49..b46bf264ae 100644 --- a/samples/Cpp/AssetsManagerTest/proj.win32/AssetsManagerTest.vcxproj +++ b/samples/Cpp/AssetsManagerTest/proj.win32/AssetsManagerTest.vcxproj @@ -34,11 +34,13 @@ - + + - + + @@ -77,7 +79,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)cocos\audio\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;DEBUG;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -96,11 +98,11 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;libcurl_imp.lib;%(AdditionalDependencies) + mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;libcurl_imp.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -110,7 +112,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\AssetsManagerTestRes" rd /s /q "$(OutDir)\AssetsManagerTestRes" mkdir "$(OutDir)\AssetsManagerTestRes" -xcopy "$(ProjectDir)..\..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\AssetsManagerTestRes\" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\javascript\script\*.js" "$(OutDir)\AssetsManagerTestRes\" /e /Y xcopy "$(ProjectDir)..\Resources" "$(OutDir)\AssetsManagerTestRes\" /e /Y @@ -131,7 +133,7 @@ xcopy "$(ProjectDir)..\Resources" "$(OutDir)\AssetsManagerTestRes\" /e /Yres_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)cocos\audio\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -151,20 +153,21 @@ xcopy "$(ProjectDir)..\Resources" "$(OutDir)\AssetsManagerTestRes\" /e /Y if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(EngineRoot)external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;libcurl_imp.lib;%(AdditionalDependencies) + mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;libcurl_imp.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 + true if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\AssetsManagerTestRes" rd /s /q "$(OutDir)\AssetsManagerTestRes" mkdir "$(OutDir)\AssetsManagerTestRes" -xcopy "$(ProjectDir)..\..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\AssetsManagerTestRes\" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\javascript\script\*.js" "$(OutDir)\AssetsManagerTestRes\" /e /Y xcopy "$(ProjectDir)..\Resources" "$(OutDir)\AssetsManagerTestRes\" /e /Y Copy js and resource files. @@ -185,13 +188,27 @@ xcopy "$(ProjectDir)..\Resources" "$(OutDir)\AssetsManagerTestRes\" /e /Y - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} false - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} - false + + + {625f7391-9a91-48a1-8cfc-79508c822637} + + + {39379840-825a-45a0-b363-c09ffef864bd} + + + {632a8f38-d0f0-4d22-86b3-d69f5e6bf63a} + + + {21b2c324-891f-48ea-ad1a-5ae13de12e28} + + + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} diff --git a/samples/Cpp/HelloCpp/proj.android/build_native.cmd b/samples/Cpp/HelloCpp/proj.android/build_native.cmd index 041749c380..f18ac5f170 100644 --- a/samples/Cpp/HelloCpp/proj.android/build_native.cmd +++ b/samples/Cpp/HelloCpp/proj.android/build_native.cmd @@ -62,7 +62,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%\external;%COCOS2DX_ROOT%\cocos :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -75,10 +75,9 @@ rem make sure assets is exist if exist %APP_ANDROID_ROOT%\assets rd /q /s %APP_ANDROID_ROOT%\assets mkdir %APP_ANDROID_ROOT%\assets -mkdir %APP_ANDROID_ROOT%\assets\res rem copy Resources/* into assets' root xcopy /e /q /r /y %APP_ROOT%\Resources\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 +call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 %* pause \ No newline at end of file diff --git a/samples/Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj b/samples/Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj index 233a21ce9c..6da099a164 100644 --- a/samples/Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj +++ b/samples/Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj @@ -37,9 +37,11 @@ + + @@ -66,7 +68,7 @@ Disabled - $(ProjectDir)..\..\..\..\cocos\2d;$(ProjectDir)..\..\..\..\cocos\base;$(ProjectDir)..\..\..\..\cocos\physics;$(ProjectDir)..\..\..\..\cocos\math\kazmath\include;$(ProjectDir)..\..\..\..\cocos\2d\platform\win32;$(ProjectDir)..\..\..\..\external\glfw3\include\win32;$(ProjectDir)..\..\..\..\external\win32-specific\gles\include\OGLES;..\Classes;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + ..\Classes;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks @@ -94,7 +96,7 @@ MaxSpeed true - $(ProjectDir)..\..\..\..\cocos\2d;$(ProjectDir)..\..\..\..\cocos\2d\include;$(ProjectDir)..\..\..\..\cocos\math\kazmath\include;$(ProjectDir)..\..\..\..\cocos\2d\platform\win32;$(ProjectDir)..\..\..\..\external\win32-specific\gles\include\OGLES;..\Classes;%(AdditionalIncludeDirectories) + ..\Classes;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true @@ -135,9 +137,8 @@ {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} false - - {f8edd7fa-9a51-4e80-baeb-860825d2eac6} - false + + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} diff --git a/samples/Cpp/SimpleGame/proj.android/build_native.cmd b/samples/Cpp/SimpleGame/proj.android/build_native.cmd index cb8929af5b..437e55298f 100644 --- a/samples/Cpp/SimpleGame/proj.android/build_native.cmd +++ b/samples/Cpp/SimpleGame/proj.android/build_native.cmd @@ -62,7 +62,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos;%COCOS2DX_ROOT%\external :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -75,10 +75,9 @@ rem make sure assets is exist if exist %APP_ANDROID_ROOT%\assets rd /q /s %APP_ANDROID_ROOT%\assets mkdir %APP_ANDROID_ROOT%\assets -mkdir %APP_ANDROID_ROOT%\assets\res rem copy Resources/* into assets' root xcopy /e /q /r /y %APP_ROOT%\Resources\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 +call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 %* pause \ No newline at end of file diff --git a/samples/Cpp/TestCpp/proj.android/build_native.cmd b/samples/Cpp/TestCpp/proj.android/build_native.cmd index 44e95cafe7..d8eaaea7c7 100644 --- a/samples/Cpp/TestCpp/proj.android/build_native.cmd +++ b/samples/Cpp/TestCpp/proj.android/build_native.cmd @@ -62,7 +62,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\external;%COCOS2DX_ROOT%\cocos :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -75,10 +75,16 @@ rem make sure assets is exist if exist %APP_ANDROID_ROOT%\assets rd /q /s %APP_ANDROID_ROOT%\assets mkdir %APP_ANDROID_ROOT%\assets -mkdir %APP_ANDROID_ROOT%\assets\res rem copy Resources/* into assets' root xcopy /e /q /r /y %APP_ROOT%\Resources\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 +rem remove test_image_rgba4444.pvr.gz +del /f /q %APP_ANDROID_ROOT%\assets\Images\test_image_rgba4444.pvr.gz +del /f /q %APP_ANDROID_ROOT%\assets\Images\test_1021x1024_rgba8888.pvr.gz +del /f /q %APP_ANDROID_ROOT%\assets\Images\test_1021x1024_rgb888.pvr.gz +del /f /q %APP_ANDROID_ROOT%\assets\Images\test_1021x1024_rgba4444.pvr.gz +del /f /q %APP_ANDROID_ROOT%\assets\Images\test_1021x1024_a8.pvr.gz + +call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 %* pause \ No newline at end of file diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj index d9227050c3..1dd1fe3146 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj @@ -37,10 +37,12 @@ + + @@ -67,7 +69,7 @@ Disabled - $(ProjectDir)..\..\..\..\cocos\physics;$(ProjectDir)..\..\..\..\cocos\base;$(ProjectDir)..\..\..\..\cocos\2d;$(ProjectDir)..\..\..\..\cocos\math\kazmath\include;$(ProjectDir)..\..\..\..\cocos\2d\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\external\win32-specific\gles\include\OGLES;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\external;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\external\glfw3\include\win32;$(ProjectDir)..\..\..\..\external\websockets\win32\include;$(ProjectDir)..\..\..\..\cocos\audio\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\cocos\network;..\Classes;..;%(AdditionalIncludeDirectories) + ..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\network;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)external\websockets\win32\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL @@ -84,7 +86,7 @@ true Windows MachineX86 - libExtensions.lib;libcocos2d.lib;libCocosDenshion.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;websockets.lib;%(AdditionalDependencies) + libcurl_imp.lib;websockets.lib;%(AdditionalDependencies) @@ -92,7 +94,7 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" @@ -100,7 +102,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O MaxSpeed true - $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\external;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\audio\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\extensions\network;..\Classes;..;%(AdditionalIncludeDirectories) + ..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\network;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)external\websockets\win32\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true @@ -112,7 +114,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O true - libExtensions.lib;libcocos2d.lib;libCocosDenshion.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;websockets.lib;%(AdditionalDependencies) + libcurl_imp.lib;websockets.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe $(OutDir);%(AdditionalLibraryDirectories) true @@ -127,7 +129,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" @@ -467,6 +469,24 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O {f8edd7fa-9a51-4e80-baeb-860825d2eac6} false + + {811c0dab-7b96-4bd3-a154-b7572b58e4ab} + + + {b57cf53f-2e49-4031-9822-047cc0e6bde2} + + + {b7c2a162-dec9-4418-972e-240ab3cbfcae} + + + {7e06e92c-537a-442b-9e4a-4761c84f8a1a} + + + {df2638c0-8128-4847-867c-6eafe3dee7b5} + + + {632a8f38-d0f0-4d22-86b3-d69f5e6bf63a} + {21b2c324-891f-48ea-ad1a-5ae13de12e28} false diff --git a/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp b/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp index 3276d5deda..f14e6df017 100644 --- a/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp +++ b/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp @@ -8,11 +8,12 @@ #include "ScriptingCore.h" #include "jsb_cocos2dx_auto.hpp" #include "jsb_cocos2dx_extension_auto.hpp" -#include "jsb_cocos2dx_extension_manual.h" +#include "jsb_cocos2dx_builder_auto.hpp" +#include "extension/jsb_cocos2dx_extension_manual.h" #include "cocos2d_specifics.hpp" -#include "js_bindings_ccbreader.h" -#include "js_bindings_system_registration.h" -#include "js_bindings_chipmunk_registration.h" +#include "cocosbuilder/js_bindings_ccbreader.h" +#include "localstorage/js_bindings_system_registration.h" +#include "chipmunk/js_bindings_chipmunk_registration.h" #include "jsb_opengl_registration.h" USING_NS_CC; @@ -124,6 +125,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_all_cocos2dx_extension); sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); + sc->addRegisterCallback(register_all_cocos2dx_builder); sc->addRegisterCallback(register_CCBuilderReader); sc->addRegisterCallback(jsb_register_system); sc->addRegisterCallback(JSB_register_opengl); diff --git a/samples/Javascript/CocosDragonJS/proj.android/build_native.cmd b/samples/Javascript/CocosDragonJS/proj.android/build_native.cmd index 349e2aa5d7..76a9a7138f 100644 --- a/samples/Javascript/CocosDragonJS/proj.android/build_native.cmd +++ b/samples/Javascript/CocosDragonJS/proj.android/build_native.cmd @@ -57,7 +57,7 @@ set COCOS2DX_ROOT=%~dp0..\..\..\.. set APP_ROOT=%~dp0.. set APP_ANDROID_ROOT=%~dp0 set RESROUCE_ROOT="%APP_ROOT%\..\Shared\games\CocosDragonJS\Published files Android" -set BINDINGS_JS_ROOT=%APP_ROOT%\..\..\..\scripting\javascript\bindings\js +set BINDINGS_JS_ROOT=%COCOS2DX_ROOT%\cocos\scripting\javascript\script if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) :MODULE1 @@ -66,7 +66,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos;%COCOS2DX_ROOT%\external :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -79,7 +79,6 @@ rem make sure assets is exist if exist %APP_ANDROID_ROOT%\assets rd /q /s %APP_ANDROID_ROOT%\assets mkdir %APP_ANDROID_ROOT%\assets -mkdir %APP_ANDROID_ROOT%\assets\res rem copy Resources/* into assets' root xcopy /e /q /r /y %RESROUCE_ROOT%\* %APP_ANDROID_ROOT%\assets @@ -87,5 +86,5 @@ xcopy /e /q /r /y %RESROUCE_ROOT%\* %APP_ANDROID_ROOT%\assets rem copy bindings/*.js into assets' root xcopy /e /q /r /y %BINDINGS_JS_ROOT%\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd %PARALLEL_BUILD_FLAG% NDK_LOG=0 V=0 +call %NDK_ROOT%\ndk-build.cmd %PARALLEL_BUILD_FLAG% NDK_LOG=0 V=0 %* pause diff --git a/samples/Javascript/CocosDragonJS/proj.win32/CocosDragonJS.vcxproj b/samples/Javascript/CocosDragonJS/proj.win32/CocosDragonJS.vcxproj index e67d8d64eb..8483cb7237 100644 --- a/samples/Javascript/CocosDragonJS/proj.win32/CocosDragonJS.vcxproj +++ b/samples/Javascript/CocosDragonJS/proj.win32/CocosDragonJS.vcxproj @@ -34,11 +34,13 @@ - + + - + + @@ -77,7 +79,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -96,11 +98,11 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -110,7 +112,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\CocosDragonJSRes" rd /s /q "$(OutDir)\CocosDragonJSRes" mkdir "$(OutDir)\CocosDragonJSRes" -xcopy "$(ProjectDir)..\..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\CocosDragonJSRes" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\javascript\script\*.js" "$(OutDir)\CocosDragonJSRes" /e /Y xcopy "$(ProjectDir)..\..\Shared\games\CocosDragonJS\Published files Android" "$(OutDir)\CocosDragonJSRes\" /e /Y @@ -131,7 +133,7 @@ xcopy "$(ProjectDir)..\..\Shared\games\CocosDragonJS\Published files Android" "$ testjs_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_JAVASCRIPT=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -151,20 +153,21 @@ xcopy "$(ProjectDir)..\..\Shared\games\CocosDragonJS\Published files Android" "$ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 + true if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\CocosDragonJSRes" rd /s /q "$(OutDir)\CocosDragonJSRes" mkdir "$(OutDir)\CocosDragonJSRes" -xcopy "$(ProjectDir)..\..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\CocosDragonJSRes" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\javascript\script\*.js" "$(OutDir)\CocosDragonJSRes" /e /Y xcopy "$(ProjectDir)..\..\Shared\games\CocosDragonJS\Published files Android" "$(OutDir)\CocosDragonJSRes\" /e /Y Copy js and resource files. @@ -185,13 +188,38 @@ xcopy "$(ProjectDir)..\..\Shared\games\CocosDragonJS\Published files Android" "$ - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} - false - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} - false + + + {811c0dab-7b96-4bd3-a154-b7572b58e4ab} + + + {21070e58-eec6-4e16-8b4f-6d083df55790} + + + {f9da0fc1-651b-457b-962e-a4d61cebf5fd} + + + {625f7391-9a91-48a1-8cfc-79508c822637} + + + {68f5f371-bd7b-4c30-ae5b-0b08f22e0cde} + + + {39379840-825a-45a0-b363-c09ffef864bd} + + + {632a8f38-d0f0-4d22-86b3-d69f5e6bf63a} + + + {21b2c324-891f-48ea-ad1a-5ae13de12e28} + + + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} diff --git a/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp b/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp index 27520db220..63f1c31aed 100644 --- a/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp +++ b/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp @@ -5,11 +5,12 @@ #include "ScriptingCore.h" #include "jsb_cocos2dx_auto.hpp" #include "jsb_cocos2dx_extension_auto.hpp" -#include "jsb_cocos2dx_extension_manual.h" +#include "jsb_cocos2dx_builder_auto.hpp" +#include "extension/jsb_cocos2dx_extension_manual.h" #include "cocos2d_specifics.hpp" -#include "js_bindings_ccbreader.h" -#include "js_bindings_system_registration.h" -#include "js_bindings_chipmunk_registration.h" +#include "cocosbuilder/js_bindings_ccbreader.h" +#include "localstorage/js_bindings_system_registration.h" +#include "chipmunk/js_bindings_chipmunk_registration.h" #include "jsb_opengl_registration.h" USING_NS_CC; @@ -106,6 +107,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(jsb_register_chipmunk); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); + sc->addRegisterCallback(register_all_cocos2dx_builder); sc->addRegisterCallback(register_CCBuilderReader); sc->addRegisterCallback(jsb_register_system); sc->addRegisterCallback(JSB_register_opengl); diff --git a/samples/Javascript/CrystalCraze/proj.android/build_native.cmd b/samples/Javascript/CrystalCraze/proj.android/build_native.cmd index 6c248549ae..22f5ad4442 100644 --- a/samples/Javascript/CrystalCraze/proj.android/build_native.cmd +++ b/samples/Javascript/CrystalCraze/proj.android/build_native.cmd @@ -57,7 +57,7 @@ set COCOS2DX_ROOT=%~dp0..\..\..\.. set APP_ROOT=%~dp0.. set APP_ANDROID_ROOT=%~dp0 set RESROUCE_ROOT="%APP_ROOT%\..\Shared\games\CrystalCraze\Published-Android" -set BINDINGS_JS_ROOT=%APP_ROOT%\..\..\..\scripting\javascript\bindings\js +set BINDINGS_JS_ROOT=%COCOS2DX_ROOT%\cocos\scripting\javascript\script if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) :MODULE1 @@ -66,7 +66,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos;%COCOS2DX_ROOT%\external :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -79,7 +79,6 @@ rem make sure assets is exist if exist %APP_ANDROID_ROOT%\assets rd /q /s %APP_ANDROID_ROOT%\assets mkdir %APP_ANDROID_ROOT%\assets -mkdir %APP_ANDROID_ROOT%\assets\res rem copy Resources/* into assets' root xcopy /e /q /r /y %RESROUCE_ROOT%\* %APP_ANDROID_ROOT%\assets @@ -87,5 +86,5 @@ xcopy /e /q /r /y %RESROUCE_ROOT%\* %APP_ANDROID_ROOT%\assets rem copy bindings/*.js into assets' root xcopy /e /q /r /y %BINDINGS_JS_ROOT%\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd %PARALLEL_BUILD_FLAG% NDK_LOG=0 V=0 +call %NDK_ROOT%\ndk-build.cmd %PARALLEL_BUILD_FLAG% NDK_LOG=0 V=0 %* pause diff --git a/samples/Javascript/CrystalCraze/proj.win32/CrystalCraze.vcxproj b/samples/Javascript/CrystalCraze/proj.win32/CrystalCraze.vcxproj index e2a144bff1..6194bc0354 100644 --- a/samples/Javascript/CrystalCraze/proj.win32/CrystalCraze.vcxproj +++ b/samples/Javascript/CrystalCraze/proj.win32/CrystalCraze.vcxproj @@ -34,11 +34,13 @@ - + + - + + @@ -77,7 +79,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -96,11 +98,11 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -110,7 +112,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\CrystalCrazeRes" rd /s /q "$(OutDir)\CrystalCrazeRes" mkdir "$(OutDir)\CrystalCrazeRes" -xcopy "$(ProjectDir)..\..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\CrystalCrazeRes" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\javascript\script\*.js" "$(OutDir)\CrystalCrazeRes" /e /Y xcopy "$(ProjectDir)..\..\Shared\games\CrystalCraze\Published-Android" "$(OutDir)\CrystalCrazeRes\" /e /Y @@ -131,7 +133,7 @@ xcopy "$(ProjectDir)..\..\Shared\games\CrystalCraze\Published-Android" "$(OutDir testjs_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_JAVASCRIPT=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -151,20 +153,21 @@ xcopy "$(ProjectDir)..\..\Shared\games\CrystalCraze\Published-Android" "$(OutDir if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 + true if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\CrystalCrazeRes" rd /s /q "$(OutDir)\CrystalCrazeRes" mkdir "$(OutDir)\CrystalCrazeRes" -xcopy "$(ProjectDir)..\..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\CrystalCrazeRes" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\javascript\script\*.js" "$(OutDir)\CrystalCrazeRes" /e /Y xcopy "$(ProjectDir)..\..\Shared\games\CrystalCraze\Published-Android" "$(OutDir)\CrystalCrazeRes\" /e /Y Copy js and resource files. @@ -185,13 +188,44 @@ xcopy "$(ProjectDir)..\..\Shared\games\CrystalCraze\Published-Android" "$(OutDir - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} - false - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} - false + + + {811c0dab-7b96-4bd3-a154-b7572b58e4ab} + + + {b57cf53f-2e49-4031-9822-047cc0e6bde2} + + + {df2638c0-8128-4847-867c-6eafe3dee7b5} + + + {21070e58-eec6-4e16-8b4f-6d083df55790} + + + {f9da0fc1-651b-457b-962e-a4d61cebf5fd} + + + {625f7391-9a91-48a1-8cfc-79508c822637} + + + {68f5f371-bd7b-4c30-ae5b-0b08f22e0cde} + + + {39379840-825a-45a0-b363-c09ffef864bd} + + + {632a8f38-d0f0-4d22-86b3-d69f5e6bf63a} + + + {21b2c324-891f-48ea-ad1a-5ae13de12e28} + + + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} diff --git a/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp b/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp index 7e7a33a156..c1406c1586 100644 --- a/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp +++ b/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp @@ -5,11 +5,12 @@ #include "ScriptingCore.h" #include "jsb_cocos2dx_auto.hpp" #include "jsb_cocos2dx_extension_auto.hpp" -#include "jsb_cocos2dx_extension_manual.h" +#include "jsb_cocos2dx_builder_auto.hpp" +#include "extension/jsb_cocos2dx_extension_manual.h" #include "cocos2d_specifics.hpp" -#include "js_bindings_ccbreader.h" -#include "js_bindings_system_registration.h" -#include "js_bindings_chipmunk_registration.h" +#include "cocosbuilder/js_bindings_ccbreader.h" +#include "localstorage/js_bindings_system_registration.h" +#include "chipmunk/js_bindings_chipmunk_registration.h" #include "jsb_opengl_registration.h" USING_NS_CC; @@ -48,6 +49,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(jsb_register_chipmunk); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); + sc->addRegisterCallback(register_all_cocos2dx_builder); sc->addRegisterCallback(register_CCBuilderReader); sc->addRegisterCallback(jsb_register_system); sc->addRegisterCallback(JSB_register_opengl); diff --git a/samples/Javascript/MoonWarriors/proj.android/build_native.cmd b/samples/Javascript/MoonWarriors/proj.android/build_native.cmd index d2dbb3a7e8..e2c1c82c7e 100644 --- a/samples/Javascript/MoonWarriors/proj.android/build_native.cmd +++ b/samples/Javascript/MoonWarriors/proj.android/build_native.cmd @@ -57,7 +57,7 @@ set COCOS2DX_ROOT=%~dp0..\..\..\.. set APP_ROOT=%~dp0.. set APP_ANDROID_ROOT=%~dp0 set RESROUCE_ROOT="%APP_ROOT%\..\Shared\games\MoonWarriors\res" -set BINDINGS_JS_ROOT=%APP_ROOT%\..\..\..\scripting\javascript\bindings\js +set BINDINGS_JS_ROOT=%COCOS2DX_ROOT%\cocos\scripting\javascript\script if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) :MODULE1 @@ -66,7 +66,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos;%COCOS2DX_ROOT%\external :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -79,13 +79,12 @@ rem make sure assets is exist if exist %APP_ANDROID_ROOT%\assets rd /q /s %APP_ANDROID_ROOT%\assets mkdir %APP_ANDROID_ROOT%\assets -mkdir %APP_ANDROID_ROOT%\assets\res rem copy Resources/* into assets' root xcopy /e /q /r /y %RESROUCE_ROOT%\* %APP_ANDROID_ROOT%\assets rem copy MoonWarriors js -xcopy /e /q /r /y %RESROUCE_ROOT%\..\src\* %APP_ANDROID_ROOT%\assets +xcopy /e /q /r /y %RESROUCE_ROOT%\..\src %APP_ANDROID_ROOT%\assets rem copy MoonWarriors-native.js xcopy /e /q /r /y %RESROUCE_ROOT%\..\* %APP_ANDROID_ROOT%\assets @@ -93,5 +92,5 @@ xcopy /e /q /r /y %RESROUCE_ROOT%\..\* %APP_ANDROID_ROOT%\assets rem copy bindings/*.js into assets' root xcopy /e /q /r /y %BINDINGS_JS_ROOT%\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd %PARALLEL_BUILD_FLAG% NDK_LOG=0 V=0 +call %NDK_ROOT%\ndk-build.cmd %PARALLEL_BUILD_FLAG% NDK_LOG=0 V=0 %* pause diff --git a/samples/Javascript/MoonWarriors/proj.win32/MoonWarriors.vcxproj b/samples/Javascript/MoonWarriors/proj.win32/MoonWarriors.vcxproj index 1b8d85f756..08efa5fdba 100644 --- a/samples/Javascript/MoonWarriors/proj.win32/MoonWarriors.vcxproj +++ b/samples/Javascript/MoonWarriors/proj.win32/MoonWarriors.vcxproj @@ -34,19 +34,21 @@ - + + - + + <_ProjectFileVersion>10.0.40219.1 - $(ProjectDir)..\..\..\..\$(Configuration).win32\ + $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ false - $(ProjectDir)..\..\..\..\$(Configuration).win32\ + $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ false AllRules.ruleset @@ -77,7 +79,7 @@ Disabled - .;..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + .;..\Classes;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -96,11 +98,11 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -110,7 +112,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\MoonWarriorsRes" rd /s /q "$(OutDir)\MoonWarriorsRes" mkdir "$(OutDir)\MoonWarriorsRes" -xcopy "$(ProjectDir)..\..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\MoonWarriorsRes" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\javascript\script\*.js" "$(OutDir)\MoonWarriorsRes" /e /Y xcopy "$(ProjectDir)..\..\Shared\games\MoonWarriors" "$(OutDir)\MoonWarriorsRes\" /e /Y Copy js and resource files. @@ -129,7 +131,7 @@ xcopy "$(ProjectDir)..\..\Shared\games\MoonWarriors" "$(OutDir)\MoonWarriorsRes\ testjs_p.c - .;..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + .;..\Classes;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -149,20 +151,21 @@ xcopy "$(ProjectDir)..\..\Shared\games\MoonWarriors" "$(OutDir)\MoonWarriorsRes\ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 + true if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\MoonWarriorsRes" rd /s /q "$(OutDir)\MoonWarriorsRes" mkdir "$(OutDir)\MoonWarriorsRes" -xcopy "$(ProjectDir)..\..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\MoonWarriorsRes" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\javascript\script\*.js" "$(OutDir)\MoonWarriorsRes" /e /Y xcopy "$(ProjectDir)..\..\Shared\games\MoonWarriors" "$(OutDir)\MoonWarriorsRes\" /e /Y Copy js and resource files. @@ -183,13 +186,47 @@ xcopy "$(ProjectDir)..\..\Shared\games\MoonWarriors" "$(OutDir)\MoonWarriorsRes\ - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} - false - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} - false + + + {811c0dab-7b96-4bd3-a154-b7572b58e4ab} + + + {b57cf53f-2e49-4031-9822-047cc0e6bde2} + + + {7e06e92c-537a-442b-9e4a-4761c84f8a1a} + + + {df2638c0-8128-4847-867c-6eafe3dee7b5} + + + {21070e58-eec6-4e16-8b4f-6d083df55790} + + + {f9da0fc1-651b-457b-962e-a4d61cebf5fd} + + + {625f7391-9a91-48a1-8cfc-79508c822637} + + + {68f5f371-bd7b-4c30-ae5b-0b08f22e0cde} + + + {39379840-825a-45a0-b363-c09ffef864bd} + + + {632a8f38-d0f0-4d22-86b3-d69f5e6bf63a} + + + {21b2c324-891f-48ea-ad1a-5ae13de12e28} + + + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} diff --git a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp index 51ebd8d85f..2a26806916 100644 --- a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp @@ -5,14 +5,18 @@ #include "ScriptingCore.h" #include "jsb_cocos2dx_auto.hpp" #include "jsb_cocos2dx_extension_auto.hpp" -#include "jsb_cocos2dx_extension_manual.h" +#include "jsb_cocos2dx_builder_auto.hpp" +#include "jsb_cocos2dx_studio_auto.hpp" +#include "extension/jsb_cocos2dx_extension_manual.h" +#include "cocostudio/jsb_cocos2dx_studio_manual.h" #include "cocos2d_specifics.hpp" -#include "js_bindings_chipmunk_registration.h" -#include "js_bindings_system_registration.h" +#include "cocosbuilder/cocosbuilder_specifics.hpp" +#include "chipmunk/js_bindings_chipmunk_registration.h" +#include "localstorage/js_bindings_system_registration.h" #include "jsb_opengl_registration.h" -#include "XMLHTTPRequest.h" -#include "jsb_websocket.h" -#include "js_bindings_ccbreader.h" +#include "network/XMLHTTPRequest.h" +#include "network/jsb_websocket.h" +#include "cocosbuilder/js_bindings_ccbreader.h" USING_NS_CC; USING_NS_CC_EXT; @@ -54,7 +58,12 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(jsb_register_system); sc->addRegisterCallback(MinXmlHttpRequest::_js_register); sc->addRegisterCallback(register_jsb_websocket); + + sc->addRegisterCallback(register_all_cocos2dx_builder); sc->addRegisterCallback(register_CCBuilderReader); + + sc->addRegisterCallback(register_all_cocos2dx_studio); + sc->addRegisterCallback(register_all_cocos2dx_studio_manual); sc->start(); diff --git a/samples/Javascript/TestJavascript/proj.android/build_native.cmd b/samples/Javascript/TestJavascript/proj.android/build_native.cmd index 19ee06dd56..a0a5ec0785 100644 --- a/samples/Javascript/TestJavascript/proj.android/build_native.cmd +++ b/samples/Javascript/TestJavascript/proj.android/build_native.cmd @@ -56,7 +56,7 @@ exit /b 1 set COCOS2DX_ROOT=%~dp0..\..\..\.. set APP_ROOT=%~dp0.. set APP_ANDROID_ROOT=%~dp0 -set BINDINGS_JS_ROOT=%APP_ROOT%\..\..\..\scripting\javascript\bindings\js +set BINDINGS_JS_ROOT=%COCOS2DX_ROOT%\cocos\scripting\javascript\script if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) :MODULE1 @@ -65,7 +65,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos;%COCOS2DX_ROOT%\external :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -86,5 +86,5 @@ xcopy /e /q /r /y %APP_ROOT%\..\Shared\tests\* %APP_ANDROID_ROOT%\assets rem copy bindings/*.js into assets' root xcopy /e /q /r /y %BINDINGS_JS_ROOT%\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd %PARALLEL_BUILD_FLAG% NDK_LOG=0 V=0 +call %NDK_ROOT%\ndk-build.cmd %PARALLEL_BUILD_FLAG% NDK_LOG=0 V=0 %* pause \ No newline at end of file diff --git a/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj b/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj index 6af44de033..1af52eccb0 100644 --- a/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj +++ b/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj @@ -34,11 +34,13 @@ - + + - + + @@ -77,7 +79,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;DEBUG;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -96,12 +98,12 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) + libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -111,7 +113,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\TestJavascriptRes" rd /s /q "$(OutDir)\TestJavascriptRes" mkdir "$(OutDir)\TestJavascriptRes" -xcopy "$(ProjectDir)..\..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\TestJavascriptRes\" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\javascript\script\*.js" "$(OutDir)\TestJavascriptRes\" /e /Y xcopy "$(ProjectDir)..\..\Shared\tests" "$(OutDir)\TestJavascriptRes\" /e /Y @@ -132,7 +134,7 @@ xcopy "$(ProjectDir)..\..\Shared\tests" "$(OutDir)\TestJavascriptRes\" /e /Ytestjs_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -152,21 +154,22 @@ xcopy "$(ProjectDir)..\..\Shared\tests" "$(OutDir)\TestJavascriptRes\" /e /Y if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) + libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 + true if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\TestJavascriptRes" rd /s /q "$(OutDir)\TestJavascriptRes" mkdir "$(OutDir)\TestJavascriptRes" -xcopy "$(ProjectDir)..\..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\TestJavascriptRes\" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\javascript\script\*.js" "$(OutDir)\TestJavascriptRes\" /e /Y xcopy "$(ProjectDir)..\..\Shared\tests" "$(OutDir)\TestJavascriptRes\" /e /Y Copy js and resource files. @@ -187,14 +190,62 @@ xcopy "$(ProjectDir)..\..\Shared\tests" "$(OutDir)\TestJavascriptRes\" /e /Y - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} false - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} false + + {811c0dab-7b96-4bd3-a154-b7572b58e4ab} + + + {b57cf53f-2e49-4031-9822-047cc0e6bde2} + + + {b7c2a162-dec9-4418-972e-240ab3cbfcae} + + + {7e06e92c-537a-442b-9e4a-4761c84f8a1a} + + + {df2638c0-8128-4847-867c-6eafe3dee7b5} + + + {21070e58-eec6-4e16-8b4f-6d083df55790} + + + {f9da0fc1-651b-457b-962e-a4d61cebf5fd} + + + {79d34511-e54e-410a-8bba-ef175ad6c695} + + + {625f7391-9a91-48a1-8cfc-79508c822637} + + + {68f5f371-bd7b-4c30-ae5b-0b08f22e0cde} + + + {3bec13f5-e227-4d80-bc77-1c857f83bcfc} + + + {39379840-825a-45a0-b363-c09ffef864bd} + + + {632a8f38-d0f0-4d22-86b3-d69f5e6bf63a} + + + {21b2c324-891f-48ea-ad1a-5ae13de12e28} + + + {929480e7-23c0-4df6-8456-096d71547116} + + + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} + diff --git a/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp b/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp index 3e9c616b35..663cd87769 100644 --- a/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp +++ b/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp @@ -5,11 +5,12 @@ #include "ScriptingCore.h" #include "jsb_cocos2dx_auto.hpp" #include "jsb_cocos2dx_extension_auto.hpp" -#include "jsb_cocos2dx_extension_manual.h" +#include "jsb_cocos2dx_builder_auto.hpp" +#include "extension/jsb_cocos2dx_extension_manual.h" #include "cocos2d_specifics.hpp" -#include "js_bindings_chipmunk_registration.h" -#include "js_bindings_ccbreader.h" -#include "js_bindings_system_registration.h" +#include "chipmunk/js_bindings_chipmunk_registration.h" +#include "cocosbuilder/js_bindings_ccbreader.h" +#include "localstorage/js_bindings_system_registration.h" #include "jsb_opengl_registration.h" USING_NS_CC; @@ -46,6 +47,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_all_cocos2dx_extension_manual); sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(jsb_register_chipmunk); + sc->addRegisterCallback(register_all_cocos2dx_builder); sc->addRegisterCallback(register_CCBuilderReader); sc->addRegisterCallback(jsb_register_system); sc->addRegisterCallback(JSB_register_opengl); diff --git a/samples/Javascript/WatermelonWithMe/proj.android/build_native.cmd b/samples/Javascript/WatermelonWithMe/proj.android/build_native.cmd index 9594dada6b..a592025ff0 100644 --- a/samples/Javascript/WatermelonWithMe/proj.android/build_native.cmd +++ b/samples/Javascript/WatermelonWithMe/proj.android/build_native.cmd @@ -57,7 +57,7 @@ set COCOS2DX_ROOT=%~dp0..\..\..\.. set APP_ROOT=%~dp0.. set APP_ANDROID_ROOT=%~dp0 set RESROUCE_ROOT="%APP_ROOT%\..\Shared\games\WatermelonWithMe" -set BINDINGS_JS_ROOT=%APP_ROOT%\..\..\..\scripting\javascript\bindings\js +set BINDINGS_JS_ROOT=%COCOS2DX_ROOT%\cocos\scripting\javascript\script if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) :MODULE1 @@ -66,7 +66,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos;%COCOS2DX_ROOT%\external :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -79,7 +79,6 @@ rem make sure assets is exist if exist %APP_ANDROID_ROOT%\assets rd /q /s %APP_ANDROID_ROOT%\assets mkdir %APP_ANDROID_ROOT%\assets -mkdir %APP_ANDROID_ROOT%\assets\res rem copy Resources/* into assets' root xcopy /e /q /r /y %RESROUCE_ROOT%\* %APP_ANDROID_ROOT%\assets @@ -87,5 +86,5 @@ xcopy /e /q /r /y %RESROUCE_ROOT%\* %APP_ANDROID_ROOT%\assets rem copy bindings/*.js into assets' root xcopy /e /q /r /y %BINDINGS_JS_ROOT%\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd %PARALLEL_BUILD_FLAG% NDK_LOG=0 V=0 +call %NDK_ROOT%\ndk-build.cmd %PARALLEL_BUILD_FLAG% NDK_LOG=0 V=0 %* pause diff --git a/samples/Javascript/WatermelonWithMe/proj.win32/WatermelonWithMe.vcxproj b/samples/Javascript/WatermelonWithMe/proj.win32/WatermelonWithMe.vcxproj index b6b8e34883..48f07febfb 100644 --- a/samples/Javascript/WatermelonWithMe/proj.win32/WatermelonWithMe.vcxproj +++ b/samples/Javascript/WatermelonWithMe/proj.win32/WatermelonWithMe.vcxproj @@ -34,11 +34,13 @@ - + + - + + @@ -77,7 +79,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -96,11 +98,11 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -110,7 +112,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\WatermelonWithMeRes" rd /s /q "$(OutDir)\WatermelonWithMeRes" mkdir "$(OutDir)\WatermelonWithMeRes" -xcopy "$(ProjectDir)..\..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\WatermelonWithMeRes" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\javascript\script\*.js" "$(OutDir)\WatermelonWithMeRes" /e /Y xcopy "$(ProjectDir)..\..\Shared\games\WatermelonWithMe" "$(OutDir)\WatermelonWithMeRes\" /e /Y @@ -131,7 +133,7 @@ xcopy "$(ProjectDir)..\..\Shared\games\WatermelonWithMe" "$(OutDir)\WatermelonWi testjs_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -151,20 +153,21 @@ xcopy "$(ProjectDir)..\..\Shared\games\WatermelonWithMe" "$(OutDir)\WatermelonWi if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 + true if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\WatermelonWithMeRes" rd /s /q "$(OutDir)\WatermelonWithMeRes" mkdir "$(OutDir)\WatermelonWithMeRes" -xcopy "$(ProjectDir)..\..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\WatermelonWithMeRes" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\javascript\script\*.js" "$(OutDir)\WatermelonWithMeRes" /e /Y xcopy "$(ProjectDir)..\..\Shared\games\WatermelonWithMe" "$(OutDir)\WatermelonWithMeRes\" /e /Y Copy js and resource files. @@ -185,13 +188,47 @@ xcopy "$(ProjectDir)..\..\Shared\games\WatermelonWithMe" "$(OutDir)\WatermelonWi - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} - false - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} - false + + + {811c0dab-7b96-4bd3-a154-b7572b58e4ab} + + + {b57cf53f-2e49-4031-9822-047cc0e6bde2} + + + {7e06e92c-537a-442b-9e4a-4761c84f8a1a} + + + {df2638c0-8128-4847-867c-6eafe3dee7b5} + + + {21070e58-eec6-4e16-8b4f-6d083df55790} + + + {f9da0fc1-651b-457b-962e-a4d61cebf5fd} + + + {625f7391-9a91-48a1-8cfc-79508c822637} + + + {68f5f371-bd7b-4c30-ae5b-0b08f22e0cde} + + + {39379840-825a-45a0-b363-c09ffef864bd} + + + {632a8f38-d0f0-4d22-86b3-d69f5e6bf63a} + + + {21b2c324-891f-48ea-ad1a-5ae13de12e28} + + + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} diff --git a/samples/Lua/HelloLua/proj.android/build_native.cmd b/samples/Lua/HelloLua/proj.android/build_native.cmd index 7daf57dd23..4116608669 100644 --- a/samples/Lua/HelloLua/proj.android/build_native.cmd +++ b/samples/Lua/HelloLua/proj.android/build_native.cmd @@ -62,7 +62,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos;%COCOS2DX_ROOT%\external :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -75,13 +75,12 @@ rem make sure assets is exist if exist %APP_ANDROID_ROOT%\assets rd /q /s %APP_ANDROID_ROOT%\assets mkdir %APP_ANDROID_ROOT%\assets -mkdir %APP_ANDROID_ROOT%\assets\res rem copy Resources/* into assets' root xcopy /e /q /r /y %APP_ROOT%\Resources\* %APP_ANDROID_ROOT%\assets rem copy common luaScript -xcopy /e /q /r /y %APP_ROOT%\..\..\scripting\lua\script\* %APP_ANDROID_ROOT%\assets +xcopy /e /q /r /y %COCOS2DX_ROOT%\cocos\scripting\lua\script\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 +call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 %* pause \ No newline at end of file diff --git a/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj b/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj index f01edcaf43..fb17ddfe2e 100644 --- a/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj +++ b/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj @@ -34,11 +34,13 @@ - + + - + + @@ -77,7 +79,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\auto-generated\lua-bindings;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\scripting\lua\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -95,14 +97,14 @@ $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(IntDir);%(AdditionalIncludeDirectories) - libcocos2d.lib;libCocosDenshion.lib;liblua.lib;lua51.lib;libExtensions.lib;websockets.lib;libchipmunk.lib;%(AdditionalDependencies) + lua51.lib;websockets.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows MachineX86 - xcopy "$(ProjectDir)..\..\..\..\scripting\lua\script" "$(ProjectDir)..\..\HelloLua\Resources" /e /Y + xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua\script" "$(ProjectDir)..\..\HelloLua\Resources" /e /Y @@ -119,7 +121,7 @@ HelloLua_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\auto-generated\lua-bindings;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\scripting\lua\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -138,10 +140,11 @@ $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(IntDir);%(AdditionalIncludeDirectories) - libcocos2d.lib;libCocosDenshion.lib;liblua.lib;lua51.lib;libExtensions.lib;%(AdditionalDependencies) + lua51.lib;websockets.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 + true @@ -153,17 +156,35 @@ - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} - false - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} - false - + + {811c0dab-7b96-4bd3-a154-b7572b58e4ab} + + + {b57cf53f-2e49-4031-9822-047cc0e6bde2} + + + {7e06e92c-537a-442b-9e4a-4761c84f8a1a} + + + {df2638c0-8128-4847-867c-6eafe3dee7b5} + + {ddc3e27f-004d-4dd4-9dd3-931a013d2159} - false + + + {632a8f38-d0f0-4d22-86b3-d69f5e6bf63a} + + + {21b2c324-891f-48ea-ad1a-5ae13de12e28} + + + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} diff --git a/samples/Lua/TestLua/proj.android/build_native.cmd b/samples/Lua/TestLua/proj.android/build_native.cmd index 5602f41812..fa1fc0ad75 100644 --- a/samples/Lua/TestLua/proj.android/build_native.cmd +++ b/samples/Lua/TestLua/proj.android/build_native.cmd @@ -62,7 +62,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos;%COCOS2DX_ROOT%\external :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -75,13 +75,19 @@ rem make sure assets is exist if exist %APP_ANDROID_ROOT%\assets rd /q /s %APP_ANDROID_ROOT%\assets mkdir %APP_ANDROID_ROOT%\assets -mkdir %APP_ANDROID_ROOT%\assets\res rem copy Resources/* into assets' root xcopy /e /q /r /y %APP_ROOT%\Resources\* %APP_ANDROID_ROOT%\assets rem copy common luaScript -xcopy /e /q /r /y %APP_ROOT%\..\..\scripting\lua\script\* %APP_ANDROID_ROOT%\assets +xcopy /e /q /r /y %COCOS2DX_ROOT%\cocos\scripting\lua\script\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 +rem remove test_image_rgba4444.pvr.gz +del /f /q %APP_ANDROID_ROOT%\assets\Images\test_image_rgba4444.pvr.gz +del /f /q %APP_ANDROID_ROOT%\assets\Images\test_1021x1024_rgba8888.pvr.gz +del /f /q %APP_ANDROID_ROOT%\assets\Images\test_1021x1024_rgb888.pvr.gz +del /f /q %APP_ANDROID_ROOT%\assets\Images\test_1021x1024_rgba4444.pvr.gz +del /f /q %APP_ANDROID_ROOT%\assets\Images\test_1021x1024_a8.pvr.gz + +call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 %* pause \ No newline at end of file diff --git a/samples/Lua/TestLua/proj.win32/TestLua.win32.vcxproj b/samples/Lua/TestLua/proj.win32/TestLua.win32.vcxproj index 1d7682a2d2..0a4ea9edbd 100644 --- a/samples/Lua/TestLua/proj.win32/TestLua.win32.vcxproj +++ b/samples/Lua/TestLua/proj.win32/TestLua.win32.vcxproj @@ -36,11 +36,13 @@ - + + - + + @@ -64,7 +66,7 @@ - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\auto-generated\lua-bindings;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\external;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\scripting\lua\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) Level3 @@ -82,7 +84,7 @@ MachineX86 true $(OutDir);%(AdditionalLibraryDirectories) - libcocos2d.lib;libExtensions.lib;libBox2d.lib;libchipmunk.lib;libCocosDenshion.lib;liblua.lib;lua51.lib;websockets.lib;%(AdditionalDependencies) + lua51.lib;websockets.lib;%(AdditionalDependencies) 0x0409 @@ -103,17 +105,17 @@ xcopy "$(ProjectDir)..\..\..\Cpp\TestCpp\Resources" "$(ProjectDir)..\..\TestLua\Resources" /e /Y -xcopy "$(ProjectDir)..\..\..\..\scripting\lua\script" "$(ProjectDir)..\..\TestLua\Resources" /e /Y +xcopy "$(EngineRoot)cocos\scripting\lua\script" "$(ProjectDir)..\..\TestLua\Resources" /e /Y copy files from TestCpp to TestLua if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(EngineRoot)external\websockets\prebuilt\\win32\*.*" "$(OutDir)" - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\auto-generated\lua-bindings;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\external;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\scripting\lua\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) Level3 @@ -129,7 +131,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O Windows MachineX86 $(OutDir);%(AdditionalLibraryDirectories) - libcocos2d.lib;libExtensions.lib;libBox2d.lib;libchipmunk.lib;libCocosDenshion.lib;liblua.lib;lua51.lib;websockets.lib;%(AdditionalDependencies) + lua51.lib;websockets.lib;%(AdditionalDependencies) true @@ -151,12 +153,12 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O xcopy "$(ProjectDir)..\..\..\Cpp\TestCpp\Resources" "$(ProjectDir)..\..\TestLua\Resources" /e /Y -xcopy "$(ProjectDir)..\..\..\..\scripting\lua\script" "$(ProjectDir)..\..\TestLua\Resources" /e /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua\script" "$(ProjectDir)..\..\TestLua\Resources" /e /Y copy files from TestCpp to TestLua if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" @@ -167,6 +169,38 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O + + + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} + + + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} + + + {811c0dab-7b96-4bd3-a154-b7572b58e4ab} + + + {b57cf53f-2e49-4031-9822-047cc0e6bde2} + + + {7e06e92c-537a-442b-9e4a-4761c84f8a1a} + + + {df2638c0-8128-4847-867c-6eafe3dee7b5} + + + {ddc3e27f-004d-4dd4-9dd3-931a013d2159} + + + {632a8f38-d0f0-4d22-86b3-d69f5e6bf63a} + + + {21b2c324-891f-48ea-ad1a-5ae13de12e28} + + + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} + + diff --git a/template/multi-platform-cpp/proj.android/build_native.cmd b/template/multi-platform-cpp/proj.android/build_native.cmd index 68a56c815c..5b25ec4817 100644 --- a/template/multi-platform-cpp/proj.android/build_native.cmd +++ b/template/multi-platform-cpp/proj.android/build_native.cmd @@ -62,7 +62,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos;%COCOS2DX_ROOT%\external :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -75,10 +75,9 @@ rem make sure assets is exist if exist %APP_ANDROID_ROOT%\assets rd /q /s %APP_ANDROID_ROOT%\assets mkdir %APP_ANDROID_ROOT%\assets -mkdir %APP_ANDROID_ROOT%\assets\res rem copy Resources/* into assets' root xcopy /e /q /r /y %APP_ROOT%\Resources\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 +call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 %* pause \ No newline at end of file diff --git a/template/multi-platform-cpp/proj.win32/HelloCpp.sln b/template/multi-platform-cpp/proj.win32/HelloCpp.sln index 31c2e25053..774ee12d79 100644 --- a/template/multi-platform-cpp/proj.win32/HelloCpp.sln +++ b/template/multi-platform-cpp/proj.win32/HelloCpp.sln @@ -3,32 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp", "HelloCpp.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}" ProjectSection(ProjectDependencies) = postProject - {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} - {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\..\cocos2dx\proj.win32\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosDenshion", "..\..\..\CocosDenshion\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" - ProjectSection(ProjectDependencies) = postProject - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\..\..\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" - ProjectSection(ProjectDependencies) = postProject - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} - {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "..\..\..\external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\..\..\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\..\..\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -43,22 +28,14 @@ Global {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32 - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.ActiveCfg = Debug|Win32 - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.Build.0 = Debug|Win32 - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.ActiveCfg = Release|Win32 - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.Build.0 = Release|Win32 - {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.ActiveCfg = Debug|Win32 - {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32 - {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32 - {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32 - {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32 - {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32 - {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32 - {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.ActiveCfg = Debug|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.Build.0 = Debug|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.ActiveCfg = Release|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.Build.0 = Release|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.ActiveCfg = Debug|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.Build.0 = Debug|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.ActiveCfg = Release|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/template/multi-platform-cpp/proj.win32/HelloCpp.vcxproj b/template/multi-platform-cpp/proj.win32/HelloCpp.vcxproj index 70a728fe8e..f2e35df259 100644 --- a/template/multi-platform-cpp/proj.win32/HelloCpp.vcxproj +++ b/template/multi-platform-cpp/proj.win32/HelloCpp.vcxproj @@ -36,11 +36,13 @@ - + + - + + @@ -67,7 +69,7 @@ Disabled - $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\external;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\audio\include;$(ProjectDir)..\..\..\extensions;..\Classes;..;%(AdditionalIncludeDirectories) + $(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;..\Classes;..;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -80,7 +82,7 @@ true - libExtensions.lib;libcocos2d.lib;libCocosDenshion.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;websockets.lib;%(AdditionalDependencies) + %(AdditionalDependencies) $(OutDir)$(ProjectName).exe $(OutDir);%(AdditionalLibraryDirectories) true @@ -93,14 +95,14 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(EngineRoot)external\websockets\prebuilt\win32\*.*" "$(OutDir)" MaxSpeed true - $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\external;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\audio\include;$(ProjectDir)..\..\..\extensions;..\Classes;..;%(AdditionalIncludeDirectories) + $(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;..\Classes;..;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true @@ -112,7 +114,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutD true - libExtensions.lib;libcocos2d.lib;libCocosDenshion.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;websockets.lib;%(AdditionalDependencies) + libcurl_imp.lib;websockets.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe $(OutDir);%(AdditionalLibraryDirectories) true @@ -127,7 +129,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutD if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(EngineRoot)external\websockets\prebuilt\win32\*.*" "$(OutDir)" @@ -141,25 +143,15 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutD - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} false - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} - false - - - {21b2c324-891f-48ea-ad1a-5ae13de12e28} - false - - - {929480e7-23c0-4df6-8456-096d71547116} - false {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} - false diff --git a/template/multi-platform-js/Classes/AppDelegate.cpp b/template/multi-platform-js/Classes/AppDelegate.cpp index ec78d9f5ae..4c2fea3abf 100644 --- a/template/multi-platform-js/Classes/AppDelegate.cpp +++ b/template/multi-platform-js/Classes/AppDelegate.cpp @@ -5,14 +5,11 @@ #include "ScriptingCore.h" #include "jsb_cocos2dx_auto.hpp" #include "jsb_cocos2dx_extension_auto.hpp" -#include "jsb_cocos2dx_extension_manual.h" #include "cocos2d_specifics.hpp" -#include "js_bindings_chipmunk_registration.h" -#include "js_bindings_system_registration.h" -#include "js_bindings_ccbreader.h" +#include "extension/jsb_cocos2dx_extension_manual.h" +#include "chipmunk/js_bindings_chipmunk_registration.h" #include "jsb_opengl_registration.h" -#include "XMLHTTPRequest.h" -#include "jsb_websocket.h" +#include "localstorage/js_bindings_system_registration.h" USING_NS_CC; using namespace CocosDenshion; @@ -41,15 +38,11 @@ bool AppDelegate::applicationDidFinishLaunching() ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); sc->addRegisterCallback(register_all_cocos2dx_extension); - sc->addRegisterCallback(register_all_cocos2dx_extension_manual); sc->addRegisterCallback(register_cocos2dx_js_extensions); - sc->addRegisterCallback(register_CCBuilderReader); + sc->addRegisterCallback(register_all_cocos2dx_extension_manual); sc->addRegisterCallback(jsb_register_chipmunk); - sc->addRegisterCallback(jsb_register_system); sc->addRegisterCallback(JSB_register_opengl); - sc->addRegisterCallback(MinXmlHttpRequest::_js_register); - sc->addRegisterCallback(register_jsb_websocket); - + sc->addRegisterCallback(jsb_register_system); sc->start(); ScriptEngineProtocol *engine = ScriptingCore::getInstance(); diff --git a/template/multi-platform-js/proj.android/build_native.cmd b/template/multi-platform-js/proj.android/build_native.cmd index 5934330044..82eb0151a5 100644 --- a/template/multi-platform-js/proj.android/build_native.cmd +++ b/template/multi-platform-js/proj.android/build_native.cmd @@ -56,7 +56,7 @@ exit /b 1 set COCOS2DX_ROOT=%~dp0..\..\.. set APP_ROOT=%~dp0.. set APP_ANDROID_ROOT=%~dp0 -set BINDINGS_JS_ROOT=%APP_ROOT%\..\..\scripting\javascript\bindings\js +set BINDINGS_JS_ROOT=%COCOS2DX_ROOT%\cocos\scripting\javascript\script if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) :MODULE1 @@ -65,7 +65,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos;%COCOS2DX_ROOT%\external :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -86,5 +86,5 @@ xcopy /e /q /r /y %APP_ROOT%\Resources\* %APP_ANDROID_ROOT%\assets rem copy bindings/*.js into assets' root xcopy /e /q /r /y %BINDINGS_JS_ROOT%\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd %PARALLEL_BUILD_FLAG% NDK_LOG=0 V=0 +call %NDK_ROOT%\ndk-build.cmd %PARALLEL_BUILD_FLAG% NDK_LOG=0 V=0 %* pause \ No newline at end of file diff --git a/template/multi-platform-js/proj.win32/HelloJavascript.sln b/template/multi-platform-js/proj.win32/HelloJavascript.sln index 025d85dd02..5880df4c17 100644 --- a/template/multi-platform-js/proj.win32/HelloJavascript.sln +++ b/template/multi-platform-js/proj.win32/HelloJavascript.sln @@ -10,23 +10,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloJavascript", "HelloJav {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\..\cocos2dx\proj.win32\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\..\..\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\..\..\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" - ProjectSection(ProjectDependencies) = postProject - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} - {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosDenshion", "..\..\..\CocosDenshion\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\..\..\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" ProjectSection(ProjectDependencies) = postProject {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "..\..\..\scripting\javascript\bindings\proj.win32\libJSBinding.vcxproj", "{39379840-825A-45A0-B363-C09FFEF864BD}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "..\..\..\cocos\scripting\javascript\bindings\proj.win32\libJSBinding.vcxproj", "{39379840-825A-45A0-B363-C09FFEF864BD}" ProjectSection(ProjectDependencies) = postProject {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} @@ -34,6 +27,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "..\..\..\sc {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForChipmunk", "..\..\..\cocos\scripting\javascript\bindings\chipmunk\libJSBindingForChipmunk.vcxproj", "{21070E58-EEC6-4E16-8B4F-6D083DF55790}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libLocalStorage", "..\..\..\cocos\storage\local-storage\proj.win32\libLocalStorage.vcxproj", "{632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForLocalStorage", "..\..\..\cocos\scripting\javascript\bindings\localstorage\libJSBindingForLocalStorage.vcxproj", "{68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForExtension", "..\..\..\cocos\scripting\javascript\bindings\extension\libJSBindingForExtension.vcxproj", "{625F7391-9A91-48A1-8CFC-79508C822637}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\..\..\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -52,10 +55,6 @@ Global {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.Build.0 = Debug|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.ActiveCfg = Release|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.Build.0 = Release|Win32 - {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.ActiveCfg = Debug|Win32 - {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32 - {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32 - {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32 {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.ActiveCfg = Debug|Win32 {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.Build.0 = Debug|Win32 {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.ActiveCfg = Release|Win32 @@ -64,6 +63,26 @@ Global {39379840-825A-45A0-B363-C09FFEF864BD}.Debug|Win32.Build.0 = Debug|Win32 {39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.ActiveCfg = Release|Win32 {39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.Build.0 = Release|Win32 + {21070E58-EEC6-4E16-8B4F-6D083DF55790}.Debug|Win32.ActiveCfg = Debug|Win32 + {21070E58-EEC6-4E16-8B4F-6D083DF55790}.Debug|Win32.Build.0 = Debug|Win32 + {21070E58-EEC6-4E16-8B4F-6D083DF55790}.Release|Win32.ActiveCfg = Release|Win32 + {21070E58-EEC6-4E16-8B4F-6D083DF55790}.Release|Win32.Build.0 = Release|Win32 + {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}.Debug|Win32.ActiveCfg = Debug|Win32 + {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}.Debug|Win32.Build.0 = Debug|Win32 + {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}.Release|Win32.ActiveCfg = Release|Win32 + {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}.Release|Win32.Build.0 = Release|Win32 + {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Debug|Win32.ActiveCfg = Debug|Win32 + {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Debug|Win32.Build.0 = Debug|Win32 + {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Release|Win32.ActiveCfg = Release|Win32 + {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Release|Win32.Build.0 = Release|Win32 + {625F7391-9A91-48A1-8CFC-79508C822637}.Debug|Win32.ActiveCfg = Debug|Win32 + {625F7391-9A91-48A1-8CFC-79508C822637}.Debug|Win32.Build.0 = Debug|Win32 + {625F7391-9A91-48A1-8CFC-79508C822637}.Release|Win32.ActiveCfg = Release|Win32 + {625F7391-9A91-48A1-8CFC-79508C822637}.Release|Win32.Build.0 = Release|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.ActiveCfg = Debug|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj b/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj index fb2ad0984c..26bab7731b 100644 --- a/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj +++ b/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj @@ -34,11 +34,13 @@ - + + - + + @@ -77,7 +79,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;DEBUG;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -96,11 +98,11 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(EngineRoot)external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(EngineRoot)external\websockets\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) + libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -110,7 +112,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutD if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\HelloJavascriptRes" rd /s /q "$(OutDir)\HelloJavascriptRes" mkdir "$(OutDir)\HelloJavascriptRes" -xcopy "$(ProjectDir)..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\HelloJavascriptRes\" /e /Y +xcopy "$(EngineRoot)cocos\scripting\javascript\script\*.js" "$(OutDir)\HelloJavascriptRes\" /e /Y xcopy "$(ProjectDir)..\Resources" "$(OutDir)\HelloJavascriptRes\" /e /Y @@ -131,7 +133,7 @@ xcopy "$(ProjectDir)..\Resources" "$(OutDir)\HelloJavascriptRes\" /e /Ygame_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\javascript\bindings;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -151,20 +153,21 @@ xcopy "$(ProjectDir)..\Resources" "$(OutDir)\HelloJavascriptRes\" /e /Y if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(EngineRoot)external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(EngineRoot)external\websockets\prebuilt\win32\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) + libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 + true if not exist "$(OutDir)" mkdir "$(OutDir)" if exist "$(OutDir)\HelloJavascriptRes" rd /s /q "$(OutDir)\HelloJavascriptRes" mkdir "$(OutDir)\HelloJavascriptRes" -xcopy "$(ProjectDir)..\..\..\scripting\javascript\bindings\js\*.js" "$(OutDir)\HelloJavascriptRes\" /e /Y +xcopy "$(EngineRoot)cocos\scripting\javascript\script\*.js" "$(OutDir)\HelloJavascriptRes\" /e /Y xcopy "$(ProjectDir)..\Resources" "$(OutDir)\HelloJavascriptRes\" /e /Y Copy js and resource files. @@ -181,13 +184,32 @@ xcopy "$(ProjectDir)..\Resources" "$(OutDir)\HelloJavascriptRes\" /e /Y - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} - false - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} - false + + + {21070e58-eec6-4e16-8b4f-6d083df55790} + + + {625f7391-9a91-48a1-8cfc-79508c822637} + + + {68f5f371-bd7b-4c30-ae5b-0b08f22e0cde} + + + {39379840-825a-45a0-b363-c09ffef864bd} + + + {632a8f38-d0f0-4d22-86b3-d69f5e6bf63a} + + + {21b2c324-891f-48ea-ad1a-5ae13de12e28} + + + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} diff --git a/template/multi-platform-lua/proj.android/build_native.cmd b/template/multi-platform-lua/proj.android/build_native.cmd index e8caf30dd1..0177685738 100644 --- a/template/multi-platform-lua/proj.android/build_native.cmd +++ b/template/multi-platform-lua/proj.android/build_native.cmd @@ -62,7 +62,7 @@ if "%buildexternalsfromsource%"=="1" (goto :MODULE1) else (goto :MODULE2) goto :COPY_RES :MODULE2 echo "Using prebuilt externals" - set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt + set NDK_MODULE_PATH=%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos;%COCOS2DX_ROOT%\external :COPY_RES echo NDK_ROOT = %NDK_ROOT% @@ -75,13 +75,12 @@ rem make sure assets is exist if exist %APP_ANDROID_ROOT%\assets rd /q /s %APP_ANDROID_ROOT%\assets mkdir %APP_ANDROID_ROOT%\assets -mkdir %APP_ANDROID_ROOT%\assets\res rem copy Resources/* into assets' root xcopy /e /q /r /y %APP_ROOT%\Resources\* %APP_ANDROID_ROOT%\assets rem copy common luaScript -xcopy /e /q /r /y %APP_ROOT%\..\..\scripting\lua\script\* %APP_ANDROID_ROOT%\assets +xcopy /e /q /r /y %COCOS2DX_ROOT%\cocos\scripting\lua\script\* %APP_ANDROID_ROOT%\assets -call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 +call %NDK_ROOT%\ndk-build.cmd NDK_LOG=0 V=0 %* pause \ No newline at end of file diff --git a/template/multi-platform-lua/proj.win32/HelloLua.sln b/template/multi-platform-lua/proj.win32/HelloLua.sln index ddd4ee62c8..5fdeacb7a4 100644 --- a/template/multi-platform-lua/proj.win32/HelloLua.sln +++ b/template/multi-platform-lua/proj.win32/HelloLua.sln @@ -11,13 +11,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "HelloLua.vcxpro {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\..\cocos2dx\proj.win32\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosDenshion", "..\..\..\CocosDenshion\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" - ProjectSection(ProjectDependencies) = postProject - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\..\..\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" ProjectSection(ProjectDependencies) = postProject {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} @@ -30,11 +23,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "..\..\..\extern EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\..\..\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "..\..\..\scripting\lua\proj.win32\liblua.vcxproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}" - ProjectSection(ProjectDependencies) = postProject - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\..\..\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "..\..\..\cocos\scripting\lua\bindings\liblua.vcxproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libNetwork", "..\..\..\cocos\network\proj.win32\libNetwork.vcxproj", "{DF2638C0-8128-4847-867C-6EAFE3DEE7B5}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosBuilder", "..\..\..\cocos\editor-support\cocosbuilder\proj.win32\libCocosBuilder.vcxproj", "{811C0DAB-7B96-4BD3-A154-B7572B58E4AB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosStudio", "..\..\..\cocos\editor-support\cocostudio\proj.win32\libCocosStudio.vcxproj", "{B57CF53F-2E49-4031-9822-047CC0E6BDE2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -46,14 +45,6 @@ Global {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.Build.0 = Debug|Win32 {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.ActiveCfg = Release|Win32 {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.Build.0 = Release|Win32 - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32 - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32 - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32 - {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32 - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.ActiveCfg = Debug|Win32 - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.Build.0 = Debug|Win32 - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.ActiveCfg = Release|Win32 - {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.Build.0 = Release|Win32 {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.ActiveCfg = Debug|Win32 {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32 {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32 @@ -66,10 +57,30 @@ Global {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.Build.0 = Debug|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.ActiveCfg = Release|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.Build.0 = Release|Win32 + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32 + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32 + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32 + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.ActiveCfg = Debug|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.Build.0 = Debug|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.ActiveCfg = Release|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.Build.0 = Release|Win32 {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.ActiveCfg = Debug|Win32 {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.Build.0 = Debug|Win32 {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.ActiveCfg = Release|Win32 {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.Build.0 = Release|Win32 + {DF2638C0-8128-4847-867C-6EAFE3DEE7B5}.Debug|Win32.ActiveCfg = Debug|Win32 + {DF2638C0-8128-4847-867C-6EAFE3DEE7B5}.Debug|Win32.Build.0 = Debug|Win32 + {DF2638C0-8128-4847-867C-6EAFE3DEE7B5}.Release|Win32.ActiveCfg = Release|Win32 + {DF2638C0-8128-4847-867C-6EAFE3DEE7B5}.Release|Win32.Build.0 = Release|Win32 + {811C0DAB-7B96-4BD3-A154-B7572B58E4AB}.Debug|Win32.ActiveCfg = Debug|Win32 + {811C0DAB-7B96-4BD3-A154-B7572B58E4AB}.Debug|Win32.Build.0 = Debug|Win32 + {811C0DAB-7B96-4BD3-A154-B7572B58E4AB}.Release|Win32.ActiveCfg = Release|Win32 + {811C0DAB-7B96-4BD3-A154-B7572B58E4AB}.Release|Win32.Build.0 = Release|Win32 + {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Debug|Win32.ActiveCfg = Debug|Win32 + {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Debug|Win32.Build.0 = Debug|Win32 + {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Release|Win32.ActiveCfg = Release|Win32 + {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/template/multi-platform-lua/proj.win32/HelloLua.vcxproj b/template/multi-platform-lua/proj.win32/HelloLua.vcxproj index 2007e7db42..b15be7cabb 100644 --- a/template/multi-platform-lua/proj.win32/HelloLua.vcxproj +++ b/template/multi-platform-lua/proj.win32/HelloLua.vcxproj @@ -36,11 +36,13 @@ - + + - + + @@ -64,7 +66,7 @@ - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\external;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\audio\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\scripting\lua\bindings;$(EngineRoot)external;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\lua;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) Level3 @@ -82,7 +84,7 @@ MachineX86 true $(OutDir);%(AdditionalLibraryDirectories) - libcocos2d.lib;libExtensions.lib;libBox2d.lib;libchipmunk.lib;libCocosDenshion.lib;liblua.lib;lua51.lib;websockets.lib;%(AdditionalDependencies) + lua51.lib;websockets.lib;%(AdditionalDependencies) 0x0409 @@ -102,18 +104,18 @@ - xcopy "$(ProjectDir)..\..\..\scripting\lua\script" "$(ProjectDir)..\Resources" /e /Y + xcopy "$(ProjectDir)..\..\..\cocos\scripting\lua\script" "$(ProjectDir)..\Resources" /e /Y if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\external;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\audio\include;$(ProjectDir)..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\scripting\lua\lua;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\scripting\lua\bindings;$(EngineRoot)external;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\lua;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) Level3 @@ -130,7 +132,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutD Windows MachineX86 $(OutDir);%(AdditionalLibraryDirectories) - libcocos2d.lib;libExtensions.lib;libBox2d.lib;libchipmunk.lib;libCocosDenshion.lib;liblua.lib;lua51.lib;websockets.lib;%(AdditionalDependencies) + lua51.lib;websockets.lib;%(AdditionalDependencies) + true 0x0409 @@ -157,7 +160,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutD if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" @@ -171,6 +174,32 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutD + + + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} + + + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} + + + {811c0dab-7b96-4bd3-a154-b7572b58e4ab} + + + {b57cf53f-2e49-4031-9822-047cc0e6bde2} + + + {df2638c0-8128-4847-867c-6eafe3dee7b5} + + + {ddc3e27f-004d-4dd4-9dd3-931a013d2159} + + + {21b2c324-891f-48ea-ad1a-5ae13de12e28} + + + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} + + diff --git a/tools/tojs/cocos2dx_extension.ini b/tools/tojs/cocos2dx_extension.ini index 1519b2eb92..a6475253f2 100644 --- a/tools/tojs/cocos2dx_extension.ini +++ b/tools/tojs/cocos2dx_extension.ini @@ -13,7 +13,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -cocos_headers = -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/gui -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath/include -I%(cocosdir)s/extensions -I%(cocosdir)s/external -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/gui -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath/include -I%(cocosdir)s/extensions -I%(cocosdir)s/external -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT @@ -23,11 +23,11 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/extensions/cocos-ext.h %(cocosdir)s/cocos/editor-support/cocosbuilder/CocosBuilder.h %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h +headers = %(cocosdir)s/extensions/cocos-ext.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = AssetsManager.* CCBReader.* CCBAnimationManager.* Scale9Sprite Control.* ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$ Armature ArmatureAnimation Skin Bone ArmatureDataManager +classes = AssetsManager.* Scale9Sprite Control.* ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$ # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -36,9 +36,7 @@ classes = AssetsManager.* CCBReader.* CCBAnimationManager.* Scale9Sprite Control # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getCCBMemberVariableAssigner readFloat getCCBSelectorResolver toLowerCase lastPathComponent deletePathExtension endsWith concat getResolutionScale getAnimatedProperties readBool readInt addOwnerCallbackNode addDocumentCallbackName readCachedString readNodeGraphFromData addDocumentCallbackNode getLoadedSpriteSheet initWithData readFileWithCleanUp getOwner$ readNodeGraphFromFile createSceneWithNodeGraphFromFile getAnimationManagers$ setAnimationManagers], - CCBAnimationManager::[setAnimationCompletedCallback], - ScrollView::[(g|s)etDelegate$], +skip = ScrollView::[(g|s)etDelegate$], .*Delegate::[*], .*Loader.*::[*], *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener], @@ -48,15 +46,11 @@ skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getC AssetsManagerDelegateProtocol::[*], Control::[removeHandleOfControlEvent addHandleOfControlEvent], ControlUtils::[*], - ControlSwitchSprite::[*], - Armature::[createBone updateBlendType getBody setBody getShapeList .*BlendFunc], - Skin::[getSkinData setSkinData], - ArmatureAnimation::[updateHandler updateFrameData frameEvent] + ControlSwitchSprite::[*] rename_functions = -rename_classes = CCBReader::_Reader, - CCBAnimationManager::BuilderAnimationManager +rename_classes = # for all class names, should we remove something when registering in the target VM? remove_prefix = @@ -65,11 +59,11 @@ remove_prefix = classes_have_no_parents = # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Object ProcessBase +base_classes_to_skip = Object # classes that create no constructor # Set is special and we will use a hand-written constructor -abstract_classes = ArmatureDataManager +abstract_classes = # Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. script_control_cpp = no diff --git a/tools/tojs/genbindings.sh b/tools/tojs/genbindings.sh index 56b1b4500f..37d07f9d12 100755 --- a/tools/tojs/genbindings.sh +++ b/tools/tojs/genbindings.sh @@ -84,3 +84,9 @@ LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py echo "Generating bindings for cocos2dx_extension..." LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_extension.ini -s cocos2dx_extension -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_extension_auto + +echo "Generating bindings for cocos2dx_builder..." +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_builder.ini -s cocos2dx_builder -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_builder_auto + +echo "Generating bindings for cocos2dx_studio..." +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_studio.ini -s cocos2dx_studio -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_studio_auto \ No newline at end of file From 232f0d598b743c3ed678d1eb8d7a636573fc07e5 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Mon, 21 Oct 2013 22:21:11 +0800 Subject: [PATCH 31/48] issues #2905:add new vs project --- .../proj.win32/libCocosBuilder.vcxproj | 142 ++ .../libCocosBuilder.vcxproj.filters | 170 ++ .../proj.win32/libCocosBuilder.vcxproj.user | 4 + .../proj.win32/libCocosStudio.vcxproj | 174 ++ .../proj.win32/libCocosStudio.vcxproj.filters | 290 +++ .../proj.win32/libCocosStudio.vcxproj.user | 4 + .../spine/proj.win32/libSpine.vcxproj | 134 ++ .../spine/proj.win32/libSpine.vcxproj.filters | 146 ++ .../spine/proj.win32/libSpine.vcxproj.user | 4 + cocos/gui/proj.win32/libGUI.vcxproj | 136 ++ cocos/gui/proj.win32/libGUI.vcxproj.filters | 159 ++ cocos/gui/proj.win32/libGUI.vcxproj.user | 4 + cocos/network/proj.win32/libNetwork.vcxproj | 131 ++ .../proj.win32/libNetwork.vcxproj.filters | 45 + .../proj.win32/libNetwork.vcxproj.user | 3 + ...s_chipmunk_auto_classes.cpp.REMOVED.git-id | 1 + .../js_bindings_chipmunk_auto_classes.h | 66 + ...dings_chipmunk_auto_classes_registration.h | 29 + ...ings_chipmunk_functions.cpp.REMOVED.git-id | 1 + .../chipmunk/js_bindings_chipmunk_functions.h | 292 +++ ...bindings_chipmunk_functions_registration.h | 285 +++ .../chipmunk/js_bindings_chipmunk_manual.cpp | 1624 +++++++++++++++++ .../chipmunk/js_bindings_chipmunk_manual.h | 103 ++ .../js_bindings_chipmunk_registration.cpp | 67 + .../js_bindings_chipmunk_registration.h | 31 + .../chipmunk/libJSBindingForChipmunk.vcxproj | 121 ++ .../libJSBindingForChipmunk.vcxproj.filters | 47 + .../libJSBindingForChipmunk.vcxproj.user | 6 + .../cocosbuilder/cocosbuilder_specifics.hpp | 23 + .../cocosbuilder/js_bindings_ccbreader.cpp | 324 ++++ .../cocosbuilder/js_bindings_ccbreader.h | 60 + .../libJSBindingForBuilder.vcxproj | 119 ++ .../libJSBindingForBuilder.vcxproj.filters | 37 + .../libJSBindingForBuilder.vcxproj.user | 6 + .../cocostudio/jsb_cocos2dx_studio_manual.cpp | 229 +++ .../cocostudio/jsb_cocos2dx_studio_manual.h | 16 + .../cocostudio/libJSBindingForStudio.vcxproj | 118 ++ .../libJSBindingForStudio.vcxproj.filters | 34 + .../libJSBindingForStudio.vcxproj.user | 6 + .../jsb_cocos2dx_extension_manual.cpp | 799 ++++++++ .../extension/jsb_cocos2dx_extension_manual.h | 16 + .../libJSBindingForExtension.vcxproj | 118 ++ .../libJSBindingForExtension.vcxproj.filters | 34 + .../libJSBindingForExtension.vcxproj.user | 6 + .../js_bindings_system_functions.cpp | 75 + .../js_bindings_system_functions.h | 23 + ...s_bindings_system_functions_registration.h | 15 + .../js_bindings_system_registration.cpp | 62 + .../js_bindings_system_registration.h | 31 + .../libJSBindingForLocalStorage.vcxproj | 116 ++ ...ibJSBindingForLocalStorage.vcxproj.filters | 32 + .../libJSBindingForLocalStorage.vcxproj.user | 6 + .../bindings/network/XMLHTTPRequest.cpp | 847 +++++++++ .../bindings/network/XMLHTTPRequest.h | 112 ++ .../bindings/network/jsb_websocket.cpp | 382 ++++ .../bindings/network/jsb_websocket.h | 34 + .../network/libJSBindingForNetwork.vcxproj | 115 ++ .../libJSBindingForNetwork.vcxproj.filters | 29 + .../libJSBindingForNetwork.vcxproj.user | 6 + .../proj.win32/libLocalStorage.vcxproj | 93 + .../libLocalStorage.vcxproj.filters | 21 + .../proj.win32/libLocalStorage.vcxproj.user | 4 + 62 files changed, 8167 insertions(+) create mode 100644 cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj create mode 100644 cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj.filters create mode 100644 cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj.user create mode 100644 cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj create mode 100644 cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters create mode 100644 cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.user create mode 100644 cocos/editor-support/spine/proj.win32/libSpine.vcxproj create mode 100644 cocos/editor-support/spine/proj.win32/libSpine.vcxproj.filters create mode 100644 cocos/editor-support/spine/proj.win32/libSpine.vcxproj.user create mode 100644 cocos/gui/proj.win32/libGUI.vcxproj create mode 100644 cocos/gui/proj.win32/libGUI.vcxproj.filters create mode 100644 cocos/gui/proj.win32/libGUI.vcxproj.user create mode 100644 cocos/network/proj.win32/libNetwork.vcxproj create mode 100644 cocos/network/proj.win32/libNetwork.vcxproj.filters create mode 100644 cocos/network/proj.win32/libNetwork.vcxproj.user create mode 100644 cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.cpp.REMOVED.git-id create mode 100644 cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.h create mode 100644 cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes_registration.h create mode 100644 cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.cpp.REMOVED.git-id create mode 100644 cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.h create mode 100644 cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions_registration.h create mode 100644 cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.cpp create mode 100644 cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.h create mode 100644 cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_registration.cpp create mode 100644 cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_registration.h create mode 100644 cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj create mode 100644 cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj.filters create mode 100644 cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj.user create mode 100644 cocos/scripting/javascript/bindings/cocosbuilder/cocosbuilder_specifics.hpp create mode 100644 cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.cpp create mode 100644 cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.h create mode 100644 cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj create mode 100644 cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj.filters create mode 100644 cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj.user create mode 100644 cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.cpp create mode 100644 cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.h create mode 100644 cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj create mode 100644 cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj.filters create mode 100644 cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj.user create mode 100644 cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp create mode 100644 cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.h create mode 100644 cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj create mode 100644 cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj.filters create mode 100644 cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj.user create mode 100644 cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions.cpp create mode 100644 cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions.h create mode 100644 cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions_registration.h create mode 100644 cocos/scripting/javascript/bindings/localstorage/js_bindings_system_registration.cpp create mode 100644 cocos/scripting/javascript/bindings/localstorage/js_bindings_system_registration.h create mode 100644 cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj create mode 100644 cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj.filters create mode 100644 cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj.user create mode 100644 cocos/scripting/javascript/bindings/network/XMLHTTPRequest.cpp create mode 100644 cocos/scripting/javascript/bindings/network/XMLHTTPRequest.h create mode 100644 cocos/scripting/javascript/bindings/network/jsb_websocket.cpp create mode 100644 cocos/scripting/javascript/bindings/network/jsb_websocket.h create mode 100644 cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj create mode 100644 cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj.filters create mode 100644 cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj.user create mode 100644 cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj create mode 100644 cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj.filters create mode 100644 cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj.user diff --git a/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj b/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj new file mode 100644 index 0000000000..2b44d72452 --- /dev/null +++ b/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj @@ -0,0 +1,142 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {811C0DAB-7B96-4BD3-A154-B7572B58E4AB} + libCocosBuilder + + + + StaticLibrary + true + v110_xp + Unicode + + + StaticLibrary + false + v110_xp + true + Unicode + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + + Level3 + Disabled + + + $(EngineRoot);$(EngineRoot)extensions;$(EngineRoot)cocos\audio\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + 4267;4251;4244;%(DisableSpecificWarnings) + false + + + true + + + + + Level3 + MaxSpeed + true + true + + + $(EngineRoot);$(EngineRoot)extensions;$(EngineRoot)cocos\audio\include;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj.filters b/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj.filters new file mode 100644 index 0000000000..8dfedcc4bf --- /dev/null +++ b/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj.filters @@ -0,0 +1,170 @@ + + + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj.user b/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj.user new file mode 100644 index 0000000000..a375ae3527 --- /dev/null +++ b/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj new file mode 100644 index 0000000000..d52ce8d931 --- /dev/null +++ b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj @@ -0,0 +1,174 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {B57CF53F-2E49-4031-9822-047CC0E6BDE2} + libCocosStudio + + + + StaticLibrary + true + v110_xp + Unicode + + + StaticLibrary + false + v110_xp + true + Unicode + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + + Level3 + Disabled + + + $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + 4267;4251;4244;%(DisableSpecificWarnings) + false + + + true + + + + + Level3 + MaxSpeed + true + true + true + WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + + + true + true + true + + + + + + \ No newline at end of file diff --git a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters new file mode 100644 index 0000000000..10053f03e2 --- /dev/null +++ b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters @@ -0,0 +1,290 @@ + + + + + {d793b86c-0905-4c9b-b6bc-161e351c9eb2} + + + {855f2366-3429-4f77-a080-a41a39c99270} + + + {1a8c6b14-fb28-4485-8417-9b6838fbc4ef} + + + {42f1ce3f-46ab-4a16-a96e-9eb076c873f7} + + + {f8271f80-1663-4425-91c8-7365ec3af017} + + + {48f28446-ffe4-4aa1-a34c-8968c3367ae6} + + + {ad9b4fd1-dc17-4704-9c60-7709eb916f13} + + + {55c682b3-7a48-4fab-ad5a-eb979f3c305e} + + + {c6464479-e0ab-4afc-96fc-1ffc73e40232} + + + {023e3440-1259-4981-ba54-24390d1df447} + + + {e8d09ad5-8816-4724-a10b-04263868ed7c} + + + + + action + + + action + + + action + + + action + + + action + + + components + + + components + + + components + + + components + + + components + + + json + + + json + + + reader + + + reader + + + armature\animation + + + armature\animation + + + armature\animation + + + armature\datas + + + armature\display + + + armature\display + + + armature\display + + + armature\display + + + armature\display + + + armature\utils + + + armature\utils + + + armature\utils + + + armature\utils + + + armature\utils + + + armature\utils + + + armature\utils + + + armature\physics + + + armature + + + armature + + + json\libjson + + + json\libjson + + + json\libjson + + + + + action + + + action + + + action + + + action + + + action + + + components + + + components + + + components + + + components + + + components + + + json + + + json + + + reader + + + reader + + + armature\animation + + + armature\animation + + + armature\animation + + + armature\datas + + + armature\display + + + armature\display + + + armature\display + + + armature\display + + + armature\display + + + armature\utils + + + armature\utils + + + armature\utils + + + armature\utils + + + armature\utils + + + armature\utils + + + armature\utils + + + armature\physics + + + armature + + + armature + + + json\libjson + + + json\libjson + + + json\libjson + + + json\libjson + + + json\libjson + + + json\libjson + + + json\libjson + + + json\libjson + + + json\libjson + + + + + json\libjson + + + json\libjson + + + json\libjson + + + json\libjson + + + \ No newline at end of file diff --git a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.user b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.user new file mode 100644 index 0000000000..a375ae3527 --- /dev/null +++ b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/cocos/editor-support/spine/proj.win32/libSpine.vcxproj b/cocos/editor-support/spine/proj.win32/libSpine.vcxproj new file mode 100644 index 0000000000..b4fc436abf --- /dev/null +++ b/cocos/editor-support/spine/proj.win32/libSpine.vcxproj @@ -0,0 +1,134 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE} + libSpine + + + + StaticLibrary + true + v110_xp + Unicode + + + StaticLibrary + false + v110_xp + true + Unicode + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + + Level3 + Disabled + + + $(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + 4267;4251;4244;%(DisableSpecificWarnings) + false + + + true + + + + + Level3 + MaxSpeed + true + true + + + WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + + + true + true + true + + + + + + \ No newline at end of file diff --git a/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.filters b/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.filters new file mode 100644 index 0000000000..d6ed5b1506 --- /dev/null +++ b/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.filters @@ -0,0 +1,146 @@ + + + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.user b/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.user new file mode 100644 index 0000000000..a375ae3527 --- /dev/null +++ b/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/cocos/gui/proj.win32/libGUI.vcxproj b/cocos/gui/proj.win32/libGUI.vcxproj new file mode 100644 index 0000000000..1e483d4b85 --- /dev/null +++ b/cocos/gui/proj.win32/libGUI.vcxproj @@ -0,0 +1,136 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {7E06E92C-537A-442B-9E4A-4761C84F8A1A} + libGUI + + + + StaticLibrary + true + v110_xp + Unicode + + + StaticLibrary + false + v110_xp + true + Unicode + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + + Level3 + Disabled + + + $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + 4267;4251;4244;%(DisableSpecificWarnings) + false + + + true + + + + + Level3 + MaxSpeed + true + true + + + WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + + + true + true + true + + + + + + \ No newline at end of file diff --git a/cocos/gui/proj.win32/libGUI.vcxproj.filters b/cocos/gui/proj.win32/libGUI.vcxproj.filters new file mode 100644 index 0000000000..12f0d385ab --- /dev/null +++ b/cocos/gui/proj.win32/libGUI.vcxproj.filters @@ -0,0 +1,159 @@ + + + + + {e31ab7d3-b8b2-467f-9e08-fd5fe168b491} + + + {f9d13563-9e5e-4b35-b0e7-d41f587efa42} + + + {ed8a2ae0-5690-4d0d-829b-7c07164c0597} + + + {5f6e9e52-fbe7-4073-ac71-98632f9e6781} + + + {b59b178a-b7e0-4826-ba07-44c46cd29a10} + + + + + UIWidgets\ScrollWidget + + + UIWidgets\ScrollWidget + + + UIWidgets\ScrollWidget + + + UIWidgets\ScrollWidget + + + UIWidgets\ScrollWidget + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + System + + + System + + + System + + + System + + + Layouts + + + Layouts + + + Layouts + + + BaseClasses + + + BaseClasses + + + + + UIWidgets\ScrollWidget + + + UIWidgets\ScrollWidget + + + UIWidgets\ScrollWidget + + + UIWidgets\ScrollWidget + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + System + + + System + + + System + + + System + + + Layouts + + + Layouts + + + Layouts + + + BaseClasses + + + BaseClasses + + + \ No newline at end of file diff --git a/cocos/gui/proj.win32/libGUI.vcxproj.user b/cocos/gui/proj.win32/libGUI.vcxproj.user new file mode 100644 index 0000000000..a375ae3527 --- /dev/null +++ b/cocos/gui/proj.win32/libGUI.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/cocos/network/proj.win32/libNetwork.vcxproj b/cocos/network/proj.win32/libNetwork.vcxproj new file mode 100644 index 0000000000..088538dfed --- /dev/null +++ b/cocos/network/proj.win32/libNetwork.vcxproj @@ -0,0 +1,131 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + libNetwork + {DF2638C0-8128-4847-867C-6EAFE3DEE7B5} + network.win32 + Win32Proj + + + + StaticLibrary + Unicode + v100 + v110 + v110_xp + + + StaticLibrary + NotSet + v100 + v110 + v110_xp + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + false + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + false + AllRules.ruleset + + + AllRules.ruleset + + + + + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) + + + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) + + + + Disabled + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;$(EngineRoot)cocos;$(EngineRoot)external\websockets\include\win32;$(EngineRoot)external\curl\include\win32;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + false + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + 4251 + true + + + winmm.lib;libcocos2d.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + true + Windows + $(TargetDir)$(TargetName).lib + MachineX86 + $(OutDir) + + + + + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;$(EngineRoot)cocos;$(EngineRoot)external\websockets\include\win32;$(EngineRoot)external\curl\include\win32;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level3 + ProgramDatabase + 4251 + true + + + winmm.lib;libcocos2d.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + true + Windows + true + true + $(TargetDir)$(TargetName).lib + MachineX86 + $(OutDir) + + + + + + \ No newline at end of file diff --git a/cocos/network/proj.win32/libNetwork.vcxproj.filters b/cocos/network/proj.win32/libNetwork.vcxproj.filters new file mode 100644 index 0000000000..bbfe567f42 --- /dev/null +++ b/cocos/network/proj.win32/libNetwork.vcxproj.filters @@ -0,0 +1,45 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/cocos/network/proj.win32/libNetwork.vcxproj.user b/cocos/network/proj.win32/libNetwork.vcxproj.user new file mode 100644 index 0000000000..ace9a86acb --- /dev/null +++ b/cocos/network/proj.win32/libNetwork.vcxproj.user @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.cpp.REMOVED.git-id new file mode 100644 index 0000000000..c8c345c32c --- /dev/null +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.cpp.REMOVED.git-id @@ -0,0 +1 @@ +6558be4f421be9227dc4fabf1b682d479825bd18 \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.h b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.h new file mode 100644 index 0000000000..42c8840236 --- /dev/null +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.h @@ -0,0 +1,66 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 +* Script version: v0.3 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_CHIPMUNK + +#include "js_bindings_chipmunk_manual.h" +extern JSObject *JSB_cpConstraint_object; +extern JSClass *JSB_cpConstraint_class; +void JSB_cpConstraint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpGrooveJoint_object; +extern JSClass *JSB_cpGrooveJoint_class; +void JSB_cpGrooveJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpSimpleMotor_object; +extern JSClass *JSB_cpSimpleMotor_class; +void JSB_cpSimpleMotor_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpPivotJoint_object; +extern JSClass *JSB_cpPivotJoint_class; +void JSB_cpPivotJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpPinJoint_object; +extern JSClass *JSB_cpPinJoint_class; +void JSB_cpPinJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpSlideJoint_object; +extern JSClass *JSB_cpSlideJoint_class; +void JSB_cpSlideJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpGearJoint_object; +extern JSClass *JSB_cpGearJoint_class; +void JSB_cpGearJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpDampedRotarySpring_object; +extern JSClass *JSB_cpDampedRotarySpring_class; +void JSB_cpDampedRotarySpring_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpDampedSpring_object; +extern JSClass *JSB_cpDampedSpring_class; +void JSB_cpDampedSpring_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpRatchetJoint_object; +extern JSClass *JSB_cpRatchetJoint_class; +void JSB_cpRatchetJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpRotaryLimitJoint_object; +extern JSClass *JSB_cpRotaryLimitJoint_class; +void JSB_cpRotaryLimitJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpArbiter_object; +extern JSClass *JSB_cpArbiter_class; +void JSB_cpArbiter_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpSpace_object; +extern JSClass *JSB_cpSpace_class; +void JSB_cpSpace_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpBody_object; +extern JSClass *JSB_cpBody_class; +void JSB_cpBody_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpShape_object; +extern JSClass *JSB_cpShape_class; +void JSB_cpShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpCircleShape_object; +extern JSClass *JSB_cpCircleShape_class; +void JSB_cpCircleShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpSegmentShape_object; +extern JSClass *JSB_cpSegmentShape_class; +void JSB_cpSegmentShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpPolyShape_object; +extern JSClass *JSB_cpPolyShape_class; +void JSB_cpPolyShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); + + +#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes_registration.h b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes_registration.h new file mode 100644 index 0000000000..da26c49bb3 --- /dev/null +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes_registration.h @@ -0,0 +1,29 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 +* Script version: v0.3 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_CHIPMUNK + +JSB_cpConstraint_createClass(_cx, chipmunk, "Constraint"); +JSB_cpGrooveJoint_createClass(_cx, chipmunk, "GrooveJoint"); +JSB_cpSimpleMotor_createClass(_cx, chipmunk, "SimpleMotor"); +JSB_cpPivotJoint_createClass(_cx, chipmunk, "PivotJoint"); +JSB_cpPinJoint_createClass(_cx, chipmunk, "PinJoint"); +JSB_cpSlideJoint_createClass(_cx, chipmunk, "SlideJoint"); +JSB_cpGearJoint_createClass(_cx, chipmunk, "GearJoint"); +JSB_cpDampedRotarySpring_createClass(_cx, chipmunk, "DampedRotarySpring"); +JSB_cpDampedSpring_createClass(_cx, chipmunk, "DampedSpring"); +JSB_cpRatchetJoint_createClass(_cx, chipmunk, "RatchetJoint"); +JSB_cpRotaryLimitJoint_createClass(_cx, chipmunk, "RotaryLimitJoint"); +JSB_cpArbiter_createClass(_cx, chipmunk, "Arbiter"); +JSB_cpSpace_createClass(_cx, chipmunk, "Space"); +JSB_cpBody_createClass(_cx, chipmunk, "Body"); +JSB_cpShape_createClass(_cx, chipmunk, "Shape"); +JSB_cpCircleShape_createClass(_cx, chipmunk, "CircleShape"); +JSB_cpSegmentShape_createClass(_cx, chipmunk, "SegmentShape"); +JSB_cpPolyShape_createClass(_cx, chipmunk, "PolyShape"); + + +#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.cpp.REMOVED.git-id new file mode 100644 index 0000000000..5cf2a4495d --- /dev/null +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.cpp.REMOVED.git-id @@ -0,0 +1 @@ +1c5eb9cd58c82de77374cdfa5c9ff647cc8b2f02 \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.h b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.h new file mode 100644 index 0000000000..accf523d5e --- /dev/null +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.h @@ -0,0 +1,292 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 +* Script version: v0.3 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_CHIPMUNK +#include "js_bindings_chipmunk_manual.h" + +#ifdef __cplusplus +extern "C" { +#endif +JSBool JSB_cpArbiterGetCount(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterGetDepth(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterGetElasticity(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterGetFriction(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterGetNormal(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterGetPoint(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterGetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterIgnore(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterIsFirstContact(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterSetElasticity(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterSetFriction(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterSetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterTotalImpulse(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterTotalImpulseWithFriction(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterTotalKE(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpAreaForCircle(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpAreaForSegment(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBBArea(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBBClampVect(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBBContainsBB(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBBContainsVect(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBBExpand(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBBIntersects(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBBIntersectsSegment(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBBMerge(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBBMergedArea(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBBNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBBNewForCircle(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBBSegmentQuery(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBBWrapVect(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyActivate(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyActivateStatic(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyApplyForce(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyApplyImpulse(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyDestroy(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyFree(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetAngVel(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetAngle(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetForce(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetMass(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetMoment(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetPos(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetRot(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetSpace(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetTorque(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetVel(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetVelAtLocalPoint(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetVelAtWorldPoint(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyGetVelLimit(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyInit(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyInitStatic(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyIsRogue(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyIsSleeping(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyIsStatic(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyKineticEnergy(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyLocal2World(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyNewStatic(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyResetForces(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodySetAngVel(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodySetAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodySetAngle(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodySetForce(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodySetMass(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodySetMoment(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodySetPos(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodySetTorque(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodySetVel(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodySetVelLimit(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodySleep(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodySleepWithGroup(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyUpdatePosition(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyUpdateVelocity(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodyWorld2Local(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBoxShapeNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBoxShapeNew2(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpCircleShapeGetOffset(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpCircleShapeGetRadius(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpCircleShapeNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpConstraintActivateBodies(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpConstraintDestroy(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpConstraintFree(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpConstraintGetA(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpConstraintGetB(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpConstraintGetErrorBias(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpConstraintGetImpulse(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpConstraintGetMaxBias(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpConstraintGetMaxForce(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpConstraintGetSpace(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpConstraintSetErrorBias(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpConstraintSetMaxBias(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpConstraintSetMaxForce(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedRotarySpringGetDamping(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedRotarySpringGetRestAngle(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedRotarySpringGetStiffness(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedRotarySpringNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedRotarySpringSetDamping(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedRotarySpringSetRestAngle(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedRotarySpringSetStiffness(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedSpringGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedSpringGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedSpringGetDamping(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedSpringGetRestLength(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedSpringGetStiffness(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedSpringNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedSpringSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedSpringSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedSpringSetDamping(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedSpringSetRestLength(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpDampedSpringSetStiffness(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpGearJointGetPhase(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpGearJointGetRatio(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpGearJointNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpGearJointSetPhase(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpGearJointSetRatio(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpGrooveJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpGrooveJointGetGrooveA(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpGrooveJointGetGrooveB(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpGrooveJointNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpGrooveJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpGrooveJointSetGrooveA(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpGrooveJointSetGrooveB(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpInitChipmunk(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpMomentForBox(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpMomentForBox2(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpMomentForCircle(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpMomentForSegment(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPinJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPinJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPinJointGetDist(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPinJointNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPinJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPinJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPinJointSetDist(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPivotJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPivotJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPivotJointNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPivotJointNew2(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPivotJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPivotJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPolyShapeGetNumVerts(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpPolyShapeGetVert(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpRatchetJointGetAngle(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpRatchetJointGetPhase(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpRatchetJointGetRatchet(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpRatchetJointNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpRatchetJointSetAngle(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpRatchetJointSetPhase(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpRatchetJointSetRatchet(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpResetShapeIdCounter(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpRotaryLimitJointGetMax(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpRotaryLimitJointGetMin(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpRotaryLimitJointNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpRotaryLimitJointSetMax(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpRotaryLimitJointSetMin(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSegmentShapeGetA(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSegmentShapeGetB(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSegmentShapeGetNormal(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSegmentShapeGetRadius(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSegmentShapeNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSegmentShapeSetNeighbors(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeCacheBB(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeDestroy(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeFree(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeGetBB(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeGetBody(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeGetCollisionType(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeGetElasticity(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeGetFriction(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeGetGroup(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeGetLayers(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeGetSensor(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeGetSpace(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeGetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapePointQuery(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeSetBody(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeSetCollisionType(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeSetElasticity(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeSetFriction(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeSetGroup(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeSetLayers(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeSetSensor(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeSetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpShapeUpdate(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSimpleMotorGetRate(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSimpleMotorNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSimpleMotorSetRate(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSlideJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSlideJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSlideJointGetMax(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSlideJointGetMin(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSlideJointNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSlideJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSlideJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSlideJointSetMax(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSlideJointSetMin(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceActivateShapesTouchingShape(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceAddBody(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceAddConstraint(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceAddShape(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceAddStaticShape(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceContainsBody(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceContainsConstraint(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceContainsShape(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceDestroy(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceFree(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceGetCollisionBias(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceGetCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceGetCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceGetCurrentTimeStep(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceGetDamping(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceGetEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceGetGravity(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceGetIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceGetIterations(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceGetSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceGetStaticBody(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceInit(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceIsLocked(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceNew(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpacePointQueryFirst(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceReindexShape(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceReindexShapesForBody(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceReindexStatic(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceRemoveBody(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceRemoveConstraint(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceRemoveShape(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceRemoveStaticShape(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceSetCollisionBias(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceSetCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceSetCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceSetDamping(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceSetEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceSetGravity(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceSetIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceSetIterations(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceSetSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceStep(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceUseSpatialHash(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpfabs(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpfclamp(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpfclamp01(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpflerp(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpflerpconst(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpfmax(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpfmin(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvadd(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvclamp(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvcross(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvdist(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvdistsq(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvdot(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpveql(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvforangle(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvlength(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvlengthsq(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvlerp(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvlerpconst(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvmult(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvnear(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvneg(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvnormalize(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvnormalize_safe(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvperp(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvproject(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvrotate(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvrperp(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvslerp(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvslerpconst(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvsub(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvtoangle(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpvunrotate(JSContext *cx, uint32_t argc, jsval *vp); + +#ifdef __cplusplus +} +#endif + + +#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions_registration.h b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions_registration.h new file mode 100644 index 0000000000..2d84087c28 --- /dev/null +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions_registration.h @@ -0,0 +1,285 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-10-18 +* Script version: v0.3 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_CHIPMUNK + +#include "js_bindings_chipmunk_manual.h" +JS_DefineFunction(_cx, chipmunk, "arbiterGetCount", JSB_cpArbiterGetCount, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterGetDepth", JSB_cpArbiterGetDepth, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterGetElasticity", JSB_cpArbiterGetElasticity, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterGetFriction", JSB_cpArbiterGetFriction, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterGetNormal", JSB_cpArbiterGetNormal, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterGetPoint", JSB_cpArbiterGetPoint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterGetSurfaceVelocity", JSB_cpArbiterGetSurfaceVelocity, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterIgnore", JSB_cpArbiterIgnore, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterIsFirstContact", JSB_cpArbiterIsFirstContact, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterSetElasticity", JSB_cpArbiterSetElasticity, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterSetFriction", JSB_cpArbiterSetFriction, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterSetSurfaceVelocity", JSB_cpArbiterSetSurfaceVelocity, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterTotalImpulse", JSB_cpArbiterTotalImpulse, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterTotalImpulseWithFriction", JSB_cpArbiterTotalImpulseWithFriction, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "arbiterTotalKE", JSB_cpArbiterTotalKE, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "areaForCircle", JSB_cpAreaForCircle, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "areaForSegment", JSB_cpAreaForSegment, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bBArea", JSB_cpBBArea, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bBClampVect", JSB_cpBBClampVect, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bBContainsBB", JSB_cpBBContainsBB, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bBContainsVect", JSB_cpBBContainsVect, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bBExpand", JSB_cpBBExpand, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bBIntersects", JSB_cpBBIntersects, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bBIntersectsSegment", JSB_cpBBIntersectsSegment, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bBMerge", JSB_cpBBMerge, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bBMergedArea", JSB_cpBBMergedArea, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bBNew", JSB_cpBBNew, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bBNewForCircle", JSB_cpBBNewForCircle, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bBSegmentQuery", JSB_cpBBSegmentQuery, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bBWrapVect", JSB_cpBBWrapVect, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyActivate", JSB_cpBodyActivate, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyActivateStatic", JSB_cpBodyActivateStatic, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyApplyForce", JSB_cpBodyApplyForce, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyApplyImpulse", JSB_cpBodyApplyImpulse, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyDestroy", JSB_cpBodyDestroy, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyFree", JSB_cpBodyFree, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetAngVel", JSB_cpBodyGetAngVel, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetAngVelLimit", JSB_cpBodyGetAngVelLimit, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetAngle", JSB_cpBodyGetAngle, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetForce", JSB_cpBodyGetForce, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetMass", JSB_cpBodyGetMass, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetMoment", JSB_cpBodyGetMoment, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetPos", JSB_cpBodyGetPos, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetRot", JSB_cpBodyGetRot, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetSpace", JSB_cpBodyGetSpace, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetTorque", JSB_cpBodyGetTorque, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetVel", JSB_cpBodyGetVel, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetVelAtLocalPoint", JSB_cpBodyGetVelAtLocalPoint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetVelAtWorldPoint", JSB_cpBodyGetVelAtWorldPoint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyGetVelLimit", JSB_cpBodyGetVelLimit, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyInit", JSB_cpBodyInit, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyInitStatic", JSB_cpBodyInitStatic, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyIsRogue", JSB_cpBodyIsRogue, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyIsSleeping", JSB_cpBodyIsSleeping, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyIsStatic", JSB_cpBodyIsStatic, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyKineticEnergy", JSB_cpBodyKineticEnergy, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyLocal2World", JSB_cpBodyLocal2World, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyNew", JSB_cpBodyNew, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyNewStatic", JSB_cpBodyNewStatic, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyResetForces", JSB_cpBodyResetForces, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodySetAngVel", JSB_cpBodySetAngVel, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodySetAngVelLimit", JSB_cpBodySetAngVelLimit, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodySetAngle", JSB_cpBodySetAngle, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodySetForce", JSB_cpBodySetForce, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodySetMass", JSB_cpBodySetMass, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodySetMoment", JSB_cpBodySetMoment, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodySetPos", JSB_cpBodySetPos, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodySetTorque", JSB_cpBodySetTorque, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodySetVel", JSB_cpBodySetVel, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodySetVelLimit", JSB_cpBodySetVelLimit, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodySleep", JSB_cpBodySleep, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodySleepWithGroup", JSB_cpBodySleepWithGroup, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyUpdatePosition", JSB_cpBodyUpdatePosition, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyUpdateVelocity", JSB_cpBodyUpdateVelocity, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "bodyWorld2Local", JSB_cpBodyWorld2Local, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "boxShapeNew", JSB_cpBoxShapeNew, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "boxShapeNew2", JSB_cpBoxShapeNew2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "circleShapeGetOffset", JSB_cpCircleShapeGetOffset, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "circleShapeGetRadius", JSB_cpCircleShapeGetRadius, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "circleShapeNew", JSB_cpCircleShapeNew, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "constraintActivateBodies", JSB_cpConstraintActivateBodies, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "constraintDestroy", JSB_cpConstraintDestroy, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "constraintFree", JSB_cpConstraintFree, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "constraintGetA", JSB_cpConstraintGetA, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "constraintGetB", JSB_cpConstraintGetB, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "constraintGetErrorBias", JSB_cpConstraintGetErrorBias, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "constraintGetImpulse", JSB_cpConstraintGetImpulse, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "constraintGetMaxBias", JSB_cpConstraintGetMaxBias, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "constraintGetMaxForce", JSB_cpConstraintGetMaxForce, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "constraintGetSpace", JSB_cpConstraintGetSpace, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "constraintSetErrorBias", JSB_cpConstraintSetErrorBias, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "constraintSetMaxBias", JSB_cpConstraintSetMaxBias, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "constraintSetMaxForce", JSB_cpConstraintSetMaxForce, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringGetDamping", JSB_cpDampedRotarySpringGetDamping, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringGetRestAngle", JSB_cpDampedRotarySpringGetRestAngle, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringGetStiffness", JSB_cpDampedRotarySpringGetStiffness, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringNew", JSB_cpDampedRotarySpringNew, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringSetDamping", JSB_cpDampedRotarySpringSetDamping, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringSetRestAngle", JSB_cpDampedRotarySpringSetRestAngle, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedRotarySpringSetStiffness", JSB_cpDampedRotarySpringSetStiffness, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedSpringGetAnchr1", JSB_cpDampedSpringGetAnchr1, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedSpringGetAnchr2", JSB_cpDampedSpringGetAnchr2, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedSpringGetDamping", JSB_cpDampedSpringGetDamping, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedSpringGetRestLength", JSB_cpDampedSpringGetRestLength, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedSpringGetStiffness", JSB_cpDampedSpringGetStiffness, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedSpringNew", JSB_cpDampedSpringNew, 7, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedSpringSetAnchr1", JSB_cpDampedSpringSetAnchr1, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedSpringSetAnchr2", JSB_cpDampedSpringSetAnchr2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedSpringSetDamping", JSB_cpDampedSpringSetDamping, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedSpringSetRestLength", JSB_cpDampedSpringSetRestLength, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "dampedSpringSetStiffness", JSB_cpDampedSpringSetStiffness, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "gearJointGetPhase", JSB_cpGearJointGetPhase, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "gearJointGetRatio", JSB_cpGearJointGetRatio, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "gearJointNew", JSB_cpGearJointNew, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "gearJointSetPhase", JSB_cpGearJointSetPhase, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "gearJointSetRatio", JSB_cpGearJointSetRatio, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "grooveJointGetAnchr2", JSB_cpGrooveJointGetAnchr2, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "grooveJointGetGrooveA", JSB_cpGrooveJointGetGrooveA, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "grooveJointGetGrooveB", JSB_cpGrooveJointGetGrooveB, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "grooveJointNew", JSB_cpGrooveJointNew, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "grooveJointSetAnchr2", JSB_cpGrooveJointSetAnchr2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "grooveJointSetGrooveA", JSB_cpGrooveJointSetGrooveA, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "grooveJointSetGrooveB", JSB_cpGrooveJointSetGrooveB, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "initChipmunk", JSB_cpInitChipmunk, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "momentForBox", JSB_cpMomentForBox, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "momentForBox2", JSB_cpMomentForBox2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "momentForCircle", JSB_cpMomentForCircle, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "momentForSegment", JSB_cpMomentForSegment, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "pinJointGetAnchr1", JSB_cpPinJointGetAnchr1, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "pinJointGetAnchr2", JSB_cpPinJointGetAnchr2, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "pinJointGetDist", JSB_cpPinJointGetDist, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "pinJointNew", JSB_cpPinJointNew, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "pinJointSetAnchr1", JSB_cpPinJointSetAnchr1, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "pinJointSetAnchr2", JSB_cpPinJointSetAnchr2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "pinJointSetDist", JSB_cpPinJointSetDist, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "pivotJointGetAnchr1", JSB_cpPivotJointGetAnchr1, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "pivotJointGetAnchr2", JSB_cpPivotJointGetAnchr2, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "pivotJointNew", JSB_cpPivotJointNew, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "pivotJointNew2", JSB_cpPivotJointNew2, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "pivotJointSetAnchr1", JSB_cpPivotJointSetAnchr1, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "pivotJointSetAnchr2", JSB_cpPivotJointSetAnchr2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "polyShapeGetNumVerts", JSB_cpPolyShapeGetNumVerts, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "polyShapeGetVert", JSB_cpPolyShapeGetVert, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "ratchetJointGetAngle", JSB_cpRatchetJointGetAngle, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "ratchetJointGetPhase", JSB_cpRatchetJointGetPhase, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "ratchetJointGetRatchet", JSB_cpRatchetJointGetRatchet, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "ratchetJointNew", JSB_cpRatchetJointNew, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "ratchetJointSetAngle", JSB_cpRatchetJointSetAngle, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "ratchetJointSetPhase", JSB_cpRatchetJointSetPhase, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "ratchetJointSetRatchet", JSB_cpRatchetJointSetRatchet, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "resetShapeIdCounter", JSB_cpResetShapeIdCounter, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "rotaryLimitJointGetMax", JSB_cpRotaryLimitJointGetMax, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "rotaryLimitJointGetMin", JSB_cpRotaryLimitJointGetMin, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "rotaryLimitJointNew", JSB_cpRotaryLimitJointNew, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "rotaryLimitJointSetMax", JSB_cpRotaryLimitJointSetMax, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "rotaryLimitJointSetMin", JSB_cpRotaryLimitJointSetMin, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "segmentShapeGetA", JSB_cpSegmentShapeGetA, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "segmentShapeGetB", JSB_cpSegmentShapeGetB, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "segmentShapeGetNormal", JSB_cpSegmentShapeGetNormal, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "segmentShapeGetRadius", JSB_cpSegmentShapeGetRadius, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "segmentShapeNew", JSB_cpSegmentShapeNew, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "segmentShapeSetNeighbors", JSB_cpSegmentShapeSetNeighbors, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeCacheBB", JSB_cpShapeCacheBB, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeDestroy", JSB_cpShapeDestroy, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeFree", JSB_cpShapeFree, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeGetBB", JSB_cpShapeGetBB, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeGetBody", JSB_cpShapeGetBody, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeGetCollisionType", JSB_cpShapeGetCollisionType, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeGetElasticity", JSB_cpShapeGetElasticity, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeGetFriction", JSB_cpShapeGetFriction, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeGetGroup", JSB_cpShapeGetGroup, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeGetLayers", JSB_cpShapeGetLayers, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeGetSensor", JSB_cpShapeGetSensor, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeGetSpace", JSB_cpShapeGetSpace, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeGetSurfaceVelocity", JSB_cpShapeGetSurfaceVelocity, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapePointQuery", JSB_cpShapePointQuery, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeSetBody", JSB_cpShapeSetBody, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeSetCollisionType", JSB_cpShapeSetCollisionType, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeSetElasticity", JSB_cpShapeSetElasticity, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeSetFriction", JSB_cpShapeSetFriction, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeSetGroup", JSB_cpShapeSetGroup, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeSetLayers", JSB_cpShapeSetLayers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeSetSensor", JSB_cpShapeSetSensor, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeSetSurfaceVelocity", JSB_cpShapeSetSurfaceVelocity, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "shapeUpdate", JSB_cpShapeUpdate, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "simpleMotorGetRate", JSB_cpSimpleMotorGetRate, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "simpleMotorNew", JSB_cpSimpleMotorNew, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "simpleMotorSetRate", JSB_cpSimpleMotorSetRate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "slideJointGetAnchr1", JSB_cpSlideJointGetAnchr1, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "slideJointGetAnchr2", JSB_cpSlideJointGetAnchr2, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "slideJointGetMax", JSB_cpSlideJointGetMax, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "slideJointGetMin", JSB_cpSlideJointGetMin, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "slideJointNew", JSB_cpSlideJointNew, 6, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "slideJointSetAnchr1", JSB_cpSlideJointSetAnchr1, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "slideJointSetAnchr2", JSB_cpSlideJointSetAnchr2, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "slideJointSetMax", JSB_cpSlideJointSetMax, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "slideJointSetMin", JSB_cpSlideJointSetMin, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceActivateShapesTouchingShape", JSB_cpSpaceActivateShapesTouchingShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceAddBody", JSB_cpSpaceAddBody, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceAddConstraint", JSB_cpSpaceAddConstraint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceAddShape", JSB_cpSpaceAddShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceAddStaticShape", JSB_cpSpaceAddStaticShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceContainsBody", JSB_cpSpaceContainsBody, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceContainsConstraint", JSB_cpSpaceContainsConstraint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceContainsShape", JSB_cpSpaceContainsShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceDestroy", JSB_cpSpaceDestroy, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceFree", JSB_cpSpaceFree, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceGetCollisionBias", JSB_cpSpaceGetCollisionBias, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceGetCollisionPersistence", JSB_cpSpaceGetCollisionPersistence, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceGetCollisionSlop", JSB_cpSpaceGetCollisionSlop, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceGetCurrentTimeStep", JSB_cpSpaceGetCurrentTimeStep, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceGetDamping", JSB_cpSpaceGetDamping, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceGetEnableContactGraph", JSB_cpSpaceGetEnableContactGraph, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceGetGravity", JSB_cpSpaceGetGravity, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceGetIdleSpeedThreshold", JSB_cpSpaceGetIdleSpeedThreshold, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceGetIterations", JSB_cpSpaceGetIterations, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceGetSleepTimeThreshold", JSB_cpSpaceGetSleepTimeThreshold, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceGetStaticBody", JSB_cpSpaceGetStaticBody, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceInit", JSB_cpSpaceInit, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceIsLocked", JSB_cpSpaceIsLocked, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceNew", JSB_cpSpaceNew, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spacePointQueryFirst", JSB_cpSpacePointQueryFirst, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceReindexShape", JSB_cpSpaceReindexShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceReindexShapesForBody", JSB_cpSpaceReindexShapesForBody, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceReindexStatic", JSB_cpSpaceReindexStatic, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceRemoveBody", JSB_cpSpaceRemoveBody, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceRemoveConstraint", JSB_cpSpaceRemoveConstraint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceRemoveShape", JSB_cpSpaceRemoveShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceRemoveStaticShape", JSB_cpSpaceRemoveStaticShape, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceSetCollisionBias", JSB_cpSpaceSetCollisionBias, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceSetCollisionPersistence", JSB_cpSpaceSetCollisionPersistence, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceSetCollisionSlop", JSB_cpSpaceSetCollisionSlop, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceSetDamping", JSB_cpSpaceSetDamping, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceSetEnableContactGraph", JSB_cpSpaceSetEnableContactGraph, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceSetGravity", JSB_cpSpaceSetGravity, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceSetIdleSpeedThreshold", JSB_cpSpaceSetIdleSpeedThreshold, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceSetIterations", JSB_cpSpaceSetIterations, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceSetSleepTimeThreshold", JSB_cpSpaceSetSleepTimeThreshold, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceStep", JSB_cpSpaceStep, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "spaceUseSpatialHash", JSB_cpSpaceUseSpatialHash, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "fabs", JSB_cpfabs, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "fclamp", JSB_cpfclamp, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "fclamp01", JSB_cpfclamp01, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "flerp", JSB_cpflerp, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "flerpconst", JSB_cpflerpconst, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "fmax", JSB_cpfmax, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "fmin", JSB_cpfmin, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vadd", JSB_cpvadd, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vclamp", JSB_cpvclamp, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vcross", JSB_cpvcross, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vdist", JSB_cpvdist, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vdistsq", JSB_cpvdistsq, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vdot", JSB_cpvdot, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "veql", JSB_cpveql, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vforangle", JSB_cpvforangle, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vlength", JSB_cpvlength, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vlengthsq", JSB_cpvlengthsq, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vlerp", JSB_cpvlerp, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vlerpconst", JSB_cpvlerpconst, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vmult", JSB_cpvmult, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vnear", JSB_cpvnear, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vneg", JSB_cpvneg, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vnormalize", JSB_cpvnormalize, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vnormalize_safe", JSB_cpvnormalize_safe, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vperp", JSB_cpvperp, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vproject", JSB_cpvproject, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vrotate", JSB_cpvrotate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vrperp", JSB_cpvrperp, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vslerp", JSB_cpvslerp, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vslerpconst", JSB_cpvslerpconst, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vsub", JSB_cpvsub, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vtoangle", JSB_cpvtoangle, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, chipmunk, "vunrotate", JSB_cpvunrotate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + + +#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.cpp b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.cpp new file mode 100644 index 0000000000..14a88c87bb --- /dev/null +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.cpp @@ -0,0 +1,1624 @@ +/* + * JS Bindings: https://github.com/zynga/jsbindings + * + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "extensions/cocos-ext.h" +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_CHIPMUNK + +#include "jsapi.h" +#include "jsfriendapi.h" + +#include "js_bindings_chipmunk_manual.h" +#include "js_manual_conversions.h" + +USING_NS_CC_EXT; +// Function declarations +void static freeSpaceChildren(cpSpace *space); + +template +static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + TypeTest t; + T* cobj = new T(); + cobj->autorelease(); + js_type_class_t *p; + uint32_t typeId = t.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, p); + assert(p); + JSObject *_tmp = JS_NewObject(cx, p->jsclass, p->proto, p->parentProto); + js_proxy_t *pp = jsb_new_proxy(cobj, _tmp); + JS_AddObjectRoot(cx, &pp->obj); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp)); + + return JS_TRUE; +} + +#pragma mark - convertions + +/* + * PhysicsSprite + */ +#pragma mark - PhysicsSprite + +JSClass* JSPROXY_CCPhysicsSprite_class = NULL; +JSObject* JSPROXY_CCPhysicsSprite_object = NULL; +// Constructor + +// Destructor +void JSPROXY_CCPhysicsSprite_finalize(JSFreeOp *fop, JSObject *obj) +{ + CCLOGINFO("jsbindings: finalizing JS object %p (PhysicsSprite)", obj); +} + +// Arguments: +// Ret value: cpBody* (N/A) +JSBool JSPROXY_CCPhysicsSprite_getCPBody(JSContext *cx, uint32_t argc, jsval *vp) { + + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, real) + cpBody* ret_val; + + ret_val = real->getCPBody(); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpBody_object, JSB_cpBody_class, "cpBody" ); + JS_SET_RVAL(cx, vp, ret_jsval); + + return JS_TRUE; +} + +// Arguments: +// Ret value: BOOL (b) +JSBool JSPROXY_CCPhysicsSprite_ignoreBodyRotation(JSContext *cx, uint32_t argc, jsval *vp) { + + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, real) + + bool ret_val; + + ret_val = real->isIgnoreBodyRotation(); + JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret_val)); + return JS_TRUE; +} + +// Arguments: cpBody* +// Ret value: void (None) +JSBool JSPROXY_CCPhysicsSprite_setCPBody_(JSContext *cx, uint32_t argc, jsval *vp) { + + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, real) + + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + + cpBody* arg0; + + ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); + if( ! ok ) return JS_FALSE; + + real->setCPBody((cpBody*)arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: BOOL +// Ret value: void (None) +JSBool JSPROXY_CCPhysicsSprite_setIgnoreBodyRotation_(JSContext *cx, uint32_t argc, jsval *vp) { + + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, real) + + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + JSBool arg0; + + ok &= JS_ValueToBoolean( cx, *argvp++, &arg0 ); + if( ! ok ) return JS_FALSE; + + real->setIgnoreBodyRotation((bool)arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +/* + * PhysicsDebugNode + */ +//#pragma mark - PhysicsDebugNode + +JSClass* JSB_CCPhysicsDebugNode_class = NULL; +JSObject* JSB_CCPhysicsDebugNode_object = NULL; +extern JSObject *js_cocos2dx_CCDrawNode_prototype; + +// Constructor + +// Destructor +void JSB_CCPhysicsDebugNode_finalize(JSFreeOp *fop, JSObject *obj) +{ + CCLOGINFO("jsbindings: finalizing JS object %p (PhysicsDebugNode)", obj); +} + +// Arguments: cpSpace* +// Ret value: PhysicsDebugNode* (o) +JSBool JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + PhysicsDebugNode* ret = PhysicsDebugNode::create(arg0); + jsval jsret; + do { + if (ret) { + TypeTest t; + js_type_class_t *typeClass; + uint32_t typeId = t.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); + assert(typeClass); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + jsret = OBJECT_TO_JSVAL(obj); + js_proxy_t *p = jsb_new_proxy(ret, obj); + JS_AddNamedObjectRoot(cx, &p->obj, "CCDebugNode"); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + + return JS_TRUE; +} + +// Arguments: cpSpace* +// Ret value: void (None) +JSBool JSB_CCPhysicsDebugNode_setSpace_(JSContext *cx, uint32_t argc, jsval *vp) { + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); + PhysicsDebugNode* real = (PhysicsDebugNode *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, real) + + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + real->setSpace(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: +// Ret value: cpSpace* (N/A) +JSBool JSB_CCPhysicsDebugNode_space(JSContext *cx, uint32_t argc, jsval *vp) { + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); + PhysicsDebugNode* real = (PhysicsDebugNode *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, real) + JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); + cpSpace* ret_val; + + ret_val = real->getSpace(); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + JS_SET_RVAL(cx, vp, ret_jsval); + + return JS_TRUE; +} + +void JSB_CCPhysicsDebugNode_createClass(JSContext *cx, JSObject* globalObj, const char* name ) +{ + JSB_CCPhysicsDebugNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_CCPhysicsDebugNode_class->name = name; + JSB_CCPhysicsDebugNode_class->addProperty = JS_PropertyStub; + JSB_CCPhysicsDebugNode_class->delProperty = JS_DeletePropertyStub; + JSB_CCPhysicsDebugNode_class->getProperty = JS_PropertyStub; + JSB_CCPhysicsDebugNode_class->setProperty = JS_StrictPropertyStub; + JSB_CCPhysicsDebugNode_class->enumerate = JS_EnumerateStub; + JSB_CCPhysicsDebugNode_class->resolve = JS_ResolveStub; + JSB_CCPhysicsDebugNode_class->convert = JS_ConvertStub; + JSB_CCPhysicsDebugNode_class->finalize = JSB_CCPhysicsDebugNode_finalize; + JSB_CCPhysicsDebugNode_class->flags = 0; + + static JSPropertySpec properties[] = { + {0, 0, 0, 0, 0} + }; + static JSFunctionSpec funcs[] = { + JS_FN("_setSpace", JSB_CCPhysicsDebugNode_setSpace_, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSpace", JSB_CCPhysicsDebugNode_space, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FN("_create", JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + TypeTest t1; + js_type_class_t *typeClass; + uint32_t typeId = t1.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); + assert(typeClass); + + JSB_CCPhysicsDebugNode_object = JS_InitClass(cx, globalObj, typeClass->proto, JSB_CCPhysicsDebugNode_class, dummy_constructor, 0,properties,funcs,NULL,st_funcs); + + TypeTest t; + js_type_class_t *p; + typeId = t.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, p); + if (!p) { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->type = typeId; + p->jsclass = JSB_CCPhysicsDebugNode_class; + p->proto = JSB_CCPhysicsDebugNode_object; + p->parentProto = typeClass->proto; + HASH_ADD_INT(_js_global_type_ht, type, p); + } +} + +// Arguments: NSString*, CGRect +// Ret value: PhysicsSprite* (o) +JSBool JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static(JSContext *cx, uint32_t argc, jsval *vp) { + + jsval *argv = JS_ARGV(cx, vp); + JSBool ok = JS_TRUE; + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + PhysicsSprite* ret = PhysicsSprite::create(arg0, arg1); + + jsval jsret; + do { + if (ret) { + TypeTest t; + js_type_class_t *typeClass; + uint32_t typeId = t.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); + assert(typeClass); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + jsret = OBJECT_TO_JSVAL(obj); + js_proxy_t *p = jsb_new_proxy(ret, obj); + JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + PhysicsSprite* ret = PhysicsSprite::create(arg0); + + jsval jsret; + do { + if (ret) { + TypeTest t; + js_type_class_t *typeClass; + uint32_t typeId = t.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); + assert(typeClass); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + jsret = OBJECT_TO_JSVAL(obj); + js_proxy_t *p = jsb_new_proxy(ret, obj); + JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + return JS_FALSE; + +} + +// Arguments: SpriteFrame* +// Ret value: PhysicsSprite* (o) +JSBool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static(JSContext *cx, uint32_t argc, jsval *vp) { + jsval *argv = JS_ARGV(cx, vp); + cocos2d::SpriteFrame* arg0; + if (argc >= 1) { + do { + js_proxy_t *proxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + proxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg0) + } while (0); + } + PhysicsSprite* ret = PhysicsSprite::createWithSpriteFrame(arg0); + + jsval jsret; + do { + if (ret) { + TypeTest t; + js_type_class_t *typeClass; + uint32_t typeId = t.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); + assert(typeClass); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + jsret = OBJECT_TO_JSVAL(obj); + js_proxy_t *p = jsb_new_proxy(ret, obj); + JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; +} + +// Arguments: NSString* +// Ret value: PhysicsSprite* (o) +JSBool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, uint32_t argc, jsval *vp) { + jsval *argv = JS_ARGV(cx, vp); + JSBool ok = JS_TRUE; + const char* arg0; + std::string arg0_tmp; + if (argc >= 1) { + ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + } + PhysicsSprite* ret = PhysicsSprite::createWithSpriteFrameName(arg0); + + jsval jsret; + do { + if (ret) { + TypeTest t; + js_type_class_t *typeClass; + uint32_t typeId = t.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); + assert(typeClass); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + jsret = OBJECT_TO_JSVAL(obj); + js_proxy_t *p = jsb_new_proxy(ret, obj); + JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; +} + +void JSPROXY_CCPhysicsSprite_createClass(JSContext *cx, JSObject* globalObj) +{ + JSPROXY_CCPhysicsSprite_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSPROXY_CCPhysicsSprite_class->name = "PhysicsSprite"; + JSPROXY_CCPhysicsSprite_class->addProperty = JS_PropertyStub; + JSPROXY_CCPhysicsSprite_class->delProperty = JS_DeletePropertyStub; + JSPROXY_CCPhysicsSprite_class->getProperty = JS_PropertyStub; + JSPROXY_CCPhysicsSprite_class->setProperty = JS_StrictPropertyStub; + JSPROXY_CCPhysicsSprite_class->enumerate = JS_EnumerateStub; + JSPROXY_CCPhysicsSprite_class->resolve = JS_ResolveStub; + JSPROXY_CCPhysicsSprite_class->convert = JS_ConvertStub; + JSPROXY_CCPhysicsSprite_class->finalize = JSPROXY_CCPhysicsSprite_finalize; + JSPROXY_CCPhysicsSprite_class->flags = 0; + + static JSPropertySpec properties[] = { + {0, 0, 0, 0, 0} + }; + static JSFunctionSpec funcs[] = { + JS_FN("getCPBody", JSPROXY_CCPhysicsSprite_getCPBody, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIgnoreBodyRotation", JSPROXY_CCPhysicsSprite_ignoreBodyRotation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("_setCPBody", JSPROXY_CCPhysicsSprite_setCPBody_, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIgnoreBodyRotation", JSPROXY_CCPhysicsSprite_setIgnoreBodyRotation_, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FN("create", JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithSpriteFrame", JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithSpriteFrameName", JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + TypeTest t1; + js_type_class_t *typeClass; + uint32_t typeId = t1.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); + assert(typeClass); + + JSPROXY_CCPhysicsSprite_object = JS_InitClass(cx, globalObj, typeClass->proto, JSPROXY_CCPhysicsSprite_class, dummy_constructor, 0,properties,funcs,NULL,st_funcs); + + TypeTest t; + js_type_class_t *p; + typeId = t.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, p); + if (!p) { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->type = typeId; + p->jsclass = JSPROXY_CCPhysicsSprite_class; + p->proto = JSPROXY_CCPhysicsSprite_object; + p->parentProto = typeClass->proto; + HASH_ADD_INT(_js_global_type_ht, type, p); + } +} + + +void register_CCPhysicsSprite(JSContext *cx, JSObject *obj) { + jsval nsval; + JSObject *ns; + JS_GetProperty(cx, obj, "cc", &nsval); + if (nsval == JSVAL_VOID) { + ns = JS_NewObject(cx, NULL, NULL, NULL); + nsval = OBJECT_TO_JSVAL(ns); + JS_SetProperty(cx, obj, "cc", &nsval); + } else { + JS_ValueToObject(cx, nsval, &ns); + } + obj = ns; + JSPROXY_CCPhysicsSprite_createClass(cx, obj); +} + +void register_CCPhysicsDebugNode(JSContext *cx, JSObject *obj) { + jsval nsval; + JSObject *ns; + JS_GetProperty(cx, obj, "cc", &nsval); + if (nsval == JSVAL_VOID) { + ns = JS_NewObject(cx, NULL, NULL, NULL); + nsval = OBJECT_TO_JSVAL(ns); + JS_SetProperty(cx, obj, "cc", &nsval); + } else { + JS_ValueToObject(cx, nsval, &ns); + } + obj = ns; + JSB_CCPhysicsDebugNode_createClass(cx, obj, "PhysicsDebugNode"); +} + +JSBool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ) +{ + JSObject *jsobj; + JSBool ok = JS_ValueToObject( cx, vp, &jsobj ); + JSB_PRECONDITION( ok, "Error converting value to object"); + JSB_PRECONDITION( jsobj, "Not a valid JS object"); + + jsval vall, valb, valr, valt; + ok = JS_TRUE; + ok &= JS_GetProperty(cx, jsobj, "l", &vall); + ok &= JS_GetProperty(cx, jsobj, "b", &valb); + ok &= JS_GetProperty(cx, jsobj, "r", &valr); + ok &= JS_GetProperty(cx, jsobj, "t", &valt); + JSB_PRECONDITION( ok, "Error obtaining point properties"); + + double l, b, r, t; + ok &= JS_ValueToNumber(cx, vall, &l); + ok &= JS_ValueToNumber(cx, valb, &b); + ok &= JS_ValueToNumber(cx, valr, &r); + ok &= JS_ValueToNumber(cx, valt, &t); + JSB_PRECONDITION( ok, "Error converting value to numbers"); + + ret->l = l; + ret->b = b; + ret->r = r; + ret->t = t; + + return JS_TRUE; +} + +jsval cpBB_to_jsval(JSContext *cx, cpBB bb ) +{ + JSObject *object = JS_NewObject(cx, NULL, NULL, NULL ); + if (!object) + return JSVAL_VOID; + + if (!JS_DefineProperty(cx, object, "l", DOUBLE_TO_JSVAL(bb.l), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "b", DOUBLE_TO_JSVAL(bb.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "r", DOUBLE_TO_JSVAL(bb.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "t", DOUBLE_TO_JSVAL(bb.t), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) + return JSVAL_VOID; + + return OBJECT_TO_JSVAL(object); +} + +// In order to be compatible with Chipmunk-JS API, +// this function expect to receive an array of numbers, and not an array of vects +// OK: [1,2, 3,4, 5,6] <- expected +// BAD: [{x:1, y:2}, {x:3,y:4}, {x:5, y:6}] <- not expected +JSBool jsval_to_array_of_cpvect( JSContext *cx, jsval vp, cpVect**verts, int *numVerts) +{ + // Parsing sequence + JSObject *jsobj; + JSBool ok = JS_ValueToObject( cx, vp, &jsobj ); + JSB_PRECONDITION( ok, "Error converting value to object"); + + JSB_PRECONDITION( jsobj && JS_IsArrayObject( cx, jsobj), "Object must be an array"); + + uint32_t len; + JS_GetArrayLength(cx, jsobj, &len); + + JSB_PRECONDITION( len%2==0, "Array lenght should be even"); + + cpVect *array = (cpVect*)malloc( sizeof(cpVect) * len/2); + + for( uint32_t i=0; i< len;i++ ) { + jsval valarg; + JS_GetElement(cx, jsobj, i, &valarg); + + double value; + ok = JS_ValueToNumber(cx, valarg, &value); + JSB_PRECONDITION( ok, "Error converting value to nsobject"); + + if(i%2==0) + array[i/2].x = value; + else + array[i/2].y = value; + } + + *numVerts = len/2; + *verts = array; + + return JS_TRUE; +} + +#pragma mark - Collision Handler + +struct collision_handler { + cpCollisionType typeA; + cpCollisionType typeB; + + JSObject *begin; + JSObject *pre; + JSObject *post; + JSObject *separate; + JSObject *jsthis; + JSContext *cx; + + // "owner" of the collision handler + // Needed when the space goes out of scope, it will remove all the allocated collision handlers for him. + cpSpace *space; + + unsigned long hash_key; + + unsigned int is_oo; // Objected oriented API ? + UT_hash_handle hh; +}; + +// hash +struct collision_handler* collision_handler_hash = NULL; + +// helper pair +static unsigned long pair_ints( unsigned long A, unsigned long B ) +{ + // order is not important + unsigned long k1 = MIN(A, B ); + unsigned long k2 = MAX(A, B ); + + return (k1 + k2) * (k1 + k2 + 1) /2 + k2; +} + +static cpBool myCollisionBegin(cpArbiter *arb, cpSpace *space, void *data) +{ + struct collision_handler *handler = (struct collision_handler*) data; + + jsval args[2]; + if( handler->is_oo ) { + args[0] = c_class_to_jsval(handler->cx, arb, JSB_cpArbiter_object, JSB_cpArbiter_class, "cpArbiter"); + args[1] = c_class_to_jsval(handler->cx, space, JSB_cpSpace_object, JSB_cpSpace_class, "cpArbiter"); + } else { + args[0] = opaque_to_jsval( handler->cx, arb); + args[1] = opaque_to_jsval( handler->cx, space ); + } + + jsval rval; + JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->begin), 2, args, &rval); + JSB_PRECONDITION2(ok, handler->cx, cpFalse, "Error calling collision callback: begin"); + + if( JSVAL_IS_BOOLEAN(rval) ) { + JSBool ret = JSVAL_TO_BOOLEAN(rval); + return (cpBool)ret; + } + return cpTrue; +} + +static cpBool myCollisionPre(cpArbiter *arb, cpSpace *space, void *data) +{ + struct collision_handler *handler = (struct collision_handler*) data; + + jsval args[2]; + if( handler->is_oo ) { + args[0] = c_class_to_jsval(handler->cx, arb, JSB_cpArbiter_object, JSB_cpArbiter_class, "cpArbiter"); + args[1] = c_class_to_jsval(handler->cx, space, JSB_cpSpace_object, JSB_cpSpace_class, "cpArbiter"); + } else { + args[0] = opaque_to_jsval( handler->cx, arb); + args[1] = opaque_to_jsval( handler->cx, space ); + } + + jsval rval; + JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->pre), 2, args, &rval); + JSB_PRECONDITION2(ok, handler->cx, JS_FALSE, "Error calling collision callback: pre"); + + if( JSVAL_IS_BOOLEAN(rval) ) { + JSBool ret = JSVAL_TO_BOOLEAN(rval); + return (cpBool)ret; + } + return cpTrue; +} + +static void myCollisionPost(cpArbiter *arb, cpSpace *space, void *data) +{ + struct collision_handler *handler = (struct collision_handler*) data; + + jsval args[2]; + + if( handler->is_oo ) { + args[0] = c_class_to_jsval(handler->cx, arb, JSB_cpArbiter_object, JSB_cpArbiter_class, "cpArbiter"); + args[1] = c_class_to_jsval(handler->cx, space, JSB_cpSpace_object, JSB_cpSpace_class, "cpArbiter"); + } else { + args[0] = opaque_to_jsval( handler->cx, arb); + args[1] = opaque_to_jsval( handler->cx, space ); + } + + jsval ignore; + JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->post), 2, args, &ignore); + JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Post"); +} + +static void myCollisionSeparate(cpArbiter *arb, cpSpace *space, void *data) +{ + struct collision_handler *handler = (struct collision_handler*) data; + + jsval args[2]; + if( handler->is_oo ) { + args[0] = c_class_to_jsval(handler->cx, arb, JSB_cpArbiter_object, JSB_cpArbiter_class, "cpArbiter"); + args[1] = c_class_to_jsval(handler->cx, space, JSB_cpSpace_object, JSB_cpSpace_class, "cpArbiter"); + } else { + args[0] = opaque_to_jsval( handler->cx, arb); + args[1] = opaque_to_jsval( handler->cx, space ); + } + + jsval ignore; + JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->separate), 2, args, &ignore); + JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Separate");} + +#pragma mark - cpSpace + +#pragma mark constructor / destructor + +void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpSpace), handle: %p", jsthis, proxy->handle); + + // space + cpSpace *space = (cpSpace*) proxy->handle; + + + // Remove collision handlers, since the user might have forgotten to manually remove them + struct collision_handler *current, *tmp; + HASH_ITER(hh, collision_handler_hash, current, tmp) { + if( current->space == space ) { + + JSContext *cx = current->cx; + + // unroot it + if( current->begin ) { + JS_RemoveObjectRoot(cx, ¤t->begin); + } + if( current->pre ) + JS_RemoveObjectRoot(cx, ¤t->pre); + if( current->post ) + JS_RemoveObjectRoot(cx, ¤t->post); + if( current->separate ) + JS_RemoveObjectRoot(cx, ¤t->separate); + + HASH_DEL(collision_handler_hash,current); /* delete; users advances to next */ + free(current); /* optional- if you want to free */ + } + } + + // Free Space Children + freeSpaceChildren(space); + + jsb_del_jsobject_for_proxy(space); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpSpaceFree(space); + jsb_del_c_proxy_for_jsobject(jsthis); + } +} + + +#pragma mark addCollisionHandler + +static +JSBool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, cpSpace *space, unsigned int is_oo) +{ + struct collision_handler *handler = (struct collision_handler*) malloc( sizeof(*handler) ); + + JSB_PRECONDITION(handler, "Error allocating memory"); + + JSBool ok = JS_TRUE; + + // args + ok &= jsval_to_int(cx, *argvp++, (int32_t*) &handler->typeA ); + ok &= jsval_to_int(cx, *argvp++, (int32_t*) &handler->typeB ); + + // this is no longer passed, so "this" is going to be "this". +// ok &= JS_ValueToObject(cx, *argvp++, &handler->jsthis ); + handler->jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + + handler->begin = !JSVAL_IS_NULL(*argvp) ? JSVAL_TO_OBJECT(*argvp) : NULL; + argvp++; + handler->pre = !JSVAL_IS_NULL(*argvp) ? JSVAL_TO_OBJECT(*argvp) : NULL; + argvp++; + handler->post = !JSVAL_IS_NULL(*argvp) ? JSVAL_TO_OBJECT(*argvp) : NULL; + argvp++; + handler->separate = !JSVAL_IS_NULL(*argvp) ? JSVAL_TO_OBJECT(*argvp) : NULL; + argvp++; + + JSB_PRECONDITION(ok, "Error parsing arguments"); + + // Object Oriented API ? + handler->is_oo = is_oo; + + // owner of the collision handler + handler->space = space; + + // Root it + if( handler->begin ) + JS_AddNamedObjectRoot(cx, &handler->begin, "begin collision_handler"); + if( handler->pre ) + JS_AddNamedObjectRoot(cx, &handler->pre, "pre collision_handler"); + if( handler->post ) + JS_AddNamedObjectRoot(cx, &handler->post, "post collision_handler"); + if( handler->separate ) + JS_AddNamedObjectRoot(cx, &handler->separate, "separate collision_handler"); + + handler->cx = cx; + + cpSpaceAddCollisionHandler(space, handler->typeA, handler->typeB, + !handler->begin ? NULL : &myCollisionBegin, + !handler->pre ? NULL : &myCollisionPre, + !handler->post ? NULL : &myCollisionPost, + !handler->separate ? NULL : &myCollisionSeparate, + handler ); + + + // + // Already added ? If so, remove it. + // Then add new entry + // + struct collision_handler *hashElement = NULL; + unsigned long paired_key = pair_ints(handler->typeA, handler->typeB ); + HASH_FIND_INT(collision_handler_hash, &paired_key, hashElement); + if( hashElement ) { + HASH_DEL( collision_handler_hash, hashElement ); + free( hashElement ); + } + + handler->hash_key = paired_key; + HASH_ADD_INT( collision_handler_hash, hash_key, handler ); + + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +JSBool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==7, cx, JS_FALSE, "Invalid number of arguments"); + + + jsval *argvp = JS_ARGV(cx,vp); + + // args + cpSpace *space; + JSBool ok = jsval_to_opaque( cx, *argvp++, (void**)&space); + JSB_PRECONDITION(ok, "Error parsing arguments"); + + return __jsb_cpSpace_addCollisionHandler(cx, vp, argvp, space, 0); +} + +// method +JSBool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==6, cx, JS_FALSE, "Invalid number of arguments"); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + void *handle = proxy->handle; + + return __jsb_cpSpace_addCollisionHandler(cx, vp, JS_ARGV(cx,vp), (cpSpace*)handle, 1); +} + +#pragma mark removeCollisionHandler + +static +JSBool __jsb_cpSpace_removeCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, cpSpace *space) +{ + JSBool ok = JS_TRUE; + + cpCollisionType typeA; + cpCollisionType typeB; + ok &= jsval_to_int(cx, *argvp++, (int32_t*) &typeA ); + ok &= jsval_to_int(cx, *argvp++, (int32_t*) &typeB ); + + JSB_PRECONDITION(ok, "Error parsing arguments"); + + cpSpaceRemoveCollisionHandler(space, typeA, typeB ); + + // Remove it + struct collision_handler *hashElement = NULL; + unsigned long key = pair_ints(typeA, typeB ); + HASH_FIND_INT(collision_handler_hash, &key, hashElement); + if( hashElement ) { + + // unroot it + if( hashElement->begin ) + JS_RemoveObjectRoot(cx, &hashElement->begin); + if( hashElement->pre ) + JS_RemoveObjectRoot(cx, &hashElement->pre); + if( hashElement->post ) + JS_RemoveObjectRoot(cx, &hashElement->post); + if( hashElement->separate ) + JS_RemoveObjectRoot(cx, &hashElement->separate); + + HASH_DEL( collision_handler_hash, hashElement ); + free( hashElement ); + } + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Free function +JSBool JSB_cpSpaceRemoveCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==3, cx, JS_FALSE, "Invalid number of arguments"); + + jsval *argvp = JS_ARGV(cx,vp); + + cpSpace* space; + JSBool ok = jsval_to_opaque( cx, *argvp++, (void**)&space); + + JSB_PRECONDITION(ok, "Error parsing arguments"); + + return __jsb_cpSpace_removeCollisionHandler(cx, vp, argvp, space); +} + +// method +JSBool JSB_cpSpace_removeCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==2, cx, JS_FALSE, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + void *handle = proxy->handle; + + return __jsb_cpSpace_removeCollisionHandler(cx, vp, JS_ARGV(cx,vp), (cpSpace*)handle); +} + +#pragma mark Add functios. Root JSObjects + +// Arguments: cpBody* +// Ret value: cpBody* +JSBool JSB_cpSpace_addBody(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpBody* arg1; + + jsval retval = *argvp; struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceAddBody((cpSpace*)arg0 , (cpBody*)arg1 ); + + // Root it: + JS_AddNamedObjectRoot(cx, &retproxy->jsobj, "cpBody"); + + // addBody returns the same object that was added, so return it without conversions + JS_SET_RVAL(cx, vp, retval); + + return JS_TRUE; +} + +// Arguments: cpConstraint* +// Ret value: cpConstraint* +JSBool JSB_cpSpace_addConstraint(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpConstraint* arg1; + + jsval retval = *argvp; struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceAddConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); + + // Root it: + JS_AddNamedObjectRoot(cx, &retproxy->jsobj, "cpConstraint"); + + // addConstraint returns the same object that was added, so return it without conversions + JS_SET_RVAL(cx, vp, retval); + + return JS_TRUE; +} + +// Arguments: cpShape* +// Ret value: cpShape* +JSBool JSB_cpSpace_addShape(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpShape* arg1; + + jsval retval = *argvp; struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceAddShape((cpSpace*)arg0 , (cpShape*)arg1 ); + + // Root it: + JS_AddNamedObjectRoot(cx, &retproxy->jsobj, "cpShape"); + + // addShape returns the same object that was added, so return it without conversions + JS_SET_RVAL(cx, vp, retval); + + return JS_TRUE; +} + +// Arguments: cpShape* +// Ret value: cpShape* +JSBool JSB_cpSpace_addStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpShape* arg1; + + jsval retval = *argvp; struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceAddStaticShape((cpSpace*)arg0 , (cpShape*)arg1 ); + + // Root it: + JS_AddNamedObjectRoot(cx, &retproxy->jsobj, "cpShape (static)"); + + // addStaticShape returns the same object that was added, so return it without conversions + JS_SET_RVAL(cx, vp, retval); + + return JS_TRUE; +} + +#pragma mark Remove functios. Untoot JSObjects + +// Arguments: cpBody* +// Ret value: void +JSBool JSB_cpSpace_removeBody(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpBody* arg1; + + struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceRemoveBody((cpSpace*)arg0 , (cpBody*)arg1 ); + JS_RemoveObjectRoot(cx, &retproxy->jsobj); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: cpConstraint* +// Ret value: void +JSBool JSB_cpSpace_removeConstraint(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpConstraint* arg1; + + struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceRemoveConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); + JS_RemoveObjectRoot(cx, &retproxy->jsobj); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: cpShape* +// Ret value: void +JSBool JSB_cpSpace_removeShape(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpShape* arg1; + + struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceRemoveShape((cpSpace*)arg0 , (cpShape*)arg1 ); + JS_RemoveObjectRoot(cx, &retproxy->jsobj); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: cpShape* +// Ret value: void +JSBool JSB_cpSpace_removeStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpShape* arg1; + + struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceRemoveStaticShape((cpSpace*)arg0 , (cpShape*)arg1 ); + JS_RemoveObjectRoot(cx, &retproxy->jsobj); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} +#pragma mark - Arbiter + +#pragma mark getBodies +static +JSBool __jsb_cpArbiter_getBodies(JSContext *cx, jsval *vp, jsval *argvp, cpArbiter *arbiter, unsigned int is_oo) +{ + cpBody *bodyA; + cpBody *bodyB; + cpArbiterGetBodies(arbiter, &bodyA, &bodyB); + + jsval valA, valB; + if( is_oo ) { + valA = c_class_to_jsval(cx, bodyA, JSB_cpBody_object, JSB_cpBody_class, "cpArbiter"); + valB = c_class_to_jsval(cx, bodyB, JSB_cpBody_object, JSB_cpBody_class, "cpArbiter"); + } else { + valA = opaque_to_jsval(cx, bodyA); + valB = opaque_to_jsval(cx, bodyB); + } + + JSObject *jsobj = JS_NewArrayObject(cx, 2, NULL); + JS_SetElement(cx, jsobj, 0, &valA); + JS_SetElement(cx, jsobj, 1, &valB); + + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); + + return JS_TRUE; +} + +// Free function +JSBool JSB_cpArbiterGetBodies(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + + jsval *argvp = JS_ARGV(cx,vp); + + cpArbiter* arbiter; + if( ! jsval_to_opaque( cx, *argvp++, (void**)&arbiter ) ) + return JS_FALSE; + + return __jsb_cpArbiter_getBodies(cx, vp, argvp, arbiter, 0); +} + +// Method +JSBool JSB_cpArbiter_getBodies(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + JSB_PRECONDITION( proxy, "Invalid private object"); + void *handle = proxy->handle; + + return __jsb_cpArbiter_getBodies(cx, vp, JS_ARGV(cx,vp), (cpArbiter*)handle, 1); +} + +#pragma mark getShapes +static +JSBool __jsb_cpArbiter_getShapes(JSContext *cx, jsval *vp, jsval *argvp, cpArbiter *arbiter, unsigned int is_oo) +{ + cpShape *shapeA; + cpShape *shapeB; + cpArbiterGetShapes(arbiter, &shapeA, &shapeB); + + jsval valA, valB; + if( is_oo ) { + valA = c_class_to_jsval(cx, shapeA, JSB_cpShape_object, JSB_cpShape_class, "cpShape"); + valB = c_class_to_jsval(cx, shapeB, JSB_cpShape_object, JSB_cpShape_class, "cpShape"); + } else { + valA = opaque_to_jsval(cx, shapeA); + valB = opaque_to_jsval(cx, shapeB); + } + + JSObject *jsobj = JS_NewArrayObject(cx, 2, NULL); + JS_SetElement(cx, jsobj, 0, &valA); + JS_SetElement(cx, jsobj, 1, &valB); + + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); + + return JS_TRUE; +} + +// function +JSBool JSB_cpArbiterGetShapes(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + + jsval *argvp = JS_ARGV(cx,vp); + + cpArbiter* arbiter; + if( ! jsval_to_opaque( cx, *argvp++, (void**) &arbiter ) ) + return JS_FALSE; + + return __jsb_cpArbiter_getShapes(cx, vp, argvp, arbiter, 0); +} + +// method +JSBool JSB_cpArbiter_getShapes(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + void *handle = proxy->handle; + + return __jsb_cpArbiter_getShapes(cx, vp, JS_ARGV(cx,vp), (cpArbiter*)handle, 1); +} + +#pragma mark - Body + +#pragma mark constructor + +// Manually added to identify static vs dynamic bodies +JSBool JSB_cpBody_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==2, cx, JS_FALSE, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpBody_class, JSB_cpBody_object, NULL); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + double m; double i; + + ok &= JS_ValueToNumber( cx, *argvp++, &m ); + ok &= JS_ValueToNumber( cx, *argvp++, &i ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpBody *ret_body = NULL; + if( m == INFINITY && i == INFINITY) { + ret_body = cpBodyNewStatic(); + + // XXX: Hack. IT WILL LEAK "rogue" objects., But at least it prevents a crash. + // The thing is that "rogue" bodies needs to be freed after the its shape, and I am not sure + // how to do it in a "js" way. + jsb_set_c_proxy_for_jsobject(jsobj, ret_body, JSB_C_FLAG_DO_NOT_CALL_FREE); + } else { + ret_body = cpBodyNew((cpFloat)m , (cpFloat)i ); + jsb_set_c_proxy_for_jsobject(jsobj, ret_body, JSB_C_FLAG_CALL_FREE); + } + + jsb_set_jsobject_for_proxy(jsobj, ret_body); + + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); + return JS_TRUE; +} + +#pragma mark getUserData + +static +JSBool __jsb_cpBody_getUserData(JSContext *cx, jsval *vp, jsval *argvp, cpBody *body) +{ + JSObject *data = (JSObject*) cpBodyGetUserData(body); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(data)); + + return JS_TRUE; +} + +// free function +JSBool JSB_cpBodyGetUserData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + + jsval *argvp = JS_ARGV(cx,vp); + cpBody *body; + if( ! jsval_to_opaque( cx, *argvp++, (void**) &body ) ) + return JS_FALSE; + + return __jsb_cpBody_getUserData(cx, vp, argvp, body); +} + +// method +JSBool JSB_cpBody_getUserData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + void *handle = proxy->handle; + + return __jsb_cpBody_getUserData(cx, vp, JS_ARGV(cx,vp), (cpBody*)handle); +} + + +#pragma mark setUserData + +static +JSBool __jsb_cpBody_setUserData(JSContext *cx, jsval *vp, jsval *argvp, cpBody *body) +{ + JSObject *jsobj; + + JSBool ok = JS_ValueToObject(cx, *argvp++, &jsobj); + + JSB_PRECONDITION(ok, "Error parsing arguments"); + + cpBodySetUserData(body, jsobj); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +// free function +JSBool JSB_cpBodySetUserData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==2, cx, JS_FALSE, "Invalid number of arguments"); + + jsval *argvp = JS_ARGV(cx,vp); + cpBody *body; + JSBool ok = jsval_to_opaque( cx, *argvp++, (void**) &body ); + JSB_PRECONDITION(ok, "Error parsing arguments"); + return __jsb_cpBody_setUserData(cx, vp, argvp, body); +} + +// method +JSBool JSB_cpBody_setUserData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + void *handle = proxy->handle; + + return __jsb_cpBody_setUserData(cx, vp, JS_ARGV(cx,vp), (cpBody*)handle); +} + +#pragma mark - Poly related + +// cpFloat cpAreaForPoly(const int numVerts, const cpVect *verts); +JSBool JSB_cpAreaForPoly(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpVect *verts; + int numVerts; + + ok &= jsval_to_array_of_cpvect( cx, *argvp++, &verts, &numVerts); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error parsing array"); + + cpFloat area = cpAreaForPoly(numVerts, verts); + + free(verts); + + JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(area)); + return JS_TRUE; +} + +// cpFloat cpMomentForPoly(cpFloat m, int numVerts, const cpVect *verts, cpVect offset); +JSBool JSB_cpMomentForPoly(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==3, cx, JS_FALSE, "Invalid number of arguments"); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpVect *verts; cpVect offset; + int numVerts; + double m; + + ok &= JS_ValueToNumber(cx, *argvp++, &m); + ok &= jsval_to_array_of_cpvect( cx, *argvp++, &verts, &numVerts); + ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &offset ); + + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error parsing args"); + + cpFloat moment = cpMomentForPoly((cpFloat)m, numVerts, verts, offset); + + free(verts); + + JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(moment)); + return JS_TRUE; +} + +// cpVect cpCentroidForPoly(const int numVerts, const cpVect *verts); +JSBool JSB_cpCentroidForPoly(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpVect *verts; + int numVerts; + + ok &= jsval_to_array_of_cpvect( cx, *argvp++, &verts, &numVerts); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error parsing args"); + + cpVect centroid = cpCentroidForPoly(numVerts, verts); + + free(verts); + + JS_SET_RVAL(cx, vp, cpVect_to_jsval(cx, (cpVect)centroid)); + return JS_TRUE; +} + +// void cpRecenterPoly(const int numVerts, cpVect *verts); +JSBool JSB_cpRecenterPoly(JSContext *cx, uint32_t argc, jsval *vp) +{ + CCASSERT(false, "NOT IMPLEMENTED"); + return JS_FALSE; +} + +#pragma mark - Object Oriented Chipmunk + +/* + * Chipmunk Base Object + */ + +JSClass* JSB_cpBase_class = NULL; +JSObject* JSB_cpBase_object = NULL; +// Constructor +JSBool JSB_cpBase_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc==1, cx, JS_FALSE, "Invalid arguments. Expecting 1"); + + JSObject *jsobj = JS_NewObject(cx, JSB_cpBase_class, JSB_cpBase_object, NULL); + + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + + void *handle = NULL; + + ok = jsval_to_opaque(cx, *argvp++, &handle); + + JSB_PRECONDITION(ok, "Error converting arguments for JSB_cpBase_constructor"); + + jsb_set_c_proxy_for_jsobject(jsobj, handle, JSB_C_FLAG_DO_NOT_CALL_FREE); + jsb_set_jsobject_for_proxy(jsobj, handle); + + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); + return JS_TRUE; +} + +// Destructor +void JSB_cpBase_finalize(JSFreeOp *fop, JSObject *obj) +{ + CCLOGINFO("jsbindings: finalizing JS object %p (cpBase)", obj); + + // should not delete the handle since it was manually added +} + +JSBool JSB_cpBase_getHandle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); + + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + void *handle = proxy->handle; + + jsval ret_val = opaque_to_jsval(cx, handle); + JS_SET_RVAL(cx, vp, ret_val); + return JS_TRUE; +} + +JSBool JSB_cpBase_setHandle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); + + jsval *argvp = JS_ARGV(cx,vp); + + void *handle; + JSBool ok = jsval_to_opaque(cx, *argvp++, &handle); + JSB_PRECONDITION( ok, "Invalid parsing arguments"); + + jsb_set_c_proxy_for_jsobject(jsthis, handle, JSB_C_FLAG_DO_NOT_CALL_FREE); + jsb_set_jsobject_for_proxy(jsthis, handle); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + + +void JSB_cpBase_createClass(JSContext *cx, JSObject* globalObj, const char* name ) +{ + JSB_cpBase_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpBase_class->name = name; + JSB_cpBase_class->addProperty = JS_PropertyStub; + JSB_cpBase_class->delProperty = JS_DeletePropertyStub; + JSB_cpBase_class->getProperty = JS_PropertyStub; + JSB_cpBase_class->setProperty = JS_StrictPropertyStub; + JSB_cpBase_class->enumerate = JS_EnumerateStub; + JSB_cpBase_class->resolve = JS_ResolveStub; + JSB_cpBase_class->convert = JS_ConvertStub; + JSB_cpBase_class->finalize = JSB_cpBase_finalize; + JSB_cpBase_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + {0, 0, 0, 0, 0} + }; + static JSFunctionSpec funcs[] = { + JS_FN("getHandle", JSB_cpBase_getHandle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setHandle", JSB_cpBase_setHandle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpBase_object = JS_InitClass(cx, globalObj, NULL, JSB_cpBase_class, JSB_cpBase_constructor,0,properties,funcs,NULL,st_funcs); + JSBool found; + JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +// Manual "methods" +// Constructor +JSBool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==3, cx, JS_FALSE, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpPolyShape_class, JSB_cpPolyShape_object, NULL); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + cpBody* body; cpVect *verts; cpVect offset; + int numVerts; + + ok &= jsval_to_c_class( cx, *argvp++, (void**)&body, NULL ); + ok &= jsval_to_array_of_cpvect( cx, *argvp++, &verts, &numVerts); + ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &offset ); + JSB_PRECONDITION(ok, "Error processing arguments"); + cpShape *shape = cpPolyShapeNew(body, numVerts, verts, offset); + + jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_DO_NOT_CALL_FREE); + jsb_set_jsobject_for_proxy(jsobj, shape); + + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); + + free(verts); + + return JS_TRUE; +} + + +#pragma mark Space Free functions +// +// When the space is removed, it should all remove its children. But not "free" them. +// "free" will be performed by the JS Garbage Collector +// +// Functions copied & pasted from ChipmunkDemo.c +// https://github.com/slembcke/Chipmunk-Physics/blob/master/Demo/ChipmunkDemo.c#L89 +// + +static void unroot_jsobject_from_handle(void *handle) +{ + JSObject *jsobj = jsb_get_jsobject_for_proxy(handle); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsobj); + + // HACK context from global + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_RemoveObjectRoot(cx, &proxy->jsobj); + +} +static void shapeFreeWrap(cpSpace *space, cpShape *shape, void *unused){ + cpSpaceRemoveShape(space, shape); + unroot_jsobject_from_handle(shape); +// cpShapeFree(shape); +} + +static void postShapeFree(cpShape *shape, cpSpace *space){ + cpSpaceAddPostStepCallback(space, (cpPostStepFunc)shapeFreeWrap, shape, NULL); +} + +static void constraintFreeWrap(cpSpace *space, cpConstraint *constraint, void *unused){ + cpSpaceRemoveConstraint(space, constraint); + unroot_jsobject_from_handle(constraint); +// cpConstraintFree(constraint); +} + +static void postConstraintFree(cpConstraint *constraint, cpSpace *space){ + cpSpaceAddPostStepCallback(space, (cpPostStepFunc)constraintFreeWrap, constraint, NULL); +} + +static void bodyFreeWrap(cpSpace *space, cpBody *body, void *unused){ + cpSpaceRemoveBody(space, body); + unroot_jsobject_from_handle(body); +// cpBodyFree(body); +} + +static void postBodyFree(cpBody *body, cpSpace *space){ + cpSpaceAddPostStepCallback(space, (cpPostStepFunc)bodyFreeWrap, body, NULL); +} + +// Safe and future proof way to remove and free all objects that have been added to the space. +void static freeSpaceChildren(cpSpace *space) +{ + // Must remove these BEFORE freeing the body or you will access dangling pointers. + cpSpaceEachShape(space, (cpSpaceShapeIteratorFunc)postShapeFree, space); + cpSpaceEachConstraint(space, (cpSpaceConstraintIteratorFunc)postConstraintFree, space); + + cpSpaceEachBody(space, (cpSpaceBodyIteratorFunc)postBodyFree, space); +} + +#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.h b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.h new file mode 100644 index 0000000000..c6b40ca757 --- /dev/null +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.h @@ -0,0 +1,103 @@ +/* + * JS Bindings: https://github.com/zynga/jsbindings + * + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#ifndef __js_bindings_chipmunk_manual +#define __js_bindings_chipmunk_manual + +#include "js_bindings_config.h" +#include "cocosjs_manual_conversions.h" +#include "js_manual_conversions.h" +#include "ScriptingCore.h" +#ifdef JSB_INCLUDE_CHIPMUNK + +#include "chipmunk.h" +#include "jsapi.h" + +#include "js_bindings_chipmunk_auto_classes.h" + +// Free Functions +JSBool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpaceRemoveCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); + +JSBool JSB_cpArbiterGetBodies(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiterGetShapes(JSContext *cx, uint32_t argc, jsval *vp); + +JSBool JSB_cpBodyGetUserData(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBodySetUserData(JSContext *cx, uint32_t argc, jsval *vp); + +// poly related +JSBool JSB_cpAreaForPoly(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpMomentForPoly(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpCentroidForPoly(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpRecenterPoly(JSContext *cx, uint32_t argc, jsval *vp); + +// "Methods" from the OO API +JSBool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpace_removeCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); + +// manually wrapped for rooting/unrooting purposes +JSBool JSB_cpSpace_addBody(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpace_addConstraint(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpace_addShape(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpace_addStaticShape(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpace_removeBody(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpace_removeConstraint(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpace_removeShape(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpSpace_removeStaticShape(JSContext *cx, uint32_t argc, jsval *vp); + + +JSBool JSB_cpArbiter_getBodies(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpArbiter_getShapes(JSContext *cx, uint32_t argc, jsval *vp); + +JSBool JSB_cpBody_constructor(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBody_getUserData(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_cpBody_setUserData(JSContext *cx, uint32_t argc, jsval *vp); + + +// convertions + +jsval cpBB_to_jsval(JSContext *cx, cpBB bb ); +JSBool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ); +JSBool jsval_to_array_of_cpvect( JSContext *cx, jsval vp, cpVect**verts, int *numVerts); + +// requires cocos2d +#define cpVect_to_jsval CGPoint_to_jsval +#define jsval_to_cpVect jsval_to_CGPoint + + +// Object Oriented Chipmunk +void JSB_cpBase_createClass(JSContext* cx, JSObject* globalObj, const char * name ); +extern JSObject* JSB_cpBase_object; +extern JSClass* JSB_cpBase_class; +extern void register_CCPhysicsSprite(JSContext *cx, JSObject *obj); +extern void register_CCPhysicsDebugNode(JSContext *cx, JSObject *obj); + +// Manual constructor / destructors +JSBool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *obj); + +#endif // JSB_INCLUDE_CHIPMUNK + +#endif // __js_bindings_chipmunk_manual diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_registration.cpp b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_registration.cpp new file mode 100644 index 0000000000..a96434eace --- /dev/null +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_registration.cpp @@ -0,0 +1,67 @@ +/* + * JS Bindings: https://github.com/zynga/jsbindings + * + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef JSB_INCLUDE_CHIPMUNK +#define JSB_INCLUDE_CHIPMUNK +#endif + +#include "js_bindings_config.h" +#include "ScriptingCore.h" + + +// chipmunk +#include "js_bindings_chipmunk_auto_classes.h" +#include "js_bindings_chipmunk_functions.h" +#include "js_bindings_chipmunk_manual.h" + + +void jsb_register_chipmunk(JSContext *_cx, JSObject *object) +{ + // + // Chipmunk + // + JSObject *chipmunk = JS_NewObject(_cx, NULL, NULL, NULL); + jsval chipmunkVal = OBJECT_TO_JSVAL(chipmunk); + JS_SetProperty(_cx, object, "cp", &chipmunkVal); + + JSB_cpBase_createClass(_cx, chipmunk, "Base"); // manual base class registration +#include "js_bindings_chipmunk_auto_classes_registration.h" +#include "js_bindings_chipmunk_functions_registration.h" + + // manual + JS_DefineFunction(_cx, chipmunk, "spaceAddCollisionHandler", JSB_cpSpaceAddCollisionHandler, 8, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, chipmunk, "spaceRemoveCollisionHandler", JSB_cpSpaceRemoveCollisionHandler, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, chipmunk, "arbiterGetBodies", JSB_cpArbiterGetBodies, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, chipmunk, "arbiterGetShapes", JSB_cpArbiterGetShapes, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, chipmunk, "bodyGetUserData", JSB_cpBodyGetUserData, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, chipmunk, "bodySetUserData", JSB_cpBodySetUserData, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + + JS_DefineFunction(_cx, chipmunk, "areaForPoly", JSB_cpAreaForPoly, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, chipmunk, "momentForPoly", JSB_cpMomentForPoly, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, chipmunk, "centroidForPoly", JSB_cpCentroidForPoly, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, chipmunk, "recenterPoly", JSB_cpRecenterPoly, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + register_CCPhysicsSprite(_cx, object); + register_CCPhysicsDebugNode(_cx, object); +} + diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_registration.h b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_registration.h new file mode 100644 index 0000000000..90bc320b87 --- /dev/null +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_registration.h @@ -0,0 +1,31 @@ +/* + * JS Bindings: https://github.com/zynga/jsbindings + * + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#ifndef __JSB_CHIPMUNK_REGISTRATION +#define __JSB_CHIPMUNK_REGISTRATION + +void jsb_register_chipmunk( JSContext *globalC, JSObject *globalO); + +#endif // __JSB_CHIPMUNK_REGISTRATION diff --git a/cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj b/cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj new file mode 100644 index 0000000000..9148f9376f --- /dev/null +++ b/cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj @@ -0,0 +1,121 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + + + {21070E58-EEC6-4E16-8B4F-6D083DF55790} + Win32Proj + libJSBindingForChipmunk + + + + StaticLibrary + true + Unicode + v100 + v110 + v110_xp + + + StaticLibrary + false + Unicode + v100 + v110 + v110_xp + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + + + + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + false + + + Windows + true + + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + + + Windows + true + true + true + + + + + + + + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj.filters b/cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj.filters new file mode 100644 index 0000000000..43253970bc --- /dev/null +++ b/cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj.filters @@ -0,0 +1,47 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + + + manual + + + manual + + + manual + + + manual + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj.user b/cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj.user new file mode 100644 index 0000000000..3f03091124 --- /dev/null +++ b/cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj.user @@ -0,0 +1,6 @@ + + + + false + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/cocosbuilder/cocosbuilder_specifics.hpp b/cocos/scripting/javascript/bindings/cocosbuilder/cocosbuilder_specifics.hpp new file mode 100644 index 0000000000..f6b3252c57 --- /dev/null +++ b/cocos/scripting/javascript/bindings/cocosbuilder/cocosbuilder_specifics.hpp @@ -0,0 +1,23 @@ +#ifndef __JS_COCOSBUILDER_SPECIFICS_H__ +#define __JS_COCOSBUILDER_SPECIFICS_H__ + +#include "../cocos2d_specifics.hpp" + +class JSCCBAnimationWrapper: public JSCallbackWrapper { +public: + JSCCBAnimationWrapper() {} + virtual ~JSCCBAnimationWrapper() {} + + void animationCompleteCallback() { + + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + jsval retval = JSVAL_NULL; + + if(!JSVAL_IS_VOID(_jsCallback) && !JSVAL_IS_VOID(_jsThisObj)) { + JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(_jsThisObj), _jsCallback, 0, NULL, &retval); + } + } + +}; + +#endif diff --git a/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.cpp b/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.cpp new file mode 100644 index 0000000000..733ac47b45 --- /dev/null +++ b/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.cpp @@ -0,0 +1,324 @@ +// +// js_bindings_ccbreader.cpp +// watermelon +// +// Created by Rohan Kuruvilla on 14/08/2012. +// +// + +#include "js_bindings_ccbreader.h" +#include "ScriptingCore.h" +#include "js_bindings_config.h" + +USING_NS_CC; +USING_NS_CC_EXT; +using namespace cocosbuilder; + +static void removeSelector(std::string &str) { + size_t found; + found = str.find(":"); + while (found!=std::string::npos){ + str.replace(found, found+1, ""); + found = str.find(":"); + } +} + +SEL_MenuHandler CCBScriptCallbackProxy::onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, + const char * pSelectorName) { + this->callBackProp = pSelectorName; + removeSelector(this->callBackProp); + return menu_selector(CCBScriptCallbackProxy::menuItemCallback); +} + +Control::Handler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(Object * pTarget, + const char * pSelectorName) { + + this->callBackProp = pSelectorName; + removeSelector(this->callBackProp); + return cccontrol_selector(CCBScriptCallbackProxy::controlCallback); +} + +bool CCBScriptCallbackProxy::onAssignCCBMemberVariable(Object * pTarget, + const char * pMemberVariableName, + Node * pNode) { + return true; +} + +void CCBScriptCallbackProxy::onNodeLoaded(Node * pNode, + NodeLoader * pNodeLoader) {} + +CCBSelectorResolver * CCBScriptCallbackProxy::createNew() { + CCBScriptCallbackProxy * ret = new CCBScriptCallbackProxy(); + ret->setJSOwner(this->owner); + return dynamic_cast(ret); +} + +void CCBScriptCallbackProxy::menuItemCallback(Object *pSender) { + ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() ); +} + +void CCBScriptCallbackProxy::controlCallback(Object *pSender, Control::EventType event) { + ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() ); +} + +void CCBScriptCallbackProxy::setCallbackProperty(const char *prop) { + callBackProp = prop; +} + +void CCBScriptCallbackProxy::setJSOwner(jsval ownr) { + owner = ownr; +} + +jsval CCBScriptCallbackProxy::getJSOwner() { + return owner; +} + +JSBool js_cocos2dx_CCBAnimationManager_animationCompleteCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 1) { + jsval *argv = JS_ARGV(cx, vp); + + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager *node = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + + JSCCBAnimationWrapper *tmpCobj = new JSCCBAnimationWrapper(); + tmpCobj->autorelease(); + + tmpCobj->setJSCallbackThis(argv[0]); + if(argc >= 2) { + tmpCobj->setJSCallbackFunc(argv[1]); + } + + node->setAnimationCompletedCallback(tmpCobj, callfunc_selector(JSCCBAnimationWrapper::animationCompleteCallback)); + + JS_SetReservedSlot(proxy->obj, 0, argv[0]); + JS_SetReservedSlot(proxy->obj, 1, argv[1]); + return JS_TRUE; + } + return JS_FALSE; +} + +JSBool js_cocos2dx_CCBReader_readNodeGraphFromFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSBool ok = JS_TRUE; + JSObject *obj; + cocosbuilder::CCBReader* cobj; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + cocos2d::Object* arg1; + do { + js_proxy_t *proxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); + proxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg1) + } while (0); + + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + cocos2d::Node* ret = cobj->readNodeGraphFromFile(arg0, arg1); + jsval jsret; do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + cocos2d::Node* ret = cobj->readNodeGraphFromFile(arg0); + jsval jsret; do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + if (argc == 3) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + cocos2d::Object* arg1; + do { + js_proxy_t *proxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); + proxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg1) + } while (0); + cocos2d::Size arg2; + ok &= jsval_to_ccsize(cx, argv[2], &arg2); + + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + cocos2d::Node* ret = cobj->readNodeGraphFromFile(arg0, arg1, arg2); + jsval jsret; do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + return JS_FALSE; +} + +JSBool js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSBool ok = JS_TRUE; + JSObject *obj; + cocosbuilder::CCBReader* cobj; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + cocos2d::Object* arg1; + do { + js_proxy_t *proxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); + proxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg1) + } while (0); + + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + cocos2d::Scene* ret = cobj->createSceneWithNodeGraphFromFile(arg0, arg1); + jsval jsret; do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + cocos2d::Scene* ret = cobj->createSceneWithNodeGraphFromFile(arg0); + jsval jsret; do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + if (argc == 3) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + cocos2d::Object* arg1; + do { + js_proxy_t *proxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); + proxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg1) + } while (0); + cocos2d::Size arg2; + ok &= jsval_to_ccsize(cx, argv[2], &arg2); + + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + cocos2d::Scene* ret = cobj->createSceneWithNodeGraphFromFile(arg0, arg1, arg2); + jsval jsret; do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + + return JS_FALSE; +} + + +JSBool js_CocosBuilder_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + + NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::getInstance(); + + ccNodeLoaderLibrary->registerNodeLoader("", JSLayerLoader::loader()); + + CCBReader * ret = new CCBReader(ccNodeLoaderLibrary); + ret->autorelease(); + + jsval jsret; + if (ret) { + js_proxy_t *proxy = jsb_get_native_proxy(ret); + if (proxy) { + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + // create a new js obj of that class + proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + +} + +extern JSObject* jsb_CCBReader_prototype; +extern JSObject* jsb_CCBAnimationManager_prototype; + +void register_CCBuilderReader(JSContext *cx, JSObject *obj) { + jsval nsval; + JSObject *ns; + JS_GetProperty(cx, obj, "cc", &nsval); + if (nsval == JSVAL_VOID) { + ns = JS_NewObject(cx, NULL, NULL, NULL); + nsval = OBJECT_TO_JSVAL(ns); + JS_SetProperty(cx, obj, "cc", &nsval); + } else { + JS_ValueToObject(cx, nsval, &ns); + } + obj = ns; + + JSObject *tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, obj, "(function () { return cc._Reader; })()")); + JS_DefineFunction(cx, tmpObj, "create", js_CocosBuilder_create, 2, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "loadScene", js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, jsb_CCBReader_prototype, "load", js_cocos2dx_CCBReader_readNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, jsb_CCBAnimationManager_prototype, "setCompletedAnimationCallback", js_cocos2dx_CCBAnimationManager_animationCompleteCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT); +} diff --git a/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.h b/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.h new file mode 100644 index 0000000000..b1b3b187cc --- /dev/null +++ b/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.h @@ -0,0 +1,60 @@ +// +// js_bindings_ccbreader.h +// watermelon +// +// Created by Rohan Kuruvilla on 14/08/2012. +// +// +#ifndef __JS_BINDINGS_CCBREADER_H__ +#define __JS_BINDINGS_CCBREADER_H__ + +#include "jsapi.h" +#include "cocosbuilder_specifics.hpp" +#include "cocosbuilder/CocosBuilder.h" + +class CCBScriptCallbackProxy: public cocos2d::Layer +, public cocosbuilder::CCBSelectorResolver +, public cocosbuilder::CCBMemberVariableAssigner { + + std::string callBackProp; + jsval owner; + +public: + + + CCBScriptCallbackProxy () {} + virtual ~CCBScriptCallbackProxy() {} + + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(CCBScriptCallbackProxy, create); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, + const char * pSelectorName); + + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, + const char * pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, + cocos2d::Node * pNode); + virtual void onNodeLoaded(cocos2d::Node * pNode, + cocosbuilder::NodeLoader * pNodeLoader); + + virtual CCBSelectorResolver * createNew(); + void menuItemCallback(Object *pSender); + void controlCallback(Object *pSender, cocos2d::extension::Control::EventType event); + void setCallbackProperty(const char *prop); + void setJSOwner(jsval ownr); + jsval getJSOwner(); +}; + + +class JSLayerLoader : public cocosbuilder::LayerLoader { +public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(JSLayerLoader, loader); + +protected: + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCBScriptCallbackProxy); +}; + +void register_CCBuilderReader(JSContext *cx, JSObject *global); +JSBool js_CocosBuilder_Run(JSContext *cx, uint32_t argc, jsval *vp); + +#endif /* __JS_BINDINGS_CCBREADER_H__ */ + diff --git a/cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj b/cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj new file mode 100644 index 0000000000..d6f2eb8d12 --- /dev/null +++ b/cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj @@ -0,0 +1,119 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + {F9DA0FC1-651B-457B-962E-A4D61CEBF5FD} + Win32Proj + libJSBindingForBuilder + + + + StaticLibrary + true + Unicode + v100 + v110 + v110_xp + + + StaticLibrary + false + Unicode + v100 + v110 + v110_xp + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + + + + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + false + + + Windows + true + + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + + + Windows + true + true + true + + + + + + + + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj.filters b/cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj.filters new file mode 100644 index 0000000000..6746ab6be9 --- /dev/null +++ b/cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj.filters @@ -0,0 +1,37 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + generated + + + manual + + + + + generated + + + manual + + + manual + + + + + generated + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj.user b/cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj.user new file mode 100644 index 0000000000..3f03091124 --- /dev/null +++ b/cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj.user @@ -0,0 +1,6 @@ + + + + false + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.cpp b/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.cpp new file mode 100644 index 0000000000..34ecbca985 --- /dev/null +++ b/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.cpp @@ -0,0 +1,229 @@ +// +// jsb_cocos2dx_studio_manual.h +// +// Created by LinWenhai on 20/10/13. +// +// +#include "jsb_cocos2dx_studio_manual.h" +#include "ScriptingCore.h" +#include "cocos2d_specifics.hpp" +#include "cocostudio/CocoStudio.h" + +class JSArmatureWrapper: public JSCallbackWrapper { +public: + JSArmatureWrapper(); + virtual ~JSArmatureWrapper(); + + virtual void setJSCallbackThis(jsval thisObj); + + void movementCallbackFunc(cocostudio::Armature * pArmature, cocostudio::MovementEventType pMovementEventType, const char *pMovementId); + void frameCallbackFunc(cocostudio::Bone *pBone, const char *frameEventName, int originFrameIndex, int currentFrameIndex); + void addArmatureFileInfoAsyncCallbackFunc(float percent); + +private: + bool m_bNeedUnroot; +}; + +JSArmatureWrapper::JSArmatureWrapper() + : m_bNeedUnroot(false) +{ + +} + +JSArmatureWrapper::~JSArmatureWrapper() +{ + if (m_bNeedUnroot) + { + JSObject *thisObj = JSVAL_TO_OBJECT(_jsThisObj); + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_RemoveObjectRoot(cx, &thisObj); + } +} + +void JSArmatureWrapper::setJSCallbackThis(jsval _jsThisObj) +{ + JSCallbackWrapper::setJSCallbackThis(_jsThisObj); + + JSObject *thisObj = JSVAL_TO_OBJECT(_jsThisObj); + js_proxy *p = jsb_get_js_proxy(thisObj); + if (!p) + { + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_AddObjectRoot(cx, &thisObj); + m_bNeedUnroot = true; + } +} + +void JSArmatureWrapper::movementCallbackFunc(cocostudio::Armature *pArmature, cocostudio::MovementEventType pMovementEventType, const char *pMovementId) +{ + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); + js_proxy_t *proxy = js_get_or_create_proxy(cx, pArmature); + jsval retval; + if (_jsCallback != JSVAL_VOID) + { + int movementEventType = (int)pMovementEventType; + jsval movementVal = INT_TO_JSVAL(movementEventType); + + jsval idVal = c_string_to_jsval(cx, pMovementId); + + jsval valArr[3]; + valArr[0] = OBJECT_TO_JSVAL(proxy->obj); + valArr[1] = movementVal; + valArr[2] = idVal; + + JS_AddValueRoot(cx, valArr); + JS_CallFunctionValue(cx, thisObj, _jsCallback, 3, valArr, &retval); + JS_RemoveValueRoot(cx, valArr); + } +} + +void JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc(float percent) +{ + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); + jsval retval; + if (_jsCallback != JSVAL_VOID) + { + jsval percentVal = DOUBLE_TO_JSVAL(percent); + + JS_AddValueRoot(cx, &percentVal); + JS_CallFunctionValue(cx, thisObj, _jsCallback, 1, &percentVal, &retval); + JS_RemoveValueRoot(cx, &percentVal); + } +} + + +void JSArmatureWrapper::frameCallbackFunc(cocostudio::Bone *pBone, const char *frameEventName, int originFrameIndex, int currentFrameIndex) +{ + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); + js_proxy_t *proxy = js_get_or_create_proxy(cx, pBone); + jsval retval; + if (_jsCallback != JSVAL_VOID) + { + jsval nameVal = c_string_to_jsval(cx, frameEventName); + jsval originIndexVal = INT_TO_JSVAL(originFrameIndex); + jsval currentIndexVal = INT_TO_JSVAL(currentFrameIndex); + + jsval valArr[4]; + valArr[0] = OBJECT_TO_JSVAL(proxy->obj); + valArr[1] = nameVal; + valArr[2] = originIndexVal; + valArr[3] = currentIndexVal; + + JS_AddValueRoot(cx, valArr); + JS_CallFunctionValue(cx, thisObj, _jsCallback, 4, valArr, &retval); + JS_RemoveValueRoot(cx, valArr); + } +} + +static JSBool js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 2) { + jsval *argv = JS_ARGV(cx, vp); + + JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); + tmpObj->autorelease(); + + tmpObj->setJSCallbackFunc(argv[0]); + tmpObj->setJSCallbackThis(argv[1]); + + cobj->setMovementEventCallFunc(tmpObj, movementEvent_selector(JSArmatureWrapper::movementCallbackFunc)); + + return JS_TRUE; + } + JS_ReportError(cx, "Invalid number of arguments"); + return JS_FALSE; +} + +static JSBool js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 2) { + jsval *argv = JS_ARGV(cx, vp); + + JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); + tmpObj->autorelease(); + + tmpObj->setJSCallbackFunc(argv[0]); + tmpObj->setJSCallbackThis(argv[1]); + + cobj->setFrameEventCallFunc(tmpObj, frameEvent_selector(JSArmatureWrapper::frameCallbackFunc)); + + return JS_TRUE; + } + JS_ReportError(cx, "Invalid number of arguments"); + return JS_FALSE; +} + +static JSBool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 3) { + jsval *argv = JS_ARGV(cx, vp); + + JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); + tmpObj->autorelease(); + + tmpObj->setJSCallbackFunc(argv[2]); + tmpObj->setJSCallbackThis(argv[1]); + + std::string ret; + jsval_to_std_string(cx, argv[0], &ret); + + cobj->addArmatureFileInfoAsync(ret.c_str(), tmpObj, schedule_selector(JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc)); + + return JS_TRUE; + } + + if(argc == 5){ + jsval *argv = JS_ARGV(cx, vp); + + JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); + tmpObj->autorelease(); + + tmpObj->setJSCallbackFunc(argv[4]); + tmpObj->setJSCallbackThis(argv[3]); + + std::string imagePath; + jsval_to_std_string(cx ,argv[0] , &imagePath); + + std::string plistPath; + jsval_to_std_string(cx ,argv[1] , &plistPath); + + std::string configFilePath; + jsval_to_std_string(cx ,argv[2] , &configFilePath); + + cobj->addArmatureFileInfoAsync(imagePath.c_str(), plistPath.c_str(), configFilePath.c_str(), tmpObj, schedule_selector(JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc)); + + return JS_TRUE; + } + JS_ReportError(cx, "Invalid number of arguments"); + return JS_FALSE; +} + +extern JSObject* jsb_ArmatureAnimation_prototype; +extern JSObject* jsb_ArmatureDataManager_prototype; + +void register_all_cocos2dx_studio_manual(JSContext* cx, JSObject* global) +{ + JS_DefineFunction(cx, jsb_ArmatureAnimation_prototype, "setMovementEventCallFunc", js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, jsb_ArmatureAnimation_prototype, "setFrameEventCallFunc", js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, jsb_ArmatureDataManager_prototype, "addArmatureFileInfoAsync", jsb_Animation_addArmatureFileInfoAsyncCallFunc, 3, JSPROP_READONLY | JSPROP_PERMANENT); +} \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.h b/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.h new file mode 100644 index 0000000000..35ebd55755 --- /dev/null +++ b/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.h @@ -0,0 +1,16 @@ +// +// jsb_cocos2dx_studio_manual.h +// +// Created by LinWenhai on 20/10/13. +// +// + +#ifndef __jsb_cocos2dx_studio_manual__ +#define __jsb_cocos2dx_studio_manual__ + +#include "jsapi.h" +#include "jsfriendapi.h" + +void register_all_cocos2dx_studio_manual(JSContext* cx, JSObject* global); + +#endif /* defined(__jsb_cocos2dx_studio_manual__) */ diff --git a/cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj b/cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj new file mode 100644 index 0000000000..2212730521 --- /dev/null +++ b/cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj @@ -0,0 +1,118 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + {79D34511-E54E-410A-8BBA-EF175AD6C695} + Win32Proj + libJSBindingForStudio + + + + StaticLibrary + true + Unicode + v100 + v110 + v110_xp + + + StaticLibrary + false + Unicode + v100 + v110 + v110_xp + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + + + + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + false + + + Windows + true + + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + + + Windows + true + true + true + + + + + + + + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj.filters b/cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj.filters new file mode 100644 index 0000000000..16be2bb316 --- /dev/null +++ b/cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj.filters @@ -0,0 +1,34 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + generated + + + manual + + + + + generated + + + manual + + + + + generated + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj.user b/cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj.user new file mode 100644 index 0000000000..3f03091124 --- /dev/null +++ b/cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj.user @@ -0,0 +1,6 @@ + + + + false + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp b/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp new file mode 100644 index 0000000000..9f2ab82470 --- /dev/null +++ b/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp @@ -0,0 +1,799 @@ +// +// jsb_cocos2d_extension_manual.cpp +// +// Created by James Chen on 3/11/13. +// +// + +#include "jsb_cocos2dx_extension_manual.h" +#include "extensions/cocos-ext.h" +#include "ScriptingCore.h" +#include "cocos2d_specifics.hpp" + +USING_NS_CC; +USING_NS_CC_EXT; + + +class JSB_ScrollViewDelegate +: public Object +, public ScrollViewDelegate +{ +public: + JSB_ScrollViewDelegate() + : _JSDelegate(NULL) + , _needUnroot(false) + {} + + virtual ~JSB_ScrollViewDelegate() + { + if (_needUnroot) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_RemoveObjectRoot(cx, &_JSDelegate); + } + } + + virtual void scrollViewDidScroll(ScrollView* view) + { + js_proxy_t * p = jsb_get_native_proxy(view); + if (!p) return; + + jsval arg = OBJECT_TO_JSVAL(p->obj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "scrollViewDidScroll", 1, &arg, NULL); + } + + virtual void scrollViewDidZoom(ScrollView* view) + { + js_proxy_t * p = jsb_get_native_proxy(view); + if (!p) return; + + jsval arg = OBJECT_TO_JSVAL(p->obj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "scrollViewDidZoom", 1, &arg, NULL); + } + + void setJSDelegate(JSObject* pJSDelegate) + { + _JSDelegate = pJSDelegate; + + // Check whether the js delegate is a pure js object. + js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); + if (!p) + { + _needUnroot = true; + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); + } + } +private: + JSObject* _JSDelegate; + bool _needUnroot; +}; + +static JSBool js_cocos2dx_CCScrollView_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 1) + { + // save the delegate + JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); + JSB_ScrollViewDelegate* nativeDelegate = new JSB_ScrollViewDelegate(); + nativeDelegate->setJSDelegate(jsDelegate); + + cobj->setUserObject(nativeDelegate); + cobj->setDelegate(nativeDelegate); + + nativeDelegate->release(); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + + +#define KEY_TABLEVIEW_DATA_SOURCE "TableViewDataSource" +#define KEY_TABLEVIEW_DELEGATE "TableViewDelegate" + +class JSB_TableViewDelegate +: public Object +, public TableViewDelegate +{ +public: + JSB_TableViewDelegate() + : _JSDelegate(NULL) + , _needUnroot(false) + {} + + virtual ~JSB_TableViewDelegate() + { + if (_needUnroot) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_RemoveObjectRoot(cx, &_JSDelegate); + } + } + + virtual void scrollViewDidScroll(ScrollView* view) + { + callJSDelegate(view, "scrollViewDidScroll"); + } + + virtual void scrollViewDidZoom(ScrollView* view) + { + callJSDelegate(view, "scrollViewDidZoom"); + } + + virtual void tableCellTouched(TableView* table, TableViewCell* cell) + { + callJSDelegate(table, cell, "tableCellTouched"); + } + + virtual void tableCellHighlight(TableView* table, TableViewCell* cell) + { + callJSDelegate(table, cell, "tableCellHighlight"); + } + + virtual void tableCellUnhighlight(TableView* table, TableViewCell* cell) + { + callJSDelegate(table, cell, "tableCellUnhighlight"); + } + + virtual void tableCellWillRecycle(TableView* table, TableViewCell* cell) + { + callJSDelegate(table, cell, "tableCellWillRecycle"); + } + + void setJSDelegate(JSObject* pJSDelegate) + { + _JSDelegate = pJSDelegate; + + // Check whether the js delegate is a pure js object. + js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); + if (!p) + { + _needUnroot = true; + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); + } + } + + +private: + void callJSDelegate(ScrollView* view, std::string jsFunctionName) + { + js_proxy_t * p = jsb_get_native_proxy(view); + if (!p) return; + + jsval arg = OBJECT_TO_JSVAL(p->obj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), jsFunctionName.c_str(), 1, &arg, NULL); + } + + void callJSDelegate(TableView* table, TableViewCell* cell, std::string jsFunctionName) + { + js_proxy_t * p = jsb_get_native_proxy(table); + if (!p) return; + + js_proxy_t * pCellProxy = jsb_get_native_proxy(cell); + if (!pCellProxy) return; + + jsval args[2]; + args[0] = OBJECT_TO_JSVAL(p->obj); + args[1] = OBJECT_TO_JSVAL(pCellProxy->obj); + + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), jsFunctionName.c_str(), 2, args, NULL); + } + + JSObject* _JSDelegate; + bool _needUnroot; +}; + +static JSBool js_cocos2dx_CCTableView_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 1) + { + // save the delegate + JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); + JSB_TableViewDelegate* nativeDelegate = new JSB_TableViewDelegate(); + nativeDelegate->setJSDelegate(jsDelegate); + + Dictionary* userDict = static_cast(cobj->getUserObject()); + if (NULL == userDict) + { + userDict = new Dictionary(); + cobj->setUserObject(userDict); + userDict->release(); + } + + userDict->setObject(nativeDelegate, KEY_TABLEVIEW_DELEGATE); + + cobj->setDelegate(nativeDelegate); + + nativeDelegate->release(); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + +class JSB_TableViewDataSource +: public Object +, public TableViewDataSource +{ +public: + JSB_TableViewDataSource() + : _JSTableViewDataSource(NULL) + , _needUnroot(false) + {} + + virtual ~JSB_TableViewDataSource() + { + if (_needUnroot) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_RemoveObjectRoot(cx, &_JSTableViewDataSource); + } + } + + virtual Size tableCellSizeForIndex(TableView *table, unsigned int idx) + { + jsval ret; + bool ok = callJSDelegate(table, idx, "tableCellSizeForIndex", ret); + if (!ok) + { + ok = callJSDelegate(table, "cellSizeForTable", ret); + } + if (ok) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + Size size; + JSBool isSucceed = jsval_to_ccsize(cx, ret, &size); + if (isSucceed) return size; + } + return Size::ZERO; + + } + + virtual TableViewCell* tableCellAtIndex(TableView *table, unsigned int idx) + { + jsval ret; + bool ok = callJSDelegate(table, idx, "tableCellAtIndex", ret); + if (ok) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + cocos2d::extension::TableViewCell* arg0; + do { + js_proxy_t *proxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(ret); + proxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::extension::TableViewCell*)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, NULL, "Invalid Native Object"); + } while (0); + return arg0; + } + return NULL; + } + + virtual unsigned int numberOfCellsInTableView(TableView *table) + { + jsval ret; + bool ok = callJSDelegate(table, "numberOfCellsInTableView", ret); + if (ok) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + uint32_t count = 0; + JSBool isSucceed = jsval_to_uint32(cx, ret, &count); + if (isSucceed) return count; + } + return 0; + } + + + void setTableViewDataSource(JSObject* pJSSource) + { + _JSTableViewDataSource = pJSSource; + + // Check whether the js delegate is a pure js object. + js_proxy_t* p = jsb_get_js_proxy(_JSTableViewDataSource); + if (!p) + { + _needUnroot = true; + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_AddNamedObjectRoot(cx, &_JSTableViewDataSource, "TableViewDataSource"); + } + } + +private: + bool callJSDelegate(TableView* table, std::string jsFunctionName, jsval& retVal) + { + js_proxy_t * p = jsb_get_native_proxy(table); + if (!p) return false; + + JSBool hasAction; + jsval temp_retval; + jsval dataVal = OBJECT_TO_JSVAL(p->obj); + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JSObject* obj = _JSTableViewDataSource; + + if (JS_HasProperty(cx, obj, jsFunctionName.c_str(), &hasAction) && hasAction) + { + if(!JS_GetProperty(cx, obj, jsFunctionName.c_str(), &temp_retval)) + { + return false; + } + if(temp_retval == JSVAL_VOID) + { + return false; + } + + JSAutoCompartment ac(cx, obj); + JS_CallFunctionName(cx, obj, jsFunctionName.c_str(), + 1, &dataVal, &retVal); + return true; + } + return false; + } + + bool callJSDelegate(TableView* table, int idx, std::string jsFunctionName, jsval& retVal) + { + js_proxy_t * p = jsb_get_native_proxy(table); + if (!p) return false; + + + JSBool hasAction; + jsval temp_retval; + jsval dataVal[2]; + dataVal[0] = OBJECT_TO_JSVAL(p->obj); + dataVal[1] = INT_TO_JSVAL(idx); + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JSObject* obj = _JSTableViewDataSource; + + if (JS_HasProperty(cx, obj, jsFunctionName.c_str(), &hasAction) && hasAction) + { + if(!JS_GetProperty(cx, obj, jsFunctionName.c_str(), &temp_retval)) + { + return false; + } + + if(temp_retval == JSVAL_VOID) + { + return false; + } + + JSAutoCompartment ac(cx, obj); + JS_CallFunctionName(cx, obj, jsFunctionName.c_str(), + 2, dataVal, &retVal); + return true; + } + return false; + } + +private: + JSObject* _JSTableViewDataSource; + bool _needUnroot; +}; + +static JSBool js_cocos2dx_CCTableView_setDataSource(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + if (argc == 1) + { + JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); + pNativeSource->setTableViewDataSource(JSVAL_TO_OBJECT(argv[0])); + + Dictionary* userDict = static_cast(cobj->getUserObject()); + if (NULL == userDict) + { + userDict = new Dictionary(); + cobj->setUserObject(userDict); + userDict->release(); + } + + userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); + + cobj->setDataSource(pNativeSource); + + pNativeSource->release(); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments"); + return JS_FALSE; +} + +static JSBool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSBool ok = JS_TRUE; + if (argc == 3 || argc == 2) + { + + JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); + pNativeSource->setTableViewDataSource(JSVAL_TO_OBJECT(argv[0])); + + cocos2d::Size arg1; + ok &= jsval_to_ccsize(cx, argv[1], &arg1); + cocos2d::extension::TableView* ret = NULL; + ret = new TableView(); + ret->autorelease(); + + ret->setDataSource(pNativeSource); + + jsval jsret; + do { + if (ret) + { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + else + { + jsret = JSVAL_NULL; + } + } while (0); + + if (argc == 2) + { + ret->initWithViewSize(arg1); + } + else + { + cocos2d::Node* arg2; + do + { + js_proxy_t *proxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); + proxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + ret->initWithViewSize(arg1, arg2); + } + ret->reloadData(); + + Dictionary* userDict = new Dictionary(); + userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); + ret->setUserObject(userDict); + userDict->release(); + + pNativeSource->release(); + + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments"); + return JS_FALSE; +} + +class JSB_EditBoxDelegate +: public Object +, public EditBoxDelegate +{ +public: + JSB_EditBoxDelegate() + : _JSDelegate(NULL) + , _needUnroot(false) + {} + + virtual ~JSB_EditBoxDelegate() + { + if (_needUnroot) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_RemoveObjectRoot(cx, &_JSDelegate); + } + } + + virtual void editBoxEditingDidBegin(EditBox* editBox) + { + js_proxy_t * p = jsb_get_native_proxy(editBox); + if (!p) return; + + jsval arg = OBJECT_TO_JSVAL(p->obj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxEditingDidBegin", 1, &arg, NULL); + } + + virtual void editBoxEditingDidEnd(EditBox* editBox) + { + js_proxy_t * p = jsb_get_native_proxy(editBox); + if (!p) return; + + jsval arg = OBJECT_TO_JSVAL(p->obj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxEditingDidEnd", 1, &arg, NULL); + } + + virtual void editBoxTextChanged(EditBox* editBox, const std::string& text) + { + js_proxy_t * p = jsb_get_native_proxy(editBox); + if (!p) return; + + jsval dataVal[2]; + dataVal[0] = OBJECT_TO_JSVAL(p->obj); + std::string arg1 = text; + dataVal[1] = std_string_to_jsval(ScriptingCore::getInstance()->getGlobalContext(), arg1); + + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxTextChanged", 2, dataVal, NULL); + } + + virtual void editBoxReturn(EditBox* editBox) + { + js_proxy_t * p = jsb_get_native_proxy(editBox); + if (!p) return; + + jsval arg = OBJECT_TO_JSVAL(p->obj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxReturn", 1, &arg, NULL); + } + + void setJSDelegate(JSObject* pJSDelegate) + { + _JSDelegate = pJSDelegate; + + // Check whether the js delegate is a pure js object. + js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); + if (!p) + { + _needUnroot = true; + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); + } + } +private: + JSObject* _JSDelegate; + bool _needUnroot; +}; + +static JSBool js_cocos2dx_CCEditBox_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 1) + { + // save the delegate + JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); + JSB_EditBoxDelegate* nativeDelegate = new JSB_EditBoxDelegate(); + nativeDelegate->setJSDelegate(jsDelegate); + + cobj->setUserObject(nativeDelegate); + cobj->setDelegate(nativeDelegate); + + nativeDelegate->release(); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + + + +class JSB_ControlButtonTarget : public Object +{ +public: + JSB_ControlButtonTarget() + : _jsFunc(nullptr), + _type(Control::EventType::TOUCH_DOWN), + _jsTarget(nullptr), + _needUnroot(false) + {} + + virtual ~JSB_ControlButtonTarget() + { + CCLOGINFO("In the destruction of JSB_ControlButtonTarget ..."); + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + if (_needUnroot) + { + JS_RemoveObjectRoot(cx, &_jsTarget); + } + + JS_RemoveObjectRoot(cx, &_jsFunc); + + for (auto iter = _jsNativeTargetMap.begin(); iter != _jsNativeTargetMap.end(); ++iter) + { + if (this == iter->second) + { + _jsNativeTargetMap.erase(iter); + break; + } + } + } + + virtual void onEvent(Object *controlButton, Control::EventType event) + { + js_proxy_t * p; + JS_GET_PROXY(p, controlButton); + if (!p) + { + log("Failed to get proxy for control button"); + return; + } + + jsval dataVal[2]; + dataVal[0] = OBJECT_TO_JSVAL(p->obj); + int arg1 = (int)event; + dataVal[1] = INT_TO_JSVAL(arg1); + jsval jsRet; + + ScriptingCore::getInstance()->executeJSFunctionWithThisObj(OBJECT_TO_JSVAL(_jsTarget), OBJECT_TO_JSVAL(_jsFunc), 2, dataVal, &jsRet); + } + + void setJSTarget(JSObject* pJSTarget) + { + _jsTarget = pJSTarget; + + js_proxy_t* p = jsb_get_js_proxy(_jsTarget); + if (!p) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_AddNamedObjectRoot(cx, &_jsTarget, "JSB_ControlButtonTarget, target"); + _needUnroot = true; + } + } + + void setJSAction(JSObject* jsFunc) + { + _jsFunc = jsFunc; + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_AddNamedObjectRoot(cx, &_jsFunc, "JSB_ControlButtonTarget, func"); + } + + void setEventType(Control::EventType type) + { + _type = type; + } +public: + + static std::multimap _jsNativeTargetMap; + JSObject* _jsFunc; + Control::EventType _type; +private: + JSObject* _jsTarget; + bool _needUnroot; +}; + +std::multimap JSB_ControlButtonTarget::_jsNativeTargetMap; + +static JSBool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + JSBool ok = JS_TRUE; + if (argc == 3) + { + JSObject* jsDelegate = JSVAL_TO_OBJECT(argv[0]); + JSObject* jsFunc = JSVAL_TO_OBJECT(argv[1]); + Control::EventType arg2; + ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing control event"); + + // Check whether the target already exists. + auto range = JSB_ControlButtonTarget::_jsNativeTargetMap.equal_range(jsDelegate); + for (auto it = range.first; it != range.second; ++it) + { + if (it->second->_jsFunc == jsFunc && arg2 == it->second->_type) + { + // Return true directly. + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + } + + // save the delegate + JSB_ControlButtonTarget* nativeDelegate = new JSB_ControlButtonTarget(); + + nativeDelegate->setJSTarget(jsDelegate); + nativeDelegate->setJSAction(jsFunc); + nativeDelegate->setEventType(arg2); + + Array* nativeDelegateArray = static_cast(cobj->getUserObject()); + if (nullptr == nativeDelegateArray) + { + nativeDelegateArray = new Array(); + nativeDelegateArray->init(); + cobj->setUserObject(nativeDelegateArray); // The reference of nativeDelegateArray is added to 2 + nativeDelegateArray->release(); // Release nativeDelegateArray to make the reference to 1 + } + + nativeDelegateArray->addObject(nativeDelegate); // The reference of nativeDelegate is added to 2 + nativeDelegate->release(); // Release nativeDelegate to make the reference to 1 + + cobj->addTargetWithActionForControlEvents(nativeDelegate, cccontrol_selector(JSB_ControlButtonTarget::onEvent), arg2); + + JSB_ControlButtonTarget::_jsNativeTargetMap.insert(std::make_pair(jsDelegate, nativeDelegate)); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3); + return JS_FALSE; +} + +static JSBool js_cocos2dx_CCControl_removeTargetWithActionForControlEvents(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + JSBool ok = JS_TRUE; + if (argc == 3) + { + Control::EventType arg2; + ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing control event"); + + obj = JSVAL_TO_OBJECT(argv[0]); + JSObject* jsFunc = JSVAL_TO_OBJECT(argv[1]); + + JSB_ControlButtonTarget* nativeTargetToRemoved = nullptr; + + auto range = JSB_ControlButtonTarget::_jsNativeTargetMap.equal_range(obj); + for (auto it = range.first; it != range.second; ++it) + { + if (it->second->_jsFunc == jsFunc && arg2 == it->second->_type) + { + nativeTargetToRemoved = it->second; + JSB_ControlButtonTarget::_jsNativeTargetMap.erase(it); + break; + } + } + + cobj->removeTargetWithActionForControlEvents(nativeTargetToRemoved, cccontrol_selector(JSB_ControlButtonTarget::onEvent), arg2); + + return JS_TRUE; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3); + return JS_FALSE; +} + +extern JSObject* jsb_ScrollView_prototype; +extern JSObject* jsb_TableView_prototype; +extern JSObject* jsb_EditBox_prototype; +extern JSObject* jsb_Control_prototype; + +void register_all_cocos2dx_extension_manual(JSContext* cx, JSObject* global) +{ + JS_DefineFunction(cx, jsb_ScrollView_prototype, "setDelegate", js_cocos2dx_CCScrollView_setDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, jsb_TableView_prototype, "setDelegate", js_cocos2dx_CCTableView_setDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, jsb_TableView_prototype, "setDataSource", js_cocos2dx_CCTableView_setDataSource, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, jsb_EditBox_prototype, "setDelegate", js_cocos2dx_CCEditBox_setDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, jsb_Control_prototype, "addTargetWithActionForControlEvents", js_cocos2dx_CCControl_addTargetWithActionForControlEvents, 3, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, jsb_Control_prototype, "removeTargetWithActionForControlEvents", js_cocos2dx_CCControl_removeTargetWithActionForControlEvents, 3, JSPROP_READONLY | JSPROP_PERMANENT); + + JSObject *tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.TableView; })()")); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCTableView_create, 3, JSPROP_READONLY | JSPROP_PERMANENT); +} \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.h b/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.h new file mode 100644 index 0000000000..e8822b1370 --- /dev/null +++ b/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.h @@ -0,0 +1,16 @@ +// +// jsb_cocos2d_extension_manual.h +// +// Created by James Chen on 3/11/13. +// +// + +#ifndef __jsb_cocos2dx_extension_manual__ +#define __jsb_cocos2dx_extension_manual__ + +#include "jsapi.h" +#include "jsfriendapi.h" + +void register_all_cocos2dx_extension_manual(JSContext* cx, JSObject* global); + +#endif /* defined(__jsb_cocos2dx_extension_manual__) */ diff --git a/cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj b/cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj new file mode 100644 index 0000000000..b9ea3695d9 --- /dev/null +++ b/cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj @@ -0,0 +1,118 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + {625F7391-9A91-48A1-8CFC-79508C822637} + Win32Proj + libJSBindingForExtension + + + + StaticLibrary + true + Unicode + v100 + v110 + v110_xp + + + StaticLibrary + false + Unicode + v100 + v110 + v110_xp + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + + + + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\network;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + false + + + Windows + true + + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\network;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + + + Windows + true + true + true + + + + + + + + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj.filters b/cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj.filters new file mode 100644 index 0000000000..805e94fc71 --- /dev/null +++ b/cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj.filters @@ -0,0 +1,34 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + generated + + + manual + + + + + generated + + + manual + + + + + generated + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj.user b/cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj.user new file mode 100644 index 0000000000..3f03091124 --- /dev/null +++ b/cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj.user @@ -0,0 +1,6 @@ + + + + false + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions.cpp b/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions.cpp new file mode 100644 index 0000000000..7d1a819fc8 --- /dev/null +++ b/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions.cpp @@ -0,0 +1,75 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 +* Script version: v0.5 +*/ +#include "cocos2d.h" +#include "js_bindings_config.h" +//#ifdef JSB_INCLUDE_SYSTEM + +#include "local-storage/LocalStorage.h" + +#include "jsfriendapi.h" +#include "js_bindings_config.h" +#include "js_bindings_core.h" +#include "js_manual_conversions.h" +#include "js_bindings_system_functions.h" +#include "ScriptingCore.h" + +USING_NS_CC; + +// Arguments: char* +// Ret value: const char* +JSBool JSB_localStorageGetItem(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + const char* arg0; + + ok &= jsval_to_charptr( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + const char* ret_val; + + ret_val = localStorageGetItem((char*)arg0 ); + + jsval ret_jsval = c_string_to_jsval(cx, ret_val ? ret_val : ""); + JS_SET_RVAL(cx, vp, ret_jsval ); + + return JS_TRUE; +} + +// Arguments: char* +// Ret value: void +JSBool JSB_localStorageRemoveItem(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + const char* arg0; + + ok &= jsval_to_charptr( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + localStorageRemoveItem((char*)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: char*, char* +// Ret value: void +JSBool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + const char* arg0; const char* arg1; + + ok &= jsval_to_charptr( cx, *argvp++, &arg0 ); + ok &= jsval_to_charptr( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + localStorageSetItem((char*)arg0 , (char*)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + + +//#endif // JSB_INCLUDE_SYSTEM diff --git a/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions.h b/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions.h new file mode 100644 index 0000000000..26d4a97c99 --- /dev/null +++ b/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions.h @@ -0,0 +1,23 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 +* Script version: v0.5 +*/ +#include "js_bindings_config.h" +//#ifdef JSB_INCLUDE_SYSTEM + +//#include "LocalStorage.h" + +#ifdef __cplusplus +extern "C" { +#endif +JSBool JSB_localStorageGetItem(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_localStorageRemoveItem(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp); + +#ifdef __cplusplus +} +#endif + + +//#endif // JSB_INCLUDE_SYSTEM diff --git a/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions_registration.h b/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions_registration.h new file mode 100644 index 0000000000..5774403878 --- /dev/null +++ b/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions_registration.h @@ -0,0 +1,15 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 +* Script version: v0.5 +*/ +#include "../js_bindings_config.h" +//#ifdef JSB_INCLUDE_SYSTEM + +//#include "LocalStorage.h" +JS_DefineFunction(_cx, system, "getItem", JSB_localStorageGetItem, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, system, "removeItem", JSB_localStorageRemoveItem, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, system, "setItem", JSB_localStorageSetItem, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + + +//#endif // JSB_INCLUDE_SYSTEM diff --git a/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_registration.cpp b/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_registration.cpp new file mode 100644 index 0000000000..bf55e188f0 --- /dev/null +++ b/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_registration.cpp @@ -0,0 +1,62 @@ +/* + * JS Bindings: https://github.com/zynga/jsbindings + * + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "js_bindings_config.h" +#include "js_bindings_core.h" +#include "local-storage/LocalStorage.h" +#include "cocos2d.h" + +// system +#include "js_bindings_system_functions.h" + + +void jsb_register_system( JSContext *_cx, JSObject *object) +{ + // + // sys + // + JSObject *sys = JS_NewObject(_cx, NULL, NULL, NULL); + jsval systemVal = OBJECT_TO_JSVAL(sys); + JS_SetProperty(_cx, object, "sys", &systemVal); + + + // sys.localStorage + JSObject *ls = JS_NewObject(_cx, NULL, NULL, NULL); + jsval lsVal = OBJECT_TO_JSVAL(ls); + JS_SetProperty(_cx, sys, "localStorage", &lsVal); + + // sys.localStorage functions + JSObject *system = ls; +#include "js_bindings_system_functions_registration.h" + + + // Init DB with full path + //NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; + //NSString *fullpath = [path stringByAppendingPathComponent:@"jsb.sqlite"]; + std::string strFilePath = cocos2d::FileUtils::getInstance()->getWritablePath(); + strFilePath += "/jsb.sqlite"; + localStorageInit(strFilePath.c_str()); + +} + diff --git a/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_registration.h b/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_registration.h new file mode 100644 index 0000000000..1afb1b1081 --- /dev/null +++ b/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_registration.h @@ -0,0 +1,31 @@ +/* + * JS Bindings: https://github.com/zynga/jsbindings + * + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#ifndef __JSB_SYSTEM_REGISTRATION +#define __JSB_SYSTEM_REGISTRATION + +void jsb_register_system( JSContext *globalC, JSObject *globalO); + +#endif // __JSB_CHIPMUNK_REGISTRATION diff --git a/cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj b/cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj new file mode 100644 index 0000000000..2f074d6c17 --- /dev/null +++ b/cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj @@ -0,0 +1,116 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE} + Win32Proj + libJSBindingForLocalStorage + + + + StaticLibrary + true + Unicode + v100 + v110 + v110_xp + + + StaticLibrary + false + Unicode + v100 + v110 + v110_xp + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + + + + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\spidermonkey\include\win32;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + false + + + Windows + true + + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\spidermonkey\include\win32;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + + + Windows + true + true + true + + + + + + + + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj.filters b/cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj.filters new file mode 100644 index 0000000000..9fc0ee4734 --- /dev/null +++ b/cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj.filters @@ -0,0 +1,32 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + manual + + + manual + + + + + manual + + + manual + + + manual + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj.user b/cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj.user new file mode 100644 index 0000000000..3f03091124 --- /dev/null +++ b/cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj.user @@ -0,0 +1,6 @@ + + + + false + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.cpp b/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.cpp new file mode 100644 index 0000000000..cc7b72c586 --- /dev/null +++ b/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.cpp @@ -0,0 +1,847 @@ +// +// XMLHTTPRequest.cpp +// XMLHttpRequest +// +// Created by Zynga 2013 +// +// Heavy based on: https://github.com/funkaster/FakeWebGL/blob/master/FakeWebGL/WebGL/XMLHTTPRequest.cpp +// Copyright (c) 2012 Rolando Abarca. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#include "XMLHTTPRequest.h" +#include + +using namespace std; + +//#pragma mark - MinXmlHttpRequest + +/** + * @brief Implementation for header retrieving. + * @param header + */ +void MinXmlHttpRequest::_gotHeader(string header) +{ + // Get Header and Set StatusText + // Split String into Tokens + char * cstr = new char [header.length()+1]; + + // check for colon. + unsigned found_header_field = header.find_first_of(":"); + + if (found_header_field != std::string::npos) + { + // Found a header field. + string http_field; + string http_value; + + http_field = header.substr(0,found_header_field); + http_value = header.substr(found_header_field+1, header.length()); + + // Get rid of all \n + if (!http_value.empty() && http_value[http_value.size() - 1] == '\n') { + http_value.erase(http_value.size() - 1); + } + + _httpHeader[http_field] = http_value; + + } + else + { + // Seems like we have the response Code! Parse it and check for it. + char * pch; + strcpy(cstr, header.c_str()); + + pch = strtok(cstr," "); + while (pch != NULL) + { + + stringstream ss; + string val; + + ss << pch; + val = ss.str(); + unsigned found_http = val.find("HTTP"); + + // Check for HTTP Header to set statusText + if (found_http != std::string::npos) { + + stringstream mystream; + + // Get Response Status + pch = strtok (NULL, " "); + mystream << pch; + + pch = strtok (NULL, " "); + mystream << " " << pch; + + _statusText = mystream.str(); + + } + + pch = strtok (NULL, " "); + } + } + + CC_SAFE_DELETE_ARRAY(cstr); +} + +/** + * @brief Set Request header for next call. + * @param field Name of the Header to be set. + * @param value Value of the Headerfield + */ +void MinXmlHttpRequest::_setRequestHeader(const char* field, const char* value) +{ + stringstream header_s; + stringstream value_s; + string header; + + map::iterator iter = _requestHeader.find(field); + + // Concatenate values when header exists. + if (iter != _requestHeader.end()) + { + value_s << iter->second << "," << value; + } + else + { + value_s << value; + } + + _requestHeader[field] = value_s.str(); +} + +/** + * @brief If headers has been set, pass them to curl. + * + */ +void MinXmlHttpRequest::_setHttpRequestHeader() +{ + std::vector header; + + for (auto it = _requestHeader.begin(); it != _requestHeader.end(); ++it) + { + const char* first = it->first.c_str(); + const char* second = it->second.c_str(); + size_t len = sizeof(char) * (strlen(first) + 3 + strlen(second)); + char* test = (char*) malloc(len); + memset(test, 0,len); + + strcpy(test, first); + strcpy(test + strlen(first) , ": "); + strcpy(test + strlen(first) + 2, second); + + header.push_back(test); + + free(test); + + } + + if (!header.empty()) + { + _httpRequest->setHeaders(header); + } + +} + +/** + * @brief Callback for HTTPRequest. Handles the response and invokes Callback. + * @param sender Object which initialized callback + * @param respone Response object + */ +void MinXmlHttpRequest::handle_requestResponse(network::HttpClient *sender, network::HttpResponse *response) +{ + if (0 != strlen(response->getHttpRequest()->getTag())) + { + CCLOG("%s completed", response->getHttpRequest()->getTag()); + } + + int statusCode = response->getResponseCode(); + char statusString[64] = {}; + sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag()); + + if (!response->isSucceed()) + { + CCLOG("response failed"); + CCLOG("error buffer: %s", response->getErrorBuffer()); + return; + } + + // set header + std::vector *headers = response->getResponseHeader(); + + char* concatHeader = (char*) malloc(headers->size() + 1); + std::string header(headers->begin(), headers->end()); + strcpy(concatHeader, header.c_str()); + + std::istringstream stream(concatHeader); + std::string line; + while(std::getline(stream, line)) { + _gotHeader(line); + } + + /** get the response data **/ + std::vector *buffer = response->getResponseData(); + char* concatenated = (char*) malloc(buffer->size() + 1); + std::string s2(buffer->begin(), buffer->end()); + + strcpy(concatenated, s2.c_str()); + + if (statusCode == 200) + { + //Succeeded + _status = 200; + _readyState = DONE; + _data << concatenated; + _dataSize = buffer->size(); + } + else + { + _status = 0; + } + // Free Memory. + free((void*) concatHeader); + free((void*) concatenated); + + js_proxy_t * p; + void* ptr = (void*)this; + p = jsb_get_native_proxy(ptr); + + if(p) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + + if (_onreadystateCallback) + { + //JS_IsExceptionPending(cx) && JS_ReportPendingException(cx); + jsval fval = OBJECT_TO_JSVAL(_onreadystateCallback); + jsval out; + JS_CallFunctionValue(cx, NULL, fval, 0, NULL, &out); + } + + } + +} +/** + * @brief Send out request and fire callback when done. + * @param cx Javascript context + */ +void MinXmlHttpRequest::_sendRequest(JSContext *cx) +{ + _httpRequest->setResponseCallback(this, httpresponse_selector(MinXmlHttpRequest::handle_requestResponse)); + network::HttpClient::getInstance()->send(_httpRequest); + _httpRequest->release(); +} + +/** + * @brief Constructor initializes cchttprequest and stuff + * + */ +MinXmlHttpRequest::MinXmlHttpRequest() : _onreadystateCallback(NULL), _isNetwork(true) +{ + _httpHeader.clear(); + _requestHeader.clear(); + _withCredentialsValue = true; + _cx = ScriptingCore::getInstance()->getGlobalContext(); + _httpRequest = new network::HttpRequest(); +} + +/** + * @brief Destructor cleans up _httpRequest and stuff + * + */ +MinXmlHttpRequest::~MinXmlHttpRequest() +{ + _httpHeader.clear(); + _requestHeader.clear(); + + if (_onreadystateCallback != NULL) + { + JS_RemoveObjectRoot(_cx, &_onreadystateCallback); + } + + if (_httpRequest) + { + // We don't need to release _httpRequest here since it will be released in the http callback. +// _httpRequest->release(); + } + +} + +/** + * @brief Initialize Object and needed properties. + * + */ +JS_BINDED_CLASS_GLUE_IMPL(MinXmlHttpRequest); + +/** + * @brief Implementation for the Javascript Constructor + * + */ +JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) +{ + MinXmlHttpRequest* req = new MinXmlHttpRequest(); + req->autorelease(); + + js_proxy_t *p; + jsval out; + + JSObject *obj = JS_NewObject(cx, &MinXmlHttpRequest::js_class, MinXmlHttpRequest::js_proto, MinXmlHttpRequest::js_parent); + + if (obj) { + JS_SetPrivate(obj, req); + out = OBJECT_TO_JSVAL(obj); + } + + JS_SET_RVAL(cx, vp, out); + p =jsb_new_proxy(req, obj); + + JS_AddNamedObjectRoot(cx, &p->obj, "XMLHttpRequest"); + return JS_TRUE; +} + +/** + * @brief get Callback function for Javascript + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, onreadystatechange) +{ + if (_onreadystateCallback) + { + JSString *tmpstr = JS_NewStringCopyZ(cx, "1"); + jsval tmpval = STRING_TO_JSVAL(tmpstr); + JS_SetProperty(cx, _onreadystateCallback, "readyState", &tmpval); + + jsval out = OBJECT_TO_JSVAL(_onreadystateCallback); + vp.set(out); + + } + else + { + vp.set(JSVAL_NULL); + } + return JS_TRUE; +} + +/** + * @brief Set Callback function coming from Javascript + * + * + */ +JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, onreadystatechange) +{ + jsval callback = vp.get(); + if (callback != JSVAL_NULL) + { + _onreadystateCallback = JSVAL_TO_OBJECT(callback); + JS_AddNamedObjectRoot(cx, &_onreadystateCallback, "onreadystateCallback"); + } + return JS_TRUE; +} + +/** + * @brief upload getter - TODO + * + * Placeholder for further implementations!! + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, upload) +{ + vp.set(JSVAL_NULL); + return JS_TRUE; +} + +/** + * @brief upload setter - TODO + * + * Placeholder for further implementations + */ +JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, upload) +{ + vp.set(JSVAL_NULL); + return JS_TRUE; +} + +/** + * @brief timeout getter - TODO + * + * Placeholder for further implementations + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, timeout) +{ + vp.set(INT_TO_JSVAL(_timeout)); + return JS_TRUE; +} + +/** + * @brief timeout setter - TODO + * + * Placeholder for further implementations + */ +JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, timeout) +{ + jsval timeout_ms = vp.get(); + + _timeout = JSVAL_TO_INT(timeout_ms); + //curl_easy_setopt(curlHandle, CURLOPT_CONNECTTIMEOUT_MS, timeout); + return JS_TRUE; + +} + +/** + * @brief get response type for actual XHR + * + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseType) +{ + JSString* str = JS_NewStringCopyN(cx, "", 0); + vp.set(STRING_TO_JSVAL(str)); + return JS_TRUE; +} + +/** + * @brief responseXML getter - TODO + * + * Placeholder for further implementation. + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseXML) +{ + vp.set(JSVAL_NULL); + return JS_TRUE; +} + +/** + * @brief set response type for actual XHR + * + * + */ +JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, responseType) +{ + jsval type = vp.get(); + if (type.isString()) { + JSString* str = type.toString(); + JSBool equal; + + JS_StringEqualsAscii(cx, str, "text", &equal); + if (equal) + { + _responseType = ResponseType::STRING; + return JS_TRUE; + } + + JS_StringEqualsAscii(cx, str, "arraybuffer", &equal); + if (equal) + { + _responseType = ResponseType::ARRAY_BUFFER; + return JS_TRUE; + } + + JS_StringEqualsAscii(cx, str, "json", &equal); + if (equal) + { + _responseType = ResponseType::JSON; + return JS_TRUE; + } + // ignore the rest of the response types for now + return JS_TRUE; + } + JS_ReportError(cx, "Invalid response type"); + return JS_FALSE; +} + +/** + * @brief get readyState for actual XHR + * + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, readyState) +{ + vp.set(INT_TO_JSVAL(_readyState)); + return JS_TRUE; +} + +/** + * @brief get status for actual XHR + * + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, status) +{ + vp.set(INT_TO_JSVAL(_status)); + return JS_TRUE; +} + +/** + * @brief get statusText for actual XHR + * + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, statusText) +{ + jsval strVal = std_string_to_jsval(cx, _statusText); + + if (strVal != JSVAL_NULL) + { + vp.set(strVal); + return JS_TRUE; + } + else + { + JS_ReportError(cx, "Error trying to create JSString from data"); + return JS_FALSE; + } +} + +/** + * @brief get value of withCredentials property. + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, withCredentials) +{ + vp.set(BOOLEAN_TO_JSVAL(_withCredentialsValue)); + return JS_TRUE; +} + +/** + * withCredentials - set value of withCredentials property. + * + */ +JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, withCredentials) +{ + jsval credential = vp.get(); + if (credential != JSVAL_NULL) + { + _withCredentialsValue = JSVAL_TO_BOOLEAN(credential); + } + + return JS_TRUE; +} + +/** + * @brief get (raw) responseText + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseText) +{ + jsval strVal = std_string_to_jsval(cx, _data.str()); + + if (strVal != JSVAL_NULL) + { + vp.set(strVal); + //JS_ReportError(cx, "Result: %s", data.str().c_str()); + return JS_TRUE; + } else { + JS_ReportError(cx, "Error trying to create JSString from data"); + return JS_FALSE; + } +} + +/** + * @brief get response of latest XHR + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, response) +{ + + if (_responseType == ResponseType::JSON) + { + jsval outVal; + + jsval strVal = std_string_to_jsval(cx, _data.str()); + if (JS_ParseJSON(cx, JS_GetStringCharsZ(cx, JSVAL_TO_STRING(strVal)), _dataSize, &outVal)) + { + vp.set(outVal); + return JS_TRUE; + } + } + else if (_responseType == ResponseType::ARRAY_BUFFER) + { + JSObject* tmp = JS_NewArrayBuffer(cx, _dataSize); + uint8_t* tmpData = JS_GetArrayBufferData(tmp); + _data.read((char*)tmpData, _dataSize); + jsval outVal = OBJECT_TO_JSVAL(tmp); + + vp.set(outVal); + return JS_TRUE; + } + // by default, return text + return _js_get_responseText(cx, id, vp); +} + +/** + * @brief initialize new xhr. + * + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, open) +{ + if (argc >= 2) + { + jsval* argv = JS_ARGV(cx, vp); + const char* method; + const char* urlstr; + JSBool async = true; + JSString* jsMethod = JS_ValueToString(cx, argv[0]); + JSString* jsURL = JS_ValueToString(cx, argv[1]); + + if (argc > 2) { + JS_ValueToBoolean(cx, argv[2], &async); + } + + JSStringWrapper w1(jsMethod); + JSStringWrapper w2(jsURL); + method = w1; + urlstr = w2; + + _url = urlstr; + _meth = method; + _readyState = 1; + _isAsync = async; + + if (_url.length() > 5 && _url.compare(_url.length() - 5, 5, ".json") == 0) + { + _responseType = ResponseType::JSON; + } + + if (_meth.compare("post") == 0 || _meth.compare("POST") == 0) + { + _httpRequest->setRequestType(network::HttpRequest::Type::POST); + } + else + { + _httpRequest->setRequestType(network::HttpRequest::Type::GET); + } + + _httpRequest->setUrl(_url.c_str()); + + _isNetwork = true; + _readyState = OPENED; + + return JS_TRUE; + } + + JS_ReportError(cx, "invalid call: %s", __FUNCTION__); + return JS_FALSE; + +} + +/** + * @brief send xhr + * + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, send) +{ + JSString *str = NULL; + std::string data; + + // Clean up header map. New request, new headers! + _httpHeader.clear(); + + if (argc == 1) + { + if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &str)) + { + return JS_FALSE; + } + JSStringWrapper strWrap(str); + data = strWrap.get(); + } + + + if (data.length() > 0 && (_meth.compare("post") == 0 || _meth.compare("POST") == 0)) + { + _httpRequest->setRequestData(data.c_str(), data.length()); + } + + _setHttpRequestHeader(); + _sendRequest(cx); + + return JS_TRUE; +} + +/** + * @brief abort function Placeholder! + * + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, abort) +{ + return JS_TRUE; +} + +/** + * @brief Get all response headers as a string + * + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getAllResponseHeaders) +{ + stringstream responseheaders; + string responseheader; + + for (auto it = _httpHeader.begin(); it != _httpHeader.end(); ++it) + { + responseheaders << it->first << ": " << it->second << "\n"; + } + + responseheader = responseheaders.str(); + + jsval strVal = std_string_to_jsval(cx, responseheader); + if (strVal != JSVAL_NULL) + { + JS_SET_RVAL(cx, vp, strVal); + return JS_TRUE; + } + else + { + JS_ReportError(cx, "Error trying to create JSString from data"); + return JS_FALSE; + } + + return JS_TRUE; +} + +/** + * @brief Get all response headers as a string + * + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getResponseHeader) +{ + JSString *header_value; + + if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &header_value)) { + return JS_FALSE; + }; + + std::string data; + JSStringWrapper strWrap(header_value); + data = strWrap.get(); + + stringstream streamdata; + + streamdata << data; + + string value = streamdata.str(); + + auto iter = _httpHeader.find(value); + if (iter != _httpHeader.end()) + { + jsval js_ret_val = std_string_to_jsval(cx, iter->second); + JS_SET_RVAL(cx, vp, js_ret_val); + return JS_TRUE; + } + else { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } +} + +/** + * @brief Set the given Fields to request Header. + * + * + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, setRequestHeader) +{ + if (argc >= 2) + { + jsval* argv = JS_ARGV(cx, vp); + const char* field; + const char* value; + + JSString* jsField = JS_ValueToString(cx, argv[0]); + JSString* jsValue = JS_ValueToString(cx, argv[1]); + + JSStringWrapper w1(jsField); + JSStringWrapper w2(jsValue); + field = w1; + value = w2; + + // Populate the request_header map. + _setRequestHeader(field, value); + + return JS_TRUE; + } + + return JS_FALSE; + +} + +/** + * @brief overrideMimeType function - TODO! + * + * Just a placeholder for further implementations. + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, overrideMimeType) +{ + return JS_TRUE; +} + +/** + * @brief destructor for Javascript + * + */ +static void basic_object_finalize(JSFreeOp *freeOp, JSObject *obj) +{ + CCLOG("basic_object_finalize %p ...", obj); +} + +/** + * @brief Register XMLHttpRequest to be usable in JS and add properties and Mehtods. + * @param cx Global Spidermonkey JS Context. + * @param global Global Spidermonkey Javascript object. + */ +void MinXmlHttpRequest::_js_register(JSContext *cx, JSObject *global) +{ + JSClass js_class = { + "XMLHttpRequest", JSCLASS_HAS_PRIVATE, JS_PropertyStub, + JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, + JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, + basic_object_finalize, JSCLASS_NO_OPTIONAL_MEMBERS + }; + + MinXmlHttpRequest::js_class = js_class; + static JSPropertySpec props[] = { + JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, onreadystatechange), + JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, responseType), + JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, withCredentials), + JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, readyState), + JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, status), + JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, statusText), + JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, responseText), + JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, responseXML), + JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, response), + {0, 0, 0, 0, 0} + }; + + static JSFunctionSpec funcs[] = { + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, open), + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, abort), + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, send), + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, setRequestHeader), + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getAllResponseHeaders), + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getResponseHeader), + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, overrideMimeType), + JS_FS_END + }; + + MinXmlHttpRequest::js_parent = NULL; + MinXmlHttpRequest::js_proto = JS_InitClass(cx, global, NULL, &MinXmlHttpRequest::js_class , MinXmlHttpRequest::_js_constructor, 0, props, funcs, NULL, NULL); + +} + diff --git a/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.h b/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.h new file mode 100644 index 0000000000..861e0a2536 --- /dev/null +++ b/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.h @@ -0,0 +1,112 @@ +// +// XMLHTTPRequest.h +// XMLHttpRequest +// +// Created by Zynga 2013 +// +// Heavy based on: https://github.com/funkaster/FakeWebGL/blob/master/FakeWebGL/WebGL/XMLHTTPRequest.h +// Copyright (c) 2012 Rolando Abarca. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#ifndef __FAKE_XMLHTTPREQUEST_H__ +#define __FAKE_XMLHTTPREQUEST_H__ + +#include "network/HttpClient.h" +#include "js_bindings_config.h" +#include "ScriptingCore.h" +#include "jstypes.h" +#include "jsapi.h" +#include "jsfriendapi.h" +#include "jsb_helper.h" + +class MinXmlHttpRequest : public cocos2d::Object +{ +public: + enum class ResponseType + { + STRING, + ARRAY_BUFFER, + BLOB, + DOCUMENT, + JSON + }; + + // Ready States (http://www.w3.org/TR/XMLHttpRequest/#interface-xmlhttprequest) + static const unsigned short UNSENT = 0; + static const unsigned short OPENED = 1; + static const unsigned short HEADERS_RECEIVED = 2; + static const unsigned short LOADING = 3; + static const unsigned short DONE = 4; + + MinXmlHttpRequest(); + ~MinXmlHttpRequest(); + + JS_BINDED_CLASS_GLUE(MinXmlHttpRequest); + JS_BINDED_CONSTRUCTOR(MinXmlHttpRequest); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onreadystatechange); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, responseType); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, withCredentials); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, upload); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, timeout); + JS_BINDED_PROP_GET(MinXmlHttpRequest, readyState); + JS_BINDED_PROP_GET(MinXmlHttpRequest, status); + JS_BINDED_PROP_GET(MinXmlHttpRequest, statusText); + JS_BINDED_PROP_GET(MinXmlHttpRequest, responseText); + JS_BINDED_PROP_GET(MinXmlHttpRequest, response); + JS_BINDED_PROP_GET(MinXmlHttpRequest, responseXML); + JS_BINDED_FUNC(MinXmlHttpRequest, open); + JS_BINDED_FUNC(MinXmlHttpRequest, send); + JS_BINDED_FUNC(MinXmlHttpRequest, abort); + JS_BINDED_FUNC(MinXmlHttpRequest, getAllResponseHeaders); + JS_BINDED_FUNC(MinXmlHttpRequest, getResponseHeader); + JS_BINDED_FUNC(MinXmlHttpRequest, setRequestHeader); + JS_BINDED_FUNC(MinXmlHttpRequest, overrideMimeType); + + void handle_requestResponse(network::HttpClient *sender, network::HttpResponse *response); + + +private: + void _gotHeader(std::string header); + void _setRequestHeader(const char* field, const char* value); + void _setHttpRequestHeader(); + void _sendRequest(JSContext *cx); + + std::string _url; + JSContext* _cx; + std::string _meth; + std::string _type; + std::stringstream _data; + size_t _dataSize; + JSObject* _onreadystateCallback; + int _readyState; + int _status; + std::string _statusText; + ResponseType _responseType; + unsigned _timeout; + bool _isAsync; + network::HttpRequest* _httpRequest; + bool _isNetwork; + bool _withCredentialsValue; + std::map _httpHeader; + std::map _requestHeader; +}; + +#endif diff --git a/cocos/scripting/javascript/bindings/network/jsb_websocket.cpp b/cocos/scripting/javascript/bindings/network/jsb_websocket.cpp new file mode 100644 index 0000000000..b5083ad268 --- /dev/null +++ b/cocos/scripting/javascript/bindings/network/jsb_websocket.cpp @@ -0,0 +1,382 @@ +/**************************************************************************** +Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013 James Chen + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#include "jsb_websocket.h" +#include "cocos2d.h" +#include "network/WebSocket.h" +#include "spidermonkey_specifics.h" +#include "ScriptingCore.h" +#include "cocos2d_specifics.hpp" + +using namespace network; + +/* + [Constructor(in DOMString url, in optional DOMString protocols)] + [Constructor(in DOMString url, in optional DOMString[] protocols)] + interface WebSocket { + readonly attribute DOMString url; + + // ready state + const unsigned short CONNECTING = 0; + const unsigned short OPEN = 1; + const unsigned short CLOSING = 2; + const unsigned short CLOSED = 3; + readonly attribute unsigned short readyState; + readonly attribute unsigned long bufferedAmount; + + // networking + attribute Function onopen; + attribute Function onmessage; + attribute Function onerror; + attribute Function onclose; + readonly attribute DOMString protocol; + void send(in DOMString data); + void close(); + }; + WebSocket implements EventTarget; + */ + +class JSB_WebSocketDelegate : public WebSocket::Delegate +{ +public: + + virtual void onOpen(WebSocket* ws) + { + js_proxy_t * p = jsb_get_native_proxy(ws); + if (!p) return; + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); + jsval vp = c_string_to_jsval(cx, "open"); + JS_SetProperty(cx, jsobj, "type", &vp); + + jsval args = OBJECT_TO_JSVAL(jsobj); + + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onopen", 1, &args); + } + + virtual void onMessage(WebSocket* ws, const WebSocket::Data& data) + { + js_proxy_t * p = jsb_get_native_proxy(ws); + if (!p) return; + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); + jsval vp = c_string_to_jsval(cx, "message"); + JS_SetProperty(cx, jsobj, "type", &vp); + + jsval args = OBJECT_TO_JSVAL(jsobj); + + if (data.isBinary) + {// data is binary + JSObject* buffer = JS_NewArrayBuffer(cx, data.len); + uint8_t* bufdata = JS_GetArrayBufferData(buffer); + memcpy((void*)bufdata, (void*)data.bytes, data.len); + jsval dataVal = OBJECT_TO_JSVAL(buffer); + JS_SetProperty(cx, jsobj, "data", &dataVal); + } + else + {// data is string + jsval dataVal = c_string_to_jsval(cx, data.bytes); + JS_SetProperty(cx, jsobj, "data", &dataVal); + } + + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onmessage", 1, &args); + } + + virtual void onClose(WebSocket* ws) + { + js_proxy_t * p = jsb_get_native_proxy(ws); + if (!p) return; + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); + jsval vp = c_string_to_jsval(cx, "close"); + JS_SetProperty(cx, jsobj, "type", &vp); + + jsval args = OBJECT_TO_JSVAL(jsobj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onclose", 1, &args); + + js_proxy_t* jsproxy = jsb_get_js_proxy(p->obj); + JS_RemoveObjectRoot(cx, &jsproxy->obj); + jsb_remove_proxy(p, jsproxy); + CC_SAFE_DELETE(ws); + } + + virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error) + { + js_proxy_t * p = jsb_get_native_proxy(ws); + if (!p) return; + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); + jsval vp = c_string_to_jsval(cx, "error"); + JS_SetProperty(cx, jsobj, "type", &vp); + + jsval args = OBJECT_TO_JSVAL(jsobj); + + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onerror", 1, &args); + } + + void setJSDelegate(JSObject* pJSDelegate) + { + _JSDelegate = pJSDelegate; + } +private: + JSObject* _JSDelegate; +}; + +JSClass *js_cocos2dx_websocket_class; +JSObject *js_cocos2dx_websocket_prototype; + +void js_cocos2dx_WebSocket_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOG("jsbindings: finalizing JS object %p (WebSocket)", obj); +} + +JSBool js_cocos2dx_extension_WebSocket_send(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if(argc == 1){ + do + { + if (JSVAL_IS_STRING(argv[0])) + { + std::string data; + jsval_to_std_string(cx, argv[0], &data); + cobj->send(data); + break; + } + + if (argv[0].isObject()) + { + uint8_t *bufdata = NULL; + uint32_t len = 0; + + JSObject* jsobj = JSVAL_TO_OBJECT(argv[0]); + if (JS_IsArrayBufferObject(jsobj)) + { + bufdata = JS_GetArrayBufferData(jsobj); + len = JS_GetArrayBufferByteLength(jsobj); + } + else if (JS_IsArrayBufferViewObject(jsobj)) + { + bufdata = (uint8_t*)JS_GetArrayBufferViewData(jsobj); + len = JS_GetArrayBufferViewByteLength(jsobj); + } + + if (bufdata && len > 0) + { + cobj->send(bufdata, len); + break; + } + } + + JS_ReportError(cx, "data type to be sent is unsupported."); + + } while (0); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return JS_TRUE; +} + +JSBool js_cocos2dx_extension_WebSocket_close(JSContext *cx, uint32_t argc, jsval *vp){ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if(argc == 0){ + cobj->close(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return JS_FALSE; +} + +JSBool js_cocos2dx_extension_WebSocket_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 1 || argc == 2) + { + + std::string url; + + do { + JSBool ok = jsval_to_std_string(cx, argv[0], &url); + JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error processing arguments"); + } while (0); + + JSObject *obj = JS_NewObject(cx, js_cocos2dx_websocket_class, js_cocos2dx_websocket_prototype, NULL); + + + WebSocket* cobj = new WebSocket(); + JSB_WebSocketDelegate* delegate = new JSB_WebSocketDelegate(); + delegate->setJSDelegate(obj); + + if (argc == 2) + { + std::vector protocols; + + if (JSVAL_IS_STRING(argv[1])) + { + std::string protocol; + do { + JSBool ok = jsval_to_std_string(cx, argv[1], &protocol); + JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error processing arguments"); + } while (0); + protocols.push_back(protocol); + } + else if (argv[1].isObject()) + { + JSBool ok = JS_TRUE; + JSObject* arg2 = JSVAL_TO_OBJECT(argv[1]); + JSB_PRECONDITION(JS_IsArrayObject( cx, arg2 ), "Object must be an array"); + + uint32_t len = 0; + JS_GetArrayLength(cx, arg2, &len); + + for( uint32_t i=0; i< len;i++ ) + { + jsval valarg; + JS_GetElement(cx, arg2, i, &valarg); + std::string protocol; + do { + ok = jsval_to_std_string(cx, valarg, &protocol); + JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error processing arguments"); + } while (0); + + protocols.push_back(protocol); + } + } + cobj->init(*delegate, url, &protocols); + } + else + { + cobj->init(*delegate, url); + } + + + JS_DefineProperty(cx, obj, "URL", argv[0] + , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); + + //protocol not support yet (always return "") + JS_DefineProperty(cx, obj, "protocol", c_string_to_jsval(cx, "") + , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); + + // link the native object with the javascript object + js_proxy_t *p = jsb_new_proxy(cobj, obj); + JS_AddNamedObjectRoot(cx, &p->obj, "WebSocket"); + + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return JS_FALSE; +} + +static JSBool js_cocos2dx_extension_WebSocket_get_readyState(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (cobj) { + vp.set(INT_TO_JSVAL((int)cobj->getReadyState())); + return JS_TRUE; + } else { + JS_ReportError(cx, "Error: WebSocket instance is invalid."); + return JS_FALSE; + } +} + +void register_jsb_websocket(JSContext *cx, JSObject *global) { + + js_cocos2dx_websocket_class = (JSClass *)calloc(1, sizeof(JSClass)); + js_cocos2dx_websocket_class->name = "WebSocket"; + js_cocos2dx_websocket_class->addProperty = JS_PropertyStub; + js_cocos2dx_websocket_class->delProperty = JS_DeletePropertyStub; + js_cocos2dx_websocket_class->getProperty = JS_PropertyStub; + js_cocos2dx_websocket_class->setProperty = JS_StrictPropertyStub; + js_cocos2dx_websocket_class->enumerate = JS_EnumerateStub; + js_cocos2dx_websocket_class->resolve = JS_ResolveStub; + js_cocos2dx_websocket_class->convert = JS_ConvertStub; + js_cocos2dx_websocket_class->finalize = js_cocos2dx_WebSocket_finalize; + js_cocos2dx_websocket_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + {"readyState", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_cocos2dx_extension_WebSocket_get_readyState), NULL}, + {0, 0, 0, 0, 0} + }; + + static JSFunctionSpec funcs[] = { + JS_FN("send",js_cocos2dx_extension_WebSocket_send, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("close",js_cocos2dx_extension_WebSocket_close, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + js_cocos2dx_websocket_prototype = JS_InitClass( + cx, global, + NULL, + js_cocos2dx_websocket_class, + js_cocos2dx_extension_WebSocket_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + + JSObject* jsclassObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return WebSocket; })()")); + + JS_DefineProperty(cx, jsclassObj, "CONNECTING", INT_TO_JSVAL((int)WebSocket::State::CONNECTING) + , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); + JS_DefineProperty(cx, jsclassObj, "OPEN", INT_TO_JSVAL((int)WebSocket::State::OPEN) + , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); + JS_DefineProperty(cx, jsclassObj, "CLOSING", INT_TO_JSVAL((int)WebSocket::State::CLOSING) + , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); + JS_DefineProperty(cx, jsclassObj, "CLOSED", INT_TO_JSVAL((int)WebSocket::State::CLOSED) + , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); + + // make the class enumerable in the registered namespace + JSBool found; + JS_SetPropertyAttributes(cx, global, "WebSocket", JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + + diff --git a/cocos/scripting/javascript/bindings/network/jsb_websocket.h b/cocos/scripting/javascript/bindings/network/jsb_websocket.h new file mode 100644 index 0000000000..cde0f40b2e --- /dev/null +++ b/cocos/scripting/javascript/bindings/network/jsb_websocket.h @@ -0,0 +1,34 @@ +/**************************************************************************** +Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013 James Chen + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#ifndef __jsb_websocket__ +#define __jsb_websocket__ + +#include "jsapi.h" +#include "jsfriendapi.h" + +void register_jsb_websocket(JSContext* cx, JSObject* global); + +#endif /* defined(__jsb_websocket__) */ diff --git a/cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj b/cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj new file mode 100644 index 0000000000..e4ff3eed4b --- /dev/null +++ b/cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj @@ -0,0 +1,115 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + {3BEC13F5-E227-4D80-BC77-1C857F83BCFC} + Win32Proj + libJSBindingForNetwork + + + + StaticLibrary + true + Unicode + v100 + v110 + v110_xp + + + StaticLibrary + false + Unicode + v100 + v110 + v110_xp + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + + + + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\network;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\websockets\include\win32;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + false + + + Windows + true + + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\network;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\websockets\include\win32;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + + + Windows + true + true + true + + + + + + + + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj.filters b/cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj.filters new file mode 100644 index 0000000000..3fd3c5a5d1 --- /dev/null +++ b/cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj.filters @@ -0,0 +1,29 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + manual + + + manual + + + + + manual + + + manual + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj.user b/cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj.user new file mode 100644 index 0000000000..3f03091124 --- /dev/null +++ b/cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj.user @@ -0,0 +1,6 @@ + + + + false + + \ No newline at end of file diff --git a/cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj b/cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj new file mode 100644 index 0000000000..d79eb7ce1c --- /dev/null +++ b/cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj @@ -0,0 +1,93 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A} + libLocalStorage + + + + StaticLibrary + true + v110_xp + Unicode + + + StaticLibrary + false + v110_xp + true + Unicode + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + + Level3 + Disabled + + + $(EngineRoot)external\sqlite3\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + 4267;4251;4244;%(DisableSpecificWarnings) + false + + + true + + + + + Level3 + MaxSpeed + true + true + + + $(EngineRoot)external\sqlite3\include;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + true + true + + + + + + \ No newline at end of file diff --git a/cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj.filters b/cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj.filters new file mode 100644 index 0000000000..b23d606b74 --- /dev/null +++ b/cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj.filters @@ -0,0 +1,21 @@ + + + + + {0310200c-b520-4f77-85f6-46f568b10f4d} + + + {69cfa37c-4b20-409e-ad74-a26314878d8a} + + + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj.user b/cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj.user new file mode 100644 index 0000000000..a375ae3527 --- /dev/null +++ b/cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From e99b80b304348f3a944268d3ff58720a6f82f70d Mon Sep 17 00:00:00 2001 From: boyu0 Date: Mon, 21 Oct 2013 23:16:21 +0800 Subject: [PATCH 32/48] issue #2771: implements rayCast and rectQuery --- cocos/physics/CCPhysicsBody.cpp | 8 +- cocos/physics/CCPhysicsBody.h | 2 +- cocos/physics/CCPhysicsContact.h | 13 ++- cocos/physics/CCPhysicsWorld.cpp | 136 +++++++++++++++++++---- cocos/physics/CCPhysicsWorld.h | 42 ++++--- cocos/physics/chipmunk/CCPhysicsHelper.h | 2 + 6 files changed, 155 insertions(+), 48 deletions(-) diff --git a/cocos/physics/CCPhysicsBody.cpp b/cocos/physics/CCPhysicsBody.cpp index 8f1e9e5c1d..22a0010cbe 100644 --- a/cocos/physics/CCPhysicsBody.cpp +++ b/cocos/physics/CCPhysicsBody.cpp @@ -77,6 +77,9 @@ PhysicsBody::PhysicsBody() , _linearDamping(0.0f) , _angularDamping(0.0f) , _tag(0) +, _categoryBitmask(UINT_MAX) +, _collisionBitmask(UINT_MAX) +, _contactTestBitmask(0) { } @@ -109,11 +112,6 @@ PhysicsBody* PhysicsBody::create() return nullptr; } -void update(float delta) -{ - -} - PhysicsBody* PhysicsBody::createCircle(float radius, PhysicsMaterial material) { PhysicsBody* body = new PhysicsBody(); diff --git a/cocos/physics/CCPhysicsBody.h b/cocos/physics/CCPhysicsBody.h index 72cad042bc..65d9f7318a 100644 --- a/cocos/physics/CCPhysicsBody.h +++ b/cocos/physics/CCPhysicsBody.h @@ -276,8 +276,8 @@ protected: int _tag; int _categoryBitmask; - int _contactTestBitmask; int _collisionBitmask; + int _contactTestBitmask; friend class PhysicsWorld; friend class PhysicsShape; diff --git a/cocos/physics/CCPhysicsContact.h b/cocos/physics/CCPhysicsContact.h index 3f2ef8659c..9b9e3044c0 100644 --- a/cocos/physics/CCPhysicsContact.h +++ b/cocos/physics/CCPhysicsContact.h @@ -80,6 +80,7 @@ private: bool _notify; friend class PhysicsWorld; + friend class PhysicsWorldCallback; }; /* @@ -94,7 +95,7 @@ private: static PhysicsContactPreSolve* create(); bool init(); - friend class PhysicsWorld; + friend class PhysicsWorldCallback; }; /* @@ -109,7 +110,7 @@ private: static PhysicsContactPostSolve* create(); bool init(); - friend class PhysicsWorld; + friend class PhysicsWorldCallback; }; /* @@ -125,20 +126,20 @@ public: /* * @brief it will called at two shapes start to contact, and only call it once. */ - std::function onContactBegin; + std::function onContactBegin; /* * @brief Two shapes are touching during this step. Return false from the callback to make world ignore the collision this step or true to process it normally. Additionally, you may override collision values, elasticity, or surface velocity values. */ - std::function onContactPreSolve; + std::function onContactPreSolve; /* * @brief Two shapes are touching and their collision response has been processed. You can retrieve the collision impulse or kinetic energy at this time if you want to use it to calculate sound volumes or damage amounts. See cpArbiter for more info */ - std::function onContactPostSolve; + std::function onContactPostSolve; /* * @brief it will called at two shapes separated, and only call it once. * onContactBegin and onContactEnd will called in pairs. */ - std::function onContactEnd; + std::function onContactEnd; }; NS_CC_END diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index 30939dc9fd..6ca256bc67 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -60,12 +60,45 @@ NS_CC_BEGIN #if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +namespace +{ + typedef struct RayCastCallbackInfo + { + PhysicsWorld* world; + PhysicsRayCastCallback* callback; + Point p1; + Point p2; + void* data; + }RayCastCallbackInfo; + + typedef struct RectQueryCallbackInfo + { + PhysicsWorld* world; + PhysicsRectQueryCallback* callback; + void* data; + }RectQueryCallbackInfo; +} + +class PhysicsWorldCallback +{ +public: + static int collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *space, PhysicsWorld *world); + static int collisionPreSolveCallbackFunc(cpArbiter *arb, cpSpace *space, PhysicsWorld *world); + static void collisionPostSolveCallbackFunc(cpArbiter *arb, cpSpace *space, PhysicsWorld *world); + static void collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, PhysicsWorld *world); + static void rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect n, RayCastCallbackInfo *info); + static void rectQueryCallbackFunc(cpShape *shape, RectQueryCallbackInfo *info); + +private: + static bool continues; +}; + +bool PhysicsWorldCallback::continues = true; + const float PHYSICS_INFINITY = INFINITY; -int PhysicsWorld::collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *space, void *data) +int PhysicsWorldCallback::collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *space, PhysicsWorld *world) { - PhysicsWorld* world = static_cast(data); - CP_ARBITER_GET_SHAPES(arb, a, b); auto ita = PhysicsShapeInfo::map.find(a); @@ -78,23 +111,20 @@ int PhysicsWorld::collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *spa return world->collisionBeginCallback(*static_cast(arb->data)); } -int PhysicsWorld::collisionPreSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data) +int PhysicsWorldCallback::collisionPreSolveCallbackFunc(cpArbiter *arb, cpSpace *space, PhysicsWorld *world) { - PhysicsWorld* world = static_cast(data); return world->collisionPreSolveCallback(*static_cast(arb->data), PhysicsContactPreSolve()); } -void PhysicsWorld::collisionPostSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data) +void PhysicsWorldCallback::collisionPostSolveCallbackFunc(cpArbiter *arb, cpSpace *space, PhysicsWorld *world) { - PhysicsWorld* world = static_cast(data); world->collisionPostSolveCallback(*static_cast(arb->data), PhysicsContactPostSolve()); } -void PhysicsWorld::collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, void *data) +void PhysicsWorldCallback::collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, PhysicsWorld *world) { - PhysicsWorld* world = static_cast(data); PhysicsContact* contact = static_cast(arb->data); world->collisionSeparateCallback(*contact); @@ -102,6 +132,40 @@ void PhysicsWorld::collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, delete contact; } +void PhysicsWorldCallback::rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect n, RayCastCallbackInfo *info) +{ + if (!PhysicsWorldCallback::continues) + { + return; + } + + auto it = PhysicsShapeInfo::map.find(shape); + CC_ASSERT(it != PhysicsShapeInfo::map.end()); + + PhysicsWorldCallback::continues = info->callback->report(*info->world, + *it->second->shape, + Point(info->p1.x+(info->p2.x-info->p1.x)*t, info->p1.y+(info->p2.y-info->p1.y)*t), + Point(n.x, n.y), + (float)t, + info->data); +} + +void PhysicsWorldCallback::rectQueryCallbackFunc(cpShape *shape, RectQueryCallbackInfo *info) +{ + auto it = PhysicsShapeInfo::map.find(shape); + + CC_ASSERT(it != PhysicsShapeInfo::map.end()); + + if (!PhysicsWorldCallback::continues) + { + return; + } + + PhysicsWorldCallback::continues = info->callback->report(*info->world, + *it->second->shape, + info->data); +} + bool PhysicsWorld::init() { _info = new PhysicsWorldInfo(); @@ -109,10 +173,10 @@ bool PhysicsWorld::init() cpSpaceSetGravity(_info->space, PhysicsHelper::point2cpv(_gravity)); cpSpaceSetDefaultCollisionHandler(_info->space, - PhysicsWorld::collisionBeginCallbackFunc, - PhysicsWorld::collisionPreSolveCallbackFunc, - PhysicsWorld::collisionPostSolveCallbackFunc, - PhysicsWorld::collisionSeparateCallbackFunc, + (cpCollisionBeginFunc)PhysicsWorldCallback::collisionBeginCallbackFunc, + (cpCollisionPreSolveFunc)PhysicsWorldCallback::collisionPreSolveCallbackFunc, + (cpCollisionPostSolveFunc)PhysicsWorldCallback::collisionPostSolveCallbackFunc, + (cpCollisionSeparateFunc)PhysicsWorldCallback::collisionSeparateCallbackFunc, this); return true; @@ -368,12 +432,14 @@ int PhysicsWorld::collisionBeginCallback(PhysicsContact& contact) PhysicsBody* bodyA = contact.getShapeA()->getBody(); PhysicsBody* bodyB = contact.getShapeB()->getBody(); - if ((bodyA->getCategoryBitmask() & bodyB->getContactTestBitmask()) == 0) + if ((bodyA->getCategoryBitmask() & bodyB->getContactTestBitmask()) == 0 + || (bodyB->getContactTestBitmask() & bodyA->getCategoryBitmask()) == 0) { contact.setNotify(false); } - if ((bodyA->getCategoryBitmask() & bodyB->getCollisionBitmask()) == 0) + if ((bodyA->getCategoryBitmask() & bodyB->getCollisionBitmask()) == 0 + || (bodyB->getCategoryBitmask() & bodyA->getCollisionBitmask()) == 0) { ret = false; } @@ -384,10 +450,10 @@ int PhysicsWorld::collisionBeginCallback(PhysicsContact& contact) // so if the mask test is false, the two bodies won't have collision. if (ret) { - ret = _listener->onContactBegin(contact); + ret = _listener->onContactBegin(*this, contact); }else { - _listener->onContactBegin(contact); + _listener->onContactBegin(*this, contact); } } @@ -403,7 +469,7 @@ int PhysicsWorld::collisionPreSolveCallback(PhysicsContact& contact, const Physi if (_listener && _listener->onContactPreSolve) { - return _listener->onContactPreSolve(contact, solve); + return _listener->onContactPreSolve(*this, contact, solve); } return true; @@ -418,7 +484,7 @@ void PhysicsWorld::collisionPostSolveCallback(PhysicsContact& contact, const Phy if (_listener && _listener->onContactPreSolve) { - _listener->onContactPostSolve(contact, solve); + _listener->onContactPostSolve(*this, contact, solve); } } @@ -431,7 +497,7 @@ void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact) if (_listener && _listener->onContactEnd) { - _listener->onContactEnd(contact); + _listener->onContactEnd(*this, contact); } } @@ -456,6 +522,36 @@ void PhysicsWorld::setGravity(Point gravity) cpSpaceSetGravity(_info->space, PhysicsHelper::point2cpv(gravity)); } + +void PhysicsWorld::rayCast(PhysicsRayCastCallback& callback, Point point1, Point point2, void* data) +{ + RayCastCallbackInfo info = {this, &callback, point1, point2, data}; + cpSpaceSegmentQuery(this->_info->space, + PhysicsHelper::point2cpv(point1), + PhysicsHelper::point2cpv(point2), + CP_ALL_LAYERS, + CP_NO_GROUP, + (cpSpaceSegmentQueryFunc)PhysicsWorldCallback::rayCastCallbackFunc, + &info); +} + + +void PhysicsWorld::rectQuery(PhysicsRectQueryCallback& callback, Rect rect, void* data) +{ + RectQueryCallbackInfo info = {this, &callback, data}; + cpSpaceBBQuery(this->_info->space, + PhysicsHelper::rect2cpbb(rect), + CP_ALL_LAYERS, + CP_NO_GROUP, + (cpSpaceBBQueryFunc)PhysicsWorldCallback::rectQueryCallbackFunc, + &info); +} + +Array* PhysicsWorld::getAllBody() const +{ + return _bodys; +} + #elif (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) #endif diff --git a/cocos/physics/CCPhysicsWorld.h b/cocos/physics/CCPhysicsWorld.h index 3247ab5221..fa6a509dfc 100644 --- a/cocos/physics/CCPhysicsWorld.h +++ b/cocos/physics/CCPhysicsWorld.h @@ -33,12 +33,6 @@ #include "CCObject.h" #include "CCGeometry.h" - -#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) -typedef struct cpArbiter cpArbiter; -typedef struct cpSpace cpSpace; -#endif - NS_CC_BEGIN class PhysicsBody; @@ -55,6 +49,29 @@ class Sprite; class Scene; class DrawNode; +class PhysicsWorld; +class PhysicsRayCastCallback +{ +public: + /** + * @brief Called for each fixture found in the query. You control how the ray cast + * proceeds by returning a float: + * return true: continue + * return false: terminate the ray cast + * @param fixture the fixture hit by the ray + * @param point the point of initial intersection + * @param normal the normal vector at the point of intersection + * @return true to continue, false to terminate + */ + std::function report; +}; + +class PhysicsRectQueryCallback +{ +public: + std::function report; +}; + /** * @brief An PhysicsWorld object simulates collisions and other physical properties. You do not create PhysicsWorld objects directly; instead, you can get it from an Scene object. */ @@ -68,9 +85,8 @@ public: /** Remove all joints from the physics world.*/ void removeAllJoints(); - Array* getBodysAlongRay(Point start, Point end) const; - Array* getBodysAtPoint(Point point) const; - Array* getBodysInRect(Rect rect) const; + void rayCast(PhysicsRayCastCallback& callback, Point point1, Point point2, void* data); + void rectQuery(PhysicsRectQueryCallback& callback, Rect rect, void* data); Array* getAllBody() const; /** Register a listener to receive contact callbacks*/ @@ -111,13 +127,6 @@ protected: virtual void collisionPostSolveCallback(PhysicsContact& contact, const PhysicsContactPostSolve& solve); virtual void collisionSeparateCallback(PhysicsContact& contact); -#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) - static int collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *space, void *data); - static int collisionPreSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data); - static void collisionPostSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data); - static void collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, void *data); -#endif - protected: Point _gravity; float _speed; @@ -140,6 +149,7 @@ protected: friend class Scene; friend class PhysicsBody; friend class PhysicsShape; + friend class PhysicsWorldCallback; }; NS_CC_END diff --git a/cocos/physics/chipmunk/CCPhysicsHelper.h b/cocos/physics/chipmunk/CCPhysicsHelper.h index 337bb1a1df..bf6f6d14db 100644 --- a/cocos/physics/chipmunk/CCPhysicsHelper.h +++ b/cocos/physics/chipmunk/CCPhysicsHelper.h @@ -43,6 +43,8 @@ public: static cpVect size2cpv(const Size& size) { return cpv(size.width, size.height); } 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 Point* cpvs2points(const cpVect* cpvs, Point* points, int count) { From b56a9962a6f4334856bb79792244094255014944 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 22 Oct 2013 15:32:44 +0800 Subject: [PATCH 33/48] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 62169acdf3..b1708fabda 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [FIX] Fixed a memory leak in ScriptingCore::runScript() [FIX] sys.localStorage.getItem() does not support non-ascii string. [FIX] cc.Scheduler.schedule(target, func) without repeat argument couldn't repeat schedule forever on device. + [FIX] CCBReader can't play sequence automatically in JSB. [Lua Binding] [NEW] Added Armature lua binding and added test samples. From 7ef5bd81109facaeadc5cc2d1f639e5b9fedfc7c Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 22 Oct 2013 15:34:32 +0800 Subject: [PATCH 34/48] Update AUTHORS --- AUTHORS | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 71cba826b3..f416e6c39f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -622,7 +622,10 @@ Developers: lettas A fix for multi-platform template. - + + HoGarfield (garfield_ho) + Fixed a bug that CCBReader can't play sequence automatically in JSB. + Retired Core Developers: WenSheng Yang Author of windows port, CCTextField, From 55d45081f68833473851617adce8d382ee30ed83 Mon Sep 17 00:00:00 2001 From: garfield_ho Date: Tue, 22 Oct 2013 15:41:43 +0800 Subject: [PATCH 35/48] Fixed name --- cocos/scripting/javascript/script/jsb_cocos2d.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos/scripting/javascript/script/jsb_cocos2d.js b/cocos/scripting/javascript/script/jsb_cocos2d.js index 6ed7e19cba..684eb386d9 100644 --- a/cocos/scripting/javascript/script/jsb_cocos2d.js +++ b/cocos/scripting/javascript/script/jsb_cocos2d.js @@ -7,10 +7,10 @@ var cc = cc || {}; cc.RESOLUTION_POLICY = { // The entire application is visible in the specified area without trying to preserve the original aspect ratio. // Distortion can occur, and the application may appear stretched or compressed. -EXACTFIT:0, +EXACT_FIT:0, // The entire application fills the specified area, without distortion but possibly with some cropping, // while maintaining the original aspect ratio of the application. -NOBORDER:1, +NO_BORDER:1, // The entire application is visible in the specified area without distortion while maintaining the original // aspect ratio of the application. Borders can appear on two sides of the application. SHOW_ALL:2, @@ -18,12 +18,12 @@ SHOW_ALL:2, // canvas so that it fits the aspect ratio of the device // no distortion will occur however you must make sure your application works on different // aspect ratios -HEIGHT:3, +FIXED_HEIGHT:3, // The application takes the width of the design resolution size and modifies the height of the internal // canvas so that it fits the aspect ratio of the device // no distortion will occur however you must make sure your application works on different // aspect ratios -WIDTH:4, +FIXED_WIDTH:4, UNKNOWN:5 }; From 31a2217178825e622d73f9f79e326041b3614ee1 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Tue, 22 Oct 2013 15:56:08 +0800 Subject: [PATCH 36/48] issues #2905:add miss file --- cocos/2d/cocos2d_headers.props | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 cocos/2d/cocos2d_headers.props diff --git a/cocos/2d/cocos2d_headers.props b/cocos/2d/cocos2d_headers.props new file mode 100644 index 0000000000..a5d8616d03 --- /dev/null +++ b/cocos/2d/cocos2d_headers.props @@ -0,0 +1,19 @@ + + + + + $(MSBuildThisFileDirectory)..\..\ + + + + + $(EngineRoot)cocos\2d;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath\include;$(EngineRoot)cocos\2d\platform\win32;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES; + + + + + $(EngineRoot) + true + + + \ No newline at end of file From 0002815acb3e276bb9a8d5b0860ec5e6459a640c Mon Sep 17 00:00:00 2001 From: garfield_ho Date: Tue, 22 Oct 2013 15:56:35 +0800 Subject: [PATCH 37/48] Modify the sequenceCompleted method in CCBAnimationManager,So it can set the next sequence in callback --- .../cocosbuilder/CCBAnimationManager.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp index 13b039dcac..0ca75e25ce 100644 --- a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp +++ b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp @@ -910,6 +910,11 @@ void CCBAnimationManager::sequenceCompleted() _lastCompletedSequenceName = runningSequenceName; } + if (nextSeqId != -1) + { + runAnimationsForSequenceIdTweenDuration(nextSeqId, 0); + } + if (_delegate) { // There may be another runAnimation() call in this delegate method @@ -920,11 +925,6 @@ void CCBAnimationManager::sequenceCompleted() if (_target && _animationCompleteCallbackFunc) { (_target->*_animationCompleteCallbackFunc)(); } - - if (nextSeqId != -1) - { - runAnimationsForSequenceIdTweenDuration(nextSeqId, 0); - } } // Custom actions From 7a1b6f2972939741b79248b8e605803dbc846f02 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 22 Oct 2013 16:33:41 +0800 Subject: [PATCH 38/48] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index b1708fabda..7b81c3c5f9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [FIX] removeSpriteFramesFromFile() crashes if file doesn't exist. [FIX] Avoid unnecessary object duplication for Scale9Sprite. [FIX] create_project.py does not rename/replace template projects completely. + [FIX] Could not set next animation in CCBAnimationCompleted callback. [Android] [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [NEW] Added Cocos2dxHelper.runOnGLThread(Runnable) again From c47d2b7ae287dc61137594c3eaaca2ccccb53182 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 22 Oct 2013 16:34:10 +0800 Subject: [PATCH 39/48] Update AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index f416e6c39f..4dff8c12b5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -625,6 +625,7 @@ Developers: HoGarfield (garfield_ho) Fixed a bug that CCBReader can't play sequence automatically in JSB. + Could not set next animation in CCBAnimationCompleted callback. Retired Core Developers: WenSheng Yang From 24561860f0d3ea47474f7094b7c2d6596c7c18c6 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Tue, 22 Oct 2013 18:00:24 +0800 Subject: [PATCH 40/48] issue #2771: add ray cast test --- cocos/physics/CCPhysicsShape.h | 2 +- cocos/physics/CCPhysicsWorld.cpp | 58 ++-- cocos/physics/CCPhysicsWorld.h | 14 +- .../Classes/PhysicsTest/PhysicsTest.cpp | 291 +++++++++++++++++- .../TestCpp/Classes/PhysicsTest/PhysicsTest.h | 32 +- 5 files changed, 349 insertions(+), 48 deletions(-) diff --git a/cocos/physics/CCPhysicsShape.h b/cocos/physics/CCPhysicsShape.h index 4191c7e6b5..d1b5e0db04 100644 --- a/cocos/physics/CCPhysicsShape.h +++ b/cocos/physics/CCPhysicsShape.h @@ -97,7 +97,7 @@ public: virtual Point getOffset() { return Point::ZERO; } virtual Point getCenter() { return getOffset(); } - static Point* recenterPoints(Point* points, int count, Point center); + static Point* recenterPoints(Point* points, int count, Point center = Point::ZERO); static Point getPolyonCenter(Point* points, int count); protected: diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index 6ca256bc67..cab183ba7a 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -89,7 +89,7 @@ public: static void rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect n, RayCastCallbackInfo *info); static void rectQueryCallbackFunc(cpShape *shape, RectQueryCallbackInfo *info); -private: +public: static bool continues; }; @@ -391,12 +391,16 @@ void PhysicsWorld::drawWithShape(DrawNode* node, PhysicsShape* shape) Point centre = PhysicsHelper::cpv2point(cpBodyGetPos(cpShapeGetBody(shape))) + PhysicsHelper::cpv2point(cpCircleShapeGetOffset(shape)); - Point seg[4] = {}; - seg[0] = Point(centre.x - radius, centre.y - radius); - seg[1] = Point(centre.x - radius, centre.y + radius); - seg[2] = Point(centre.x + radius, centre.y + radius); - seg[3] = Point(centre.x + radius, centre.y - radius); - node->drawPolygon(seg, 4, Color4F(), 1, Color4F(1, 0, 0, 1)); + static const int CIRCLE_SEG_NUM = 12; + Point seg[CIRCLE_SEG_NUM] = {}; + + for (int i = 0; i < CIRCLE_SEG_NUM; ++i) + { + float angle = (float)i * M_PI / (float)CIRCLE_SEG_NUM * 2.0f; + Point d(radius * cosf(angle), radius * sinf(angle)); + seg[i] = centre + d; + } + node->drawPolygon(seg, CIRCLE_SEG_NUM, Color4F(1.0f, 0.0f, 0.0f, 0.3f), 1, Color4F(1, 0, 0, 1)); break; } case CP_SEGMENT_SHAPE: @@ -525,26 +529,36 @@ void PhysicsWorld::setGravity(Point gravity) void PhysicsWorld::rayCast(PhysicsRayCastCallback& callback, Point point1, Point point2, void* data) { - RayCastCallbackInfo info = {this, &callback, point1, point2, data}; - cpSpaceSegmentQuery(this->_info->space, - PhysicsHelper::point2cpv(point1), - PhysicsHelper::point2cpv(point2), - CP_ALL_LAYERS, - CP_NO_GROUP, - (cpSpaceSegmentQueryFunc)PhysicsWorldCallback::rayCastCallbackFunc, - &info); + if (callback.report != nullptr) + { + RayCastCallbackInfo info = {this, &callback, point1, point2, data}; + + PhysicsWorldCallback::continues = true; + cpSpaceSegmentQuery(this->_info->space, + PhysicsHelper::point2cpv(point1), + PhysicsHelper::point2cpv(point2), + CP_ALL_LAYERS, + CP_NO_GROUP, + (cpSpaceSegmentQueryFunc)PhysicsWorldCallback::rayCastCallbackFunc, + &info); + } } void PhysicsWorld::rectQuery(PhysicsRectQueryCallback& callback, Rect rect, void* data) { - RectQueryCallbackInfo info = {this, &callback, data}; - cpSpaceBBQuery(this->_info->space, - PhysicsHelper::rect2cpbb(rect), - CP_ALL_LAYERS, - CP_NO_GROUP, - (cpSpaceBBQueryFunc)PhysicsWorldCallback::rectQueryCallbackFunc, - &info); + if (callback.report != nullptr) + { + RectQueryCallbackInfo info = {this, &callback, data}; + + PhysicsWorldCallback::continues = true; + cpSpaceBBQuery(this->_info->space, + PhysicsHelper::rect2cpbb(rect), + CP_ALL_LAYERS, + CP_NO_GROUP, + (cpSpaceBBQueryFunc)PhysicsWorldCallback::rectQueryCallbackFunc, + &info); + } } Array* PhysicsWorld::getAllBody() const diff --git a/cocos/physics/CCPhysicsWorld.h b/cocos/physics/CCPhysicsWorld.h index fa6a509dfc..e61cde2763 100644 --- a/cocos/physics/CCPhysicsWorld.h +++ b/cocos/physics/CCPhysicsWorld.h @@ -53,6 +53,10 @@ class PhysicsWorld; class PhysicsRayCastCallback { public: + PhysicsRayCastCallback() + : report(nullptr) + {} + virtual ~PhysicsRayCastCallback(){} /** * @brief Called for each fixture found in the query. You control how the ray cast * proceeds by returning a float: @@ -63,13 +67,19 @@ public: * @param normal the normal vector at the point of intersection * @return true to continue, false to terminate */ - std::function report; + std::function report; }; class PhysicsRectQueryCallback { public: - std::function report; + PhysicsRectQueryCallback() + : report(nullptr) + {} + virtual ~PhysicsRectQueryCallback(){} + +public: + std::function report; }; /** diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index 91c67da54d..0c67ddc204 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -9,6 +9,7 @@ namespace CL(PhysicsDemoPyramidStack), CL(PhysicsDemoPlink), CL(PhysicsDemoClickAdd), + CL(PhysicsDemoRayCast), }; static int sceneIdx=-1; @@ -48,6 +49,8 @@ namespace return layer; } + + static const Color4F STATIC_COLOR = {1.0f, 0.0f, 0.0f, 1.0f}; } @@ -87,6 +90,8 @@ void PhysicsTestScene::toggleDebug() PhysicsDemo::PhysicsDemo() : _scene(nullptr) +, _ball(nullptr) +, _spriteTexture(nullptr) { } @@ -304,22 +309,62 @@ namespace } } -Node* PhysicsDemoLogoSmash::makeBall(float x, float y) +Sprite* PhysicsDemo::makeBall(float x, float y, float radius, PhysicsMaterial material) { - auto ball = Sprite::createWithTexture(_ball->getTexture()); - ball->setScale(0.1); + Sprite* ball = nullptr; + if (_ball != nullptr) + { + ball = Sprite::createWithTexture(_ball->getTexture()); + }else + { + ball = Sprite::create("Images/ball.png"); + } - auto body = PhysicsBody::createCircle(0.95, PhysicsMaterial(1, 0, 0)); - body->setMass(1.0); - body->setMoment(PHYSICS_INFINITY); + ball->setScale(0.13f * radius); + auto body = PhysicsBody::createCircle(radius, material); ball->setPhysicsBody(body); - ball->setPosition(Point(x, y)); return ball; } +Sprite* PhysicsDemo::makeBox(float x, float y, Size size, PhysicsMaterial material) +{ + auto box = CCRANDOM_0_1() > 0.5f ? Sprite::create("Images/YellowSquare.png") : Sprite::create("Images/CyanSquare.png"); + + box->setScaleX(size.width/100.0f); + box->setScaleY(size.height/100.0f); + + auto body = PhysicsBody::createBox(size); + box->setPhysicsBody(body); + box->setPosition(Point(x, y)); + + return box; +} + +Sprite* PhysicsDemo::makeTriangle(float x, float y, Size size, PhysicsMaterial material) +{ + auto triangle = CCRANDOM_0_1() > 0.5f ? Sprite::create("Images/YellowTriangle.png") : Sprite::create("Images/CyanTriangle.png"); + + if(size.height == 0) + { + triangle->setScale(size.width/100.0f); + }else + { + triangle->setScaleX(size.width/50.0f); + triangle->setScaleY(size.height/43.5f); + } + + Point vers[] = { Point(0, size.height/2), Point(size.width/2, -size.height/2), Point(-size.width/2, -size.height/2)}; + + auto body = PhysicsBody::createPolygon(vers, 3); + triangle->setPhysicsBody(body); + triangle->setPosition(Point(x, y)); + + return triangle; +} + void PhysicsDemoLogoSmash::onEnter() { PhysicsDemo::onEnter(); @@ -337,19 +382,22 @@ void PhysicsDemoLogoSmash::onEnter() float x_jitter = 0.05*frand(); float y_jitter = 0.05*frand(); - _ball->addChild(makeBall(2*(x - logo_width/2 + x_jitter) + VisibleRect::getVisibleRect().size.width/2, - 2*(logo_height-y + y_jitter) + VisibleRect::getVisibleRect().size.height/2 - logo_height/2)); + Node* ball = makeBall(2*(x - logo_width/2 + x_jitter) + VisibleRect::getVisibleRect().size.width/2, + 2*(logo_height-y + y_jitter) + VisibleRect::getVisibleRect().size.height/2 - logo_height/2, + 0.95f, PhysicsMaterial(1.0f, 0.0f, 0.0f)); + + ball->getPhysicsBody()->setMass(1.0); + ball->getPhysicsBody()->setMoment(PHYSICS_INFINITY); + + _ball->addChild(ball); + } } } - auto bullet = Sprite::createWithTexture(_ball->getTexture()); - bullet->setScale(0.5); - - auto body = PhysicsBody::createCircle(8, PhysicsMaterial(PHYSICS_INFINITY, 0, 0)); - body->setVelocity(Point(400, 0)); - bullet->setPhysicsBody(body); + auto bullet = makeBall(400, 0, 10, PhysicsMaterial(PHYSICS_INFINITY, 0, 0)); + bullet->getPhysicsBody()->setVelocity(Point(400, 0)); bullet->setPosition(Point(-1000, VisibleRect::getVisibleRect().size.height/2)); @@ -393,7 +441,7 @@ void PhysicsDemoPlink::onEnter() { PhysicsDemo::onEnter(); - auto node = Node::create(); + auto node = DrawNode::create(); auto body = PhysicsBody::create(); body->setDynamic(false); node->setPhysicsBody(body); @@ -405,7 +453,11 @@ void PhysicsDemoPlink::onEnter() { for (int j = 0; j < 4; ++j) { - body->addShape(PhysicsShapePolygon::create(tris, 3, PHYSICSSHAPE_MATERIAL_DEFAULT, Point(rect.origin.x + rect.size.width/9*i + (j%2)*40 - 20, rect.origin.y + j*70))); + Point offset(rect.origin.x + rect.size.width/9*i + (j%2)*40 - 20, rect.origin.y + j*70); + body->addShape(PhysicsShapePolygon::create(tris, 3, PHYSICSSHAPE_MATERIAL_DEFAULT, offset)); + + Point drawVec[] = {tris[0] + offset, tris[1] + offset, tris[2] + offset}; + node->drawPolygon(drawVec, 3, STATIC_COLOR, 1, STATIC_COLOR); } } @@ -416,4 +468,209 @@ void PhysicsDemoPlink::onEnter() std::string PhysicsDemoPlink::title() { return "Plink"; +} + +PhysicsDemoRayCast::PhysicsDemoRayCast() +: _angle(0.0f) +, _node(nullptr) +, _mode(0) +{} + +void PhysicsDemoRayCast::onEnter() +{ + PhysicsDemo::onEnter(); + setTouchEnabled(true); + + _scene->getPhysicsWorld()->setGravity(Point::ZERO); + + auto node = DrawNode::create(); + node->setPhysicsBody(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Point(0, 50), VisibleRect::rightBottom() + Point(0, 50))); + node->drawSegment(VisibleRect::leftBottom() + Point(0, 50), VisibleRect::rightBottom() + Point(0, 50), 1, STATIC_COLOR); + this->addChild(node); + + MenuItemFont::setFontSize(18); + auto item = MenuItemFont::create("Change Mode(any)", CC_CALLBACK_1(PhysicsDemoRayCast::changeModeCallback, this)); + + auto menu = Menu::create(item, NULL); + this->addChild(menu); + menu->setPosition(Point(VisibleRect::left().x+100, VisibleRect::top().y-10)); + + scheduleUpdate(); +} + +void PhysicsDemoRayCast::changeModeCallback(Object* sender) +{ + _mode = (_mode + 1) % 3; + + switch (_mode) + { + case 0: + ((MenuItemFont*)sender)->setString("Change Mode(any)"); + break; + case 1: + ((MenuItemFont*)sender)->setString("Change Mode(nearest)"); + break; + case 2: + ((MenuItemFont*)sender)->setString("Change Mode(multiple)"); + break; + + default: + break; + } +} + +bool PhysicsDemoRayCast::anyRay(PhysicsWorld& world, PhysicsShape& shape, Point point, Point normal, float fraction, void* data) +{ + *((Point*)data) = point; + return false; +} + +class PhysicsDemoNearestRayCastCallback : public PhysicsRayCastCallback +{ +public: + PhysicsDemoNearestRayCastCallback(); + +private: + float _friction; +}; + +PhysicsDemoNearestRayCastCallback::PhysicsDemoNearestRayCastCallback() +: _friction(1.0f) +{ + report = [this](PhysicsWorld& world, PhysicsShape& shape, Point point, Point normal, float fraction, void* data)->bool + { + if (_friction > fraction) + { + *((Point*)data) = point; + _friction = fraction; + } + + return true; + }; +} + +namespace +{ + static const int MAX_MULTI_RAYCAST_NUM = 5; +} + +class PhysicsDemoMultiRayCastCallback : public PhysicsRayCastCallback +{ +public: + PhysicsDemoMultiRayCastCallback(); + +public: + Point points[MAX_MULTI_RAYCAST_NUM]; + int num; +}; + +PhysicsDemoMultiRayCastCallback::PhysicsDemoMultiRayCastCallback() +: num(0) +{ + report = [this](PhysicsWorld& world, PhysicsShape& shape, Point point, Point normal, float fraction, void* data)->bool + { + if (num < MAX_MULTI_RAYCAST_NUM) + { + points[num++] = point; + } + + return true; + }; +} + +void PhysicsDemoRayCast::update(float delta) +{ + float L = 150.0f; + Point point1 = VisibleRect::center(); + Point d(L * cosf(_angle), L * sinf(_angle)); + Point point2 = point1 + d; + + removeChild(_node); + _node = DrawNode::create(); + switch (_mode) + { + case 0: + { + PhysicsRayCastCallback callback; + Point point3 = point2; + callback.report = anyRay; + + _scene->getPhysicsWorld()->rayCast(callback, point1, point2, &point3); + _node->drawSegment(point1, point3, 1, STATIC_COLOR); + + if (point2 != point3) + { + _node->drawDot(point3, 2, Color4F(1.0f, 1.0f, 1.0f, 1.0f)); + } + addChild(_node); + + break; + } + case 1: + { + PhysicsDemoNearestRayCastCallback callback; + Point point3 = point2; + + _scene->getPhysicsWorld()->rayCast(callback, point1, point2, &point3); + _node->drawSegment(point1, point3, 1, STATIC_COLOR); + + if (point2 != point3) + { + _node->drawDot(point3, 2, Color4F(1.0f, 1.0f, 1.0f, 1.0f)); + } + addChild(_node); + + break; + } + case 2: + { + PhysicsDemoMultiRayCastCallback callback; + + _scene->getPhysicsWorld()->rayCast(callback, point1, point2, nullptr); + + _node->drawSegment(point1, point2, 1, STATIC_COLOR); + + for (int i = 0; i < callback.num; ++i) + { + _node->drawDot(callback.points[i], 2, Color4F(1.0f, 1.0f, 1.0f, 1.0f)); + } + + addChild(_node); + + break; + } + + default: + break; + } + + _angle += 0.25f * M_PI / 180.0f; +} + +void PhysicsDemoRayCast::onTouchesEnded(const std::vector& touches, Event* event) +{ + //Add a new body/atlas sprite at the touched location + + for( auto &touch: touches) + { + auto location = touch->getLocation(); + + float r = CCRANDOM_0_1(); + + if (r < 1.0f/3.0f) + { + addChild(makeBall(location.x, location.y, 5 + CCRANDOM_0_1()*10)); + }else if(r < 2.0f/3.0f) + { + addChild(makeBox(location.x, location.y, Size(10 + CCRANDOM_0_1()*15, 10 + CCRANDOM_0_1()*15))); + }else + { + addChild(makeTriangle(location.x, location.y, Size(10 + CCRANDOM_0_1()*20, 10 + CCRANDOM_0_1()*20))); + } + } +} + +std::string PhysicsDemoRayCast::title() +{ + return "Ray Cast"; } \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h index 34f8053b37..65c1c6bad9 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h @@ -37,9 +37,13 @@ public: void toggleDebugCallback(Object* sender); void addGrossiniAtPosition(Point p, float scale = 1.0); + Sprite* makeBall(float x, float y, float radius, PhysicsMaterial material = {1.0f, 1.0f, 1.0f}); + Sprite* makeBox(float x, float y, Size size, PhysicsMaterial material = {1.0f, 1.0f, 1.0f}); + Sprite* makeTriangle(float x, float y, Size size, PhysicsMaterial material = {1.0f, 1.0f, 1.0f}); -private: +protected: Texture2D* _spriteTexture; // weak ref + SpriteBatchNode* _ball; }; class PhysicsDemoClickAdd : public PhysicsDemo @@ -57,11 +61,6 @@ class PhysicsDemoLogoSmash : public PhysicsDemo public: void onEnter() override; std::string title() override; - - Node* makeBall(float x, float y); - -private: - SpriteBatchNode* _ball; }; class PhysicsDemoPyramidStack : public PhysicsDemo @@ -78,4 +77,25 @@ public: std::string title() override; }; +class PhysicsDemoRayCast : public PhysicsDemo +{ +public: + PhysicsDemoRayCast(); +public: + void onEnter() override; + std::string title() override; + void update(float delta) override; + + void onTouchesEnded(const std::vector& touches, Event* event) override; + + void changeModeCallback(Object* sender); + + static bool anyRay(PhysicsWorld& world, PhysicsShape& shape, Point point, Point normal, float fraction, void* data); + +private: + float _angle; + DrawNode* _node; + int _mode; +}; + #endif From 6a664d480a870c0a46c923fcd15fcdf9a3d0a9ee Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 22 Oct 2013 18:01:56 +0800 Subject: [PATCH 41/48] issue #2905:samples build ok on linux --- build/Makefile | 101 ++++--- build/install-deps-linux.sh | 2 +- cocos/2d/Makefile | 302 +++++++++++---------- cocos/2d/cocos2dx.mk | 45 +-- cocos/2d/platform/linux/CCEGLView.cpp | 2 +- cocos/2d/platform/linux/CCEGLView.h | 2 +- cocos/audio/proj.linux/Makefile | 10 +- cocos/editor-support/cocosbuilder/Makefile | 44 +++ cocos/editor-support/cocostudio/Makefile | 69 +++++ cocos/editor-support/spine/Makefile | 42 +++ cocos/gui/Layout.cpp | 4 +- cocos/gui/Makefile | 44 +++ cocos/network/Makefile | 22 ++ cocos/physics/CCPhysicsBody.cpp | 10 +- cocos/physics/CCPhysicsContact.cpp | 2 +- cocos/physics/CCPhysicsJoint.cpp | 6 +- cocos/physics/CCPhysicsShape.cpp | 6 +- cocos/physics/CCPhysicsWorld.cpp | 10 +- cocos/scripting/lua/bindings/Makefile | 126 +++++---- extensions/proj.linux/Makefile | 166 ++--------- extensions/proj.linux/extensions.prf | 20 -- external/Box2D/proj.linux/Makefile | 2 +- external/chipmunk/proj.linux/Makefile | 2 +- samples/Cpp/HelloCpp/proj.linux/Makefile | 2 +- samples/Cpp/SimpleGame/proj.linux/Makefile | 5 +- samples/Cpp/TestCpp/proj.linux/Makefile | 24 +- samples/Lua/HelloLua/proj.linux/Makefile | 18 +- samples/Lua/TestLua/proj.linux/Makefile | 16 +- 28 files changed, 615 insertions(+), 489 deletions(-) create mode 100644 cocos/editor-support/cocosbuilder/Makefile create mode 100644 cocos/editor-support/cocostudio/Makefile create mode 100644 cocos/editor-support/spine/Makefile create mode 100644 cocos/gui/Makefile create mode 100644 cocos/network/Makefile delete mode 100644 extensions/proj.linux/extensions.prf diff --git a/build/Makefile b/build/Makefile index fbea65f3cd..761855d264 100644 --- a/build/Makefile +++ b/build/Makefile @@ -3,68 +3,89 @@ PLATFORM ?= linux all: chipmunk: - $(MAKE) -C external/chipmunk/proj.$(PLATFORM) + $(MAKE) -C ../external/chipmunk/proj.$(PLATFORM) chipmunk-clean: - $(MAKE) -C external/chipmunk/proj.$(PLATFORM) clean + $(MAKE) -C ../external/chipmunk/proj.$(PLATFORM) clean box2d: - $(MAKE) -C external/Box2D/proj.$(PLATFORM) + $(MAKE) -C ../external/Box2D/proj.$(PLATFORM) box2d-clean: - $(MAKE) -C external/Box2D/proj.$(PLATFORM) clean + $(MAKE) -C ../external/Box2D/proj.$(PLATFORM) clean -libextensions: chipmunk cocosdenshion box2d - $(MAKE) -C extensions/proj.$(PLATFORM) -libextensions-clean: - $(MAKE) -C extensions/proj.$(PLATFORM) clean +cocos2dx: chipmunk + $(MAKE) -C ../cocos/2d +cocos2dx-clean: + $(MAKE) -C ../cocos/2d clean -libcocos2dx: libextensions - $(MAKE) -C cocos2dx/proj.$(PLATFORM) -libcocos2dx-clean: - $(MAKE) -C cocos2dx/proj.$(PLATFORM) clean +audio: cocos2dx + $(MAKE) -C ../cocos/audio/proj.$(PLATFORM) +audio-clean: + $(MAKE) -C ../cocos/audio/proj.$(PLATFORM) clean -cocosdenshion: libcocos2dx - $(MAKE) -C audio/proj.$(PLATFORM) -cocosdenshion-clean: - $(MAKE) -C audio/proj.$(PLATFORM) clean +gui: + $(MAKE) -C ../cocos/gui +gui-clean: + $(MAKE) -C ../cocos/gui clean -lua: libextensions - $(MAKE) -C scripting/lua/proj.$(PLATFORM) +network: cocos2dx + $(MAKE) -C ../cocos/network +network-clean: + $(MAKE) -C ../cocos/network clean + +cocosbuilder: + $(MAKE) -C ../cocos/editor-support/cocosbuilder +cocosbuilder-clean: + $(MAKE) -C ../cocos/editor-support/cocosbuilder clean + +spine: + $(MAKE) -C ../cocos/editor-support/spine +spine-clean: + $(MAKE) -C ../cocos/editor-support/spine clean + +cocostudio: + $(MAKE) -C ../cocos/editor-support/cocostudio +cocostudio-clean: + $(MAKE) -C ../cocos/editor-support/cocostudio clean + +extensions: chipmunk audio box2d + $(MAKE) -C ../extensions/proj.$(PLATFORM) +extensions-clean: + $(MAKE) -C ../extensions/proj.$(PLATFORM) clean + +lua: extensions cocosbuilder cocostudio + $(MAKE) -C ../cocos/scripting/lua/bindings lua-clean: - $(MAKE) -C scripting/lua/proj.$(PLATFORM) clean + $(MAKE) -C ../cocos/scripting/lua/bindings clean -hellocpp: libcocos2dx - $(MAKE) -C samples/Cpp/HelloCpp/proj.$(PLATFORM) +hellocpp: cocos2dx + $(MAKE) -C ../samples/Cpp/HelloCpp/proj.$(PLATFORM) hellocpp-clean: - $(MAKE) -C samples/Cpp/HelloCpp/proj.$(PLATFORM) clean + $(MAKE) -C ../samples/Cpp/HelloCpp/proj.$(PLATFORM) clean -testcpp: libcocos2dx libextensions - $(MAKE) -C samples/Cpp/TestCpp/proj.$(PLATFORM) +testcpp: cocos2dx audio extensions cocostudio gui cocosbuilder spine network + $(MAKE) -C ../samples/Cpp/TestCpp/proj.$(PLATFORM) testcpp-clean: - $(MAKE) -C samples/Cpp/TestCpp/proj.$(PLATFORM) clean + $(MAKE) -C ../samples/Cpp/TestCpp/proj.$(PLATFORM) clean -simplegame: libcocos2dx - $(MAKE) -C samples/Cpp/SimpleGame/proj.$(PLATFORM) +simplegame: cocos2dx audio + $(MAKE) -C ../samples/Cpp/SimpleGame/proj.$(PLATFORM) simplegame-clean: - $(MAKE) -C samples/Cpp/SimpleGame/proj.$(PLATFORM) clean + $(MAKE) -C ../samples/Cpp/SimpleGame/proj.$(PLATFORM) clean -all: chipmunk cocosdenshion libextensions libcocos2dx lua hellocpp testcpp simplegame -clean: libcocos2dx-clean box2d-clean chipmunk-clean cocosdenshion-clean libextensions-clean lua-clean hellocpp-clean testcpp-clean simplegame-clean +all: chipmunk audio extensions cocos2dx lua hellocpp testcpp simplegame +clean: cocos2dx-clean box2d-clean chipmunk-clean audio-clean extensions-clean lua-clean hellocpp-clean testcpp-clean simplegame-clean -# Haven't yet got the lua projects working with emscripten -ifneq ($(PLATFORM),emscripten) - -hellolua: libcocos2dx lua - $(MAKE) -C samples/Lua/HelloLua/proj.$(PLATFORM) +hellolua: cocos2dx lua + $(MAKE) -C ../samples/Lua/HelloLua/proj.$(PLATFORM) hellolua-clean: - $(MAKE) -C samples/Lua/HelloLua/proj.$(PLATFORM) clean + $(MAKE) -C ../samples/Lua/HelloLua/proj.$(PLATFORM) clean -testlua: libcocos2dx lua - $(MAKE) -C samples/Lua/TestLua/proj.$(PLATFORM) +testlua: cocos2dx lua + $(MAKE) -C ../samples/Lua/TestLua/proj.$(PLATFORM) testlua-clean: - $(MAKE) -C samples/Lua/TestLua/proj.$(PLATFORM) clean + $(MAKE) -C ../samples/Lua/TestLua/proj.$(PLATFORM) clean all: hellolua testlua clean: hellolua-clean testlua-clean -endif .PHONY: all clean diff --git a/build/install-deps-linux.sh b/build/install-deps-linux.sh index f62c78a3e8..687b51926b 100755 --- a/build/install-deps-linux.sh +++ b/build/install-deps-linux.sh @@ -32,5 +32,5 @@ if [ -n "$MISSING" ]; then fi # install glfw -tools/travis-scripts/install_glfw.sh +../tools/travis-scripts/install_glfw.sh diff --git a/cocos/2d/Makefile b/cocos/2d/Makefile index fa3d1cb659..d88604b130 100644 --- a/cocos/2d/Makefile +++ b/cocos/2d/Makefile @@ -1,93 +1,83 @@ TARGET = libcocos2d.so -INCLUDES += \ - -I../platform/third_party/linux/libfreetype2 \ - -I../platform/third_party/common/etc \ - -I../platform/third_party/common/s3tc \ - -I../platform/third_party/common/atitc \ - -I../../extensions \ - -I../../extensions/CCBReader \ - -I../../extensions/GUI/CCControlExtension \ - -I../../extensions/GUI/CCControlExtension \ - -I../../external/chipmunk/include/chipmunk \ - -I../../extensions/network \ - -I../../extensions/Components +INCLUDES = -SOURCES = ../actions/CCAction.cpp \ -../actions/CCActionCamera.cpp \ -../actions/CCActionEase.cpp \ -../actions/CCActionGrid.cpp \ -../actions/CCActionGrid3D.cpp \ -../actions/CCActionInstant.cpp \ -../actions/CCActionInterval.cpp \ -../actions/CCActionManager.cpp \ -../actions/CCActionPageTurn3D.cpp \ -../actions/CCActionProgressTimer.cpp \ -../actions/CCActionTiledGrid.cpp \ -../actions/CCActionCatmullRom.cpp \ -../actions/CCActionTween.cpp \ -../base_nodes/CCAtlasNode.cpp \ -../base_nodes/CCNode.cpp \ -../cocoa/CCAffineTransform.cpp \ -../cocoa/CCAutoreleasePool.cpp \ -../cocoa/CCGeometry.cpp \ -../cocoa/CCNS.cpp \ -../cocoa/CCObject.cpp \ -../cocoa/CCSet.cpp \ -../cocoa/CCArray.cpp \ -../cocoa/CCDictionary.cpp \ -../cocoa/CCString.cpp \ -../cocoa/CCDataVisitor.cpp \ -../cocoa/CCData.cpp \ -../event_dispatcher/CCEventAcceleration.cpp \ -../event_dispatcher/CCEventListenerAcceleration.cpp \ -../event_dispatcher/CCEvent.cpp \ -../event_dispatcher/CCEventDispatcher.cpp \ -../event_dispatcher/CCEventListener.cpp \ -../event_dispatcher/CCEventKeyboard.cpp \ -../event_dispatcher/CCEventListenerKeyboard.cpp \ -../event_dispatcher/CCTouch.cpp \ -../event_dispatcher/CCEventTouch.cpp \ -../event_dispatcher/CCEventListenerTouch.cpp \ -../event_dispatcher/CCEventCustom.cpp \ -../event_dispatcher/CCEventListenerCustom.cpp \ -../draw_nodes/CCDrawingPrimitives.cpp \ -../draw_nodes/CCDrawNode.cpp \ -../effects/CCGrabber.cpp \ -../effects/CCGrid.cpp \ -../label_nodes/CCFont.cpp \ -../label_nodes/CCFontAtlas.cpp \ -../label_nodes/CCFontAtlasCache.cpp \ -../label_nodes/CCFontAtlasFactory.cpp \ -../label_nodes/CCFontDefinition.cpp \ -../label_nodes/CCFontFNT.cpp \ -../label_nodes/CCFontFreeType.cpp \ -../label_nodes/CCLabel.cpp \ -../label_nodes/CCLabelAtlas.cpp \ -../label_nodes/CCLabelBMFont.cpp \ -../label_nodes/CCLabelTTF.cpp \ -../label_nodes/CCLabelTextFormatter.cpp \ -../label_nodes/CCTextImage.cpp \ -../layers_scenes_transitions_nodes/CCLayer.cpp \ -../layers_scenes_transitions_nodes/CCScene.cpp \ -../layers_scenes_transitions_nodes/CCTransition.cpp \ -../layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp \ -../layers_scenes_transitions_nodes/CCTransitionProgress.cpp \ -../menu_nodes/CCMenu.cpp \ -../menu_nodes/CCMenuItem.cpp \ -../misc_nodes/CCMotionStreak.cpp \ -../misc_nodes/CCProgressTimer.cpp \ -../misc_nodes/CCClippingNode.cpp \ -../misc_nodes/CCRenderTexture.cpp \ -../particle_nodes/CCParticleExamples.cpp \ -../particle_nodes/CCParticleSystem.cpp \ -../particle_nodes/CCParticleSystemQuad.cpp \ -../particle_nodes/CCParticleBatchNode.cpp \ -../physics/Box2D/CCPhysicsContactInfo.cpp \ -../physics/Box2D/CCPhysicsJointInfo.cpp \ -../physics/Box2D/CCPhysicsShapeInfo.cpp \ -../physics/Box2D/CCPhysicsBodyInfo.cpp \ -../physics/Box2D/CCPhysicsWorldInfo.cpp \ +SOURCES = \ +CCAction.cpp \ +CCActionCamera.cpp \ +CCActionEase.cpp \ +CCActionGrid.cpp \ +CCActionGrid3D.cpp \ +CCActionInstant.cpp \ +CCActionInterval.cpp \ +CCActionManager.cpp \ +CCActionPageTurn3D.cpp \ +CCActionProgressTimer.cpp \ +CCActionTiledGrid.cpp \ +CCActionCatmullRom.cpp \ +CCActionTween.cpp \ +CCAtlasNode.cpp \ +CCNode.cpp \ +../base/CCAffineTransform.cpp \ +../base/CCAutoreleasePool.cpp \ +../base/CCGeometry.cpp \ +../base/CCNS.cpp \ +../base/CCObject.cpp \ +../base/CCSet.cpp \ +../base/CCArray.cpp \ +../base/CCDictionary.cpp \ +../base/CCString.cpp \ +../base/CCDataVisitor.cpp \ +../base/CCData.cpp \ +CCEventAcceleration.cpp \ +CCEventListenerAcceleration.cpp \ +CCEvent.cpp \ +CCEventDispatcher.cpp \ +CCEventListener.cpp \ +CCEventKeyboard.cpp \ +CCEventListenerKeyboard.cpp \ +CCTouch.cpp \ +CCEventTouch.cpp \ +CCEventListenerTouch.cpp \ +CCEventCustom.cpp \ +CCEventListenerCustom.cpp \ +CCDrawingPrimitives.cpp \ +CCDrawNode.cpp \ +CCGrabber.cpp \ +CCGrid.cpp \ +CCFont.cpp \ +CCFontAtlas.cpp \ +CCFontAtlasCache.cpp \ +CCFontAtlasFactory.cpp \ +CCFontDefinition.cpp \ +CCFontFNT.cpp \ +CCFontFreeType.cpp \ +CCLabel.cpp \ +CCLabelAtlas.cpp \ +CCLabelBMFont.cpp \ +CCLabelTTF.cpp \ +CCLabelTextFormatter.cpp \ +CCTextImage.cpp \ +CCLayer.cpp \ +CCScene.cpp \ +CCTransition.cpp \ +CCTransitionPageTurn.cpp \ +CCTransitionProgress.cpp \ +CCMenu.cpp \ +CCMenuItem.cpp \ +CCMotionStreak.cpp \ +CCProgressTimer.cpp \ +CCClippingNode.cpp \ +CCRenderTexture.cpp \ +CCParticleExamples.cpp \ +CCParticleSystem.cpp \ +CCParticleSystemQuad.cpp \ +CCParticleBatchNode.cpp \ +../physics/box2d/CCPhysicsContactInfo.cpp \ +../physics/box2d/CCPhysicsJointInfo.cpp \ +../physics/box2d/CCPhysicsShapeInfo.cpp \ +../physics/box2d/CCPhysicsBodyInfo.cpp \ +../physics/box2d/CCPhysicsWorldInfo.cpp \ ../physics/chipmunk/CCPhysicsContactInfo.cpp \ ../physics/chipmunk/CCPhysicsJointInfo.cpp \ ../physics/chipmunk/CCPhysicsShapeInfo.cpp \ @@ -109,68 +99,68 @@ SOURCES = ../actions/CCAction.cpp \ ../platform/linux/CCEGLView.cpp \ ../platform/linux/CCImage.cpp \ ../platform/linux/CCDevice.cpp \ -../platform/third_party/common/etc/etc1.cpp \ -../platform/third_party/common/s3tc/s3tc.cpp \ -../platform/third_party/common/atitc/atitc.cpp \ -../script_support/CCScriptSupport.cpp \ -../sprite_nodes/CCAnimation.cpp \ -../sprite_nodes/CCAnimationCache.cpp \ -../sprite_nodes/CCSprite.cpp \ -../sprite_nodes/CCSpriteBatchNode.cpp \ -../sprite_nodes/CCSpriteFrame.cpp \ -../sprite_nodes/CCSpriteFrameCache.cpp \ -../support/ccUTF8.cpp \ -../support/CCProfiling.cpp \ -../support/user_default/CCUserDefault.cpp \ -../support/TransformUtils.cpp \ -../support/base64.cpp \ -../support/ccUtils.cpp \ -../support/CCVertex.cpp \ -../support/CCNotificationCenter.cpp \ -../support/image_support/TGAlib.cpp \ -../support/tinyxml2/tinyxml2.cpp \ -../support/zip_support/ZipUtils.cpp \ -../support/zip_support/ioapi.cpp \ -../support/zip_support/unzip.cpp \ -../support/data_support/ccCArray.cpp \ -../support/component/CCComponent.cpp \ -../support/component/CCComponentContainer.cpp \ -../text_input_node/CCIMEDispatcher.cpp \ -../text_input_node/CCTextFieldTTF.cpp \ -../textures/CCTexture2D.cpp \ -../textures/CCTextureAtlas.cpp \ -../textures/CCTextureCache.cpp \ -../tilemap_parallax_nodes/CCParallaxNode.cpp \ -../tilemap_parallax_nodes/CCTMXLayer.cpp \ -../tilemap_parallax_nodes/CCTMXObjectGroup.cpp \ -../tilemap_parallax_nodes/CCTMXTiledMap.cpp \ -../tilemap_parallax_nodes/CCTMXXMLParser.cpp \ -../tilemap_parallax_nodes/CCTileMapAtlas.cpp \ -../shaders/CCGLProgram.cpp \ -../shaders/ccGLStateCache.cpp \ -../shaders/CCShaderCache.cpp \ -../shaders/ccShaders.cpp \ -../kazmath/src/aabb.c \ -../kazmath/src/plane.c \ -../kazmath/src/vec2.c \ -../kazmath/src/mat3.c \ -../kazmath/src/quaternion.c \ -../kazmath/src/vec3.c \ -../kazmath/src/mat4.c \ -../kazmath/src/ray2.c \ -../kazmath/src/vec4.c \ -../kazmath/src/neon_matrix_impl.c \ -../kazmath/src/utility.c \ -../kazmath/src/GL/mat4stack.c \ -../kazmath/src/GL/matrix.c \ -../CCCamera.cpp \ -../CCConfiguration.cpp \ -../CCDirector.cpp \ -../CCScheduler.cpp \ -../ccFPSImages.c \ -../ccTypes.cpp \ -../cocos2d.cpp \ -../CCDeprecated.cpp +../base/etc1.cpp \ +../base/s3tc.cpp \ +../base/atitc.cpp \ +CCScriptSupport.cpp \ +CCAnimation.cpp \ +CCAnimationCache.cpp \ +CCSprite.cpp \ +CCSpriteBatchNode.cpp \ +CCSpriteFrame.cpp \ +CCSpriteFrameCache.cpp \ +ccUTF8.cpp \ +CCProfiling.cpp \ +CCUserDefault.cpp \ +TransformUtils.cpp \ +base64.cpp \ +ccUtils.cpp \ +CCVertex.cpp \ +CCNotificationCenter.cpp \ +TGAlib.cpp \ +../../external/tinyxml2/tinyxml2.cpp \ +ZipUtils.cpp \ +../../external/unzip/ioapi.cpp \ +../../external/unzip/unzip.cpp \ +ccCArray.cpp \ +CCComponent.cpp \ +CCComponentContainer.cpp \ +CCIMEDispatcher.cpp \ +CCTextFieldTTF.cpp \ +CCTexture2D.cpp \ +CCTextureAtlas.cpp \ +CCTextureCache.cpp \ +CCParallaxNode.cpp \ +CCTMXLayer.cpp \ +CCTMXObjectGroup.cpp \ +CCTMXTiledMap.cpp \ +CCTMXXMLParser.cpp \ +CCTileMapAtlas.cpp \ +CCGLProgram.cpp \ +ccGLStateCache.cpp \ +CCShaderCache.cpp \ +ccShaders.cpp \ +../math/kazmath/src/aabb.c \ +../math/kazmath/src/plane.c \ +../math/kazmath/src/vec2.c \ +../math/kazmath/src/mat3.c \ +../math/kazmath/src/quaternion.c \ +../math/kazmath/src/vec3.c \ +../math/kazmath/src/mat4.c \ +../math/kazmath/src/ray2.c \ +../math/kazmath/src/vec4.c \ +../math/kazmath/src/neon_matrix_impl.c \ +../math/kazmath/src/utility.c \ +../math/kazmath/src/GL/mat4stack.c \ +../math/kazmath/src/GL/matrix.c \ +CCCamera.cpp \ +CCConfiguration.cpp \ +CCDirector.cpp \ +CCScheduler.cpp \ +ccFPSImages.c \ +ccTypes.cpp \ +cocos2d.cpp \ +CCDeprecated.cpp COCOS_ROOT = ../.. @@ -189,10 +179,24 @@ $(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -shared -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) +$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + $(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ +$(OBJ_DIR)/%.o: ../../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + +$(OBJ_DIR)/%.o: %.c $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + $(OBJ_DIR)/%.o: ../%.c $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + + diff --git a/cocos/2d/cocos2dx.mk b/cocos/2d/cocos2dx.mk index 0058e43bac..41ef87b631 100644 --- a/cocos/2d/cocos2dx.mk +++ b/cocos/2d/cocos2dx.mk @@ -45,28 +45,30 @@ THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) ifndef COCOS_ROOT COCOS_ROOT := $(realpath $(dir $(THIS_MAKEFILE))/../..) endif -COCOS_SRC = $(COCOS_ROOT)/cocos2dx +COCOS_SRC = $(COCOS_ROOT)/cocos/2d OBJ_DIR ?= obj LIB_DIR = $(COCOS_ROOT)/lib/linux BIN_DIR = bin INCLUDES += \ - -I$(COCOS_SRC) \ - -I$(COCOS_SRC)/cocoa \ - -I$(COCOS_SRC)/include \ - -I$(COCOS_SRC)/kazmath/include \ + -I$(COCOS_SRC)/ \ + -I$(COCOS_SRC)/../math/kazmath/include \ -I$(COCOS_SRC)/platform/linux \ - -I$(COCOS_SRC)/platform/third_party/linux/libjpeg \ - -I$(COCOS_SRC)/platform/third_party/linux/libtiff \ - -I$(COCOS_SRC)/platform/third_party/linux/libwebp + -I$(COCOS_SRC)/../../external/jpeg/include/linux \ + -I$(COCOS_SRC)/../../external/tiff/include/linux \ + -I$(COCOS_SRC)/../../external/webp/include/linux \ + -I$(COCOS_SRC)/../../external/tinyxml2 \ + -I$(COCOS_SRC)/../../external/unzip \ + -I$(COCOS_SRC)/../../external/glfw3/include/linux \ + -I$(COCOS_SRC)/../physics \ + -I$(COCOS_SRC)/../base \ + -I$(COCOS_SRC)/../../external/chipmunk/include/chipmunk \ + -I$(COCOS_SRC)/../../external/freetype2/include/linux \ + -I$(COCOS_SRC)/../.. \ + -I$(COCOS_SRC)/../audio/include LBITS := $(shell getconf LONG_BIT) -ifeq ($(LBITS),64) -INCLUDES += -I$(COCOS_SRC)/platform/third_party/linux/include64 -else -INCLUDES += -I$(COCOS_SRC)/platform/third_party/linux -endif ifeq ($(DEBUG), 1) CCFLAGS += -g3 -O0 @@ -100,22 +102,23 @@ DEPS = $(OBJECTS:.o=.d) CORE_MAKEFILE_LIST := $(MAKEFILE_LIST) -include $(DEPS) +STATICLIBS_DIR = $(COCOS_ROOT)/external ifeq ($(LBITS),64) -STATICLIBS_DIR = $(COCOS_SRC)/platform/third_party/linux/libraries/lib64 +POSTFIX = 64-bit else -STATICLIBS_DIR = $(COCOS_SRC)/platform/third_party/linux/libraries +POSTFIX = 32-bit endif -STATICLIBS = $(STATICLIBS_DIR)/libfreetype.a \ - $(STATICLIBS_DIR)/libjpeg.a \ - $(STATICLIBS_DIR)/libtiff.a \ - $(STATICLIBS_DIR)/libwebp.a +STATICLIBS = $(STATICLIBS_DIR)/freetype2/prebuilt/linux/$(POSTFIX)/libfreetype.a \ + $(STATICLIBS_DIR)/jpeg/prebuilt/linux/$(POSTFIX)/libjpeg.a \ + $(STATICLIBS_DIR)/tiff/prebuilt/linux/$(POSTFIX)/libtiff.a \ + $(STATICLIBS_DIR)/webp/prebuilt/linux/$(POSTFIX)/libwebp.a ifneq ($(OPENAL),1) ifeq ($(LBITS),64) -FMOD_LIBDIR = $(COCOS_ROOT)/audio/third_party/fmod/lib64/api/lib +FMOD_LIBDIR = $(COCOS_ROOT)/cocos/audio/third-party/fmod/lib64/api/lib SHAREDLIBS += -lfmodex64 else -FMOD_LIBDIR = $(COCOS_ROOT)/audio/third_party/fmod/api/lib +FMOD_LIBDIR = $(COCOS_ROOT)/cocos/audio/third-party/fmod/api/lib SHAREDLIBS += -lfmodex endif endif diff --git a/cocos/2d/platform/linux/CCEGLView.cpp b/cocos/2d/platform/linux/CCEGLView.cpp index 452d5738a3..561fedcca8 100644 --- a/cocos/2d/platform/linux/CCEGLView.cpp +++ b/cocos/2d/platform/linux/CCEGLView.cpp @@ -10,7 +10,7 @@ #include "ccMacros.h" #include "CCDirector.h" #include "CCTouch.h" -#include "/CCIMEDispatcher.h" +#include "CCIMEDispatcher.h" #include "CCEventDispatcher.h" #include "CCEventKeyboard.h" #include diff --git a/cocos/2d/platform/linux/CCEGLView.h b/cocos/2d/platform/linux/CCEGLView.h index 9d29d9c188..ed4fc18245 100644 --- a/cocos/2d/platform/linux/CCEGLView.h +++ b/cocos/2d/platform/linux/CCEGLView.h @@ -11,7 +11,7 @@ #include "platform/CCCommon.h" #include "CCGeometry.h" #include "platform/CCEGLViewProtocol.h" -#include "platform/third_party/linux/glfw/glfw3.h" +#include "glfw3.h" #include bool initExtensions(); diff --git a/cocos/audio/proj.linux/Makefile b/cocos/audio/proj.linux/Makefile index 82dc89a6d6..e8b18e3972 100644 --- a/cocos/audio/proj.linux/Makefile +++ b/cocos/audio/proj.linux/Makefile @@ -1,6 +1,6 @@ TARGET = libcocosdenshion.so -INCLUDES += -I.. -I../include +INCLUDES = -I.. -I../include ##Using OpenAL ifeq ($(OPENAL),1) @@ -26,15 +26,15 @@ SOURCES = \ ../linux/FmodAudioPlayer.cpp ifeq ($(LBITS),64) -INCLUDES += -I../third_party/fmod/lib64/api/inc +INCLUDES += -I../third-party/fmod/lib64/api/inc else -INCLUDES += -I../third_party/fmod/api/inc +INCLUDES += -I../third-party/fmod/api/inc endif endif -COCOS_ROOT = ../.. -include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk +COCOS_ROOT = ../../.. +include $(COCOS_ROOT)/cocos/2d/cocos2dx.mk TARGET := $(LIB_DIR)/$(TARGET) diff --git a/cocos/editor-support/cocosbuilder/Makefile b/cocos/editor-support/cocosbuilder/Makefile new file mode 100644 index 0000000000..688c5d49d5 --- /dev/null +++ b/cocos/editor-support/cocosbuilder/Makefile @@ -0,0 +1,44 @@ +TARGET = libcocosbuilder.a + +INCLUDES = + +SOURCES = CCBFileLoader.cpp \ +CCMenuItemImageLoader.cpp \ +CCBReader.cpp \ +CCMenuItemLoader.cpp \ +CCControlButtonLoader.cpp \ +CCNodeLoader.cpp \ +CCControlLoader.cpp \ +CCNodeLoaderLibrary.cpp \ +CCLabelBMFontLoader.cpp \ +CCParticleSystemQuadLoader.cpp \ +CCLabelTTFLoader.cpp \ +CCScale9SpriteLoader.cpp \ +CCLayerColorLoader.cpp \ +CCScrollViewLoader.cpp \ +CCLayerGradientLoader.cpp \ +CCSpriteLoader.cpp \ +CCLayerLoader.cpp \ +CCBAnimationManager.cpp \ +CCBKeyframe.cpp \ +CCBSequence.cpp \ +CCBSequenceProperty.cpp \ +CCBValue.cpp \ +CCNode+CCBRelativePositioning.cpp + +include ../../2d/cocos2dx.mk + +CXXFLAGS += -Wno-multichar + +TARGET := $(LIB_DIR)/$(TARGET) + +all: $(TARGET) + +$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_AR)$(AR) $(ARFLAGS) $@ $(OBJECTS) + +$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + diff --git a/cocos/editor-support/cocostudio/Makefile b/cocos/editor-support/cocostudio/Makefile new file mode 100644 index 0000000000..810c28372e --- /dev/null +++ b/cocos/editor-support/cocostudio/Makefile @@ -0,0 +1,69 @@ +TARGET = libcocostudio.a + +COCOS_ROOT=../../.. + +INCLUDES = -I../../2d \ +-I../../../external \ +-I.. \ +-I../.. \ + +SOURCES = CCActionFrame.cpp \ +CCActionFrameEasing.cpp \ +CCActionManagerEx.cpp \ +CCActionNode.cpp \ +CCActionObject.cpp \ +CCArmature.cpp \ +CCBone.cpp \ +CCArmatureAnimation.cpp \ +CCProcessBase.cpp \ +CCTween.cpp \ +CCDatas.cpp \ +CCBatchNode.cpp \ +CCDecorativeDisplay.cpp \ +CCDisplayFactory.cpp \ +CCDisplayManager.cpp \ +CCSkin.cpp \ +CCColliderDetector.cpp \ +CCArmatureDataManager.cpp \ +CCArmatureDefine.cpp \ +CCDataReaderHelper.cpp \ +CCSpriteFrameCacheHelper.cpp \ +CCTransformHelp.cpp \ +CCTweenFunction.cpp \ +CCUtilMath.cpp \ +CCComAttribute.cpp \ +CCComAudio.cpp \ +CCComController.cpp \ +CCComRender.cpp \ +CCInputDelegate.cpp \ +CSContentJsonDictionary.cpp \ +DictionaryHelper.cpp \ +CCSGUIReader.cpp \ +CCSSceneReader.cpp \ +../../../external/json/json_reader.cpp \ +../../../external/json/json_value.cpp \ +../../../external/json/json_writer.cpp + +include ../../2d/cocos2dx.mk + +CXXFLAGS += -Wno-multichar + +TARGET := $(LIB_DIR)/$(TARGET) + +all: $(TARGET) + +$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_AR)$(AR) $(ARFLAGS) $@ $(OBJECTS) + +$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + +$(OBJ_DIR)/%.o: ../../../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + +$(OBJ_DIR)/%.o: %.c $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/cocos/editor-support/spine/Makefile b/cocos/editor-support/spine/Makefile new file mode 100644 index 0000000000..88514a824e --- /dev/null +++ b/cocos/editor-support/spine/Makefile @@ -0,0 +1,42 @@ +TARGET = libspine.a + +INCLUDES = -I.. + +SOURCES = Animation.cpp \ +AnimationState.cpp \ +AnimationStateData.cpp \ +Atlas.cpp \ +AtlasAttachmentLoader.cpp \ +Attachment.cpp \ +AttachmentLoader.cpp \ +Bone.cpp \ +BoneData.cpp \ +Json.cpp \ +RegionAttachment.cpp \ +Skeleton.cpp \ +SkeletonData.cpp \ +SkeletonJson.cpp \ +Skin.cpp \ +Slot.cpp \ +SlotData.cpp \ +extension.cpp \ +spine-cocos2dx.cpp \ +CCSkeleton.cpp \ +CCSkeletonAnimation.cpp + +include ../../2d/cocos2dx.mk + +CXXFLAGS += -Wno-multichar + +TARGET := $(LIB_DIR)/$(TARGET) + +all: $(TARGET) + +$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_AR)$(AR) $(ARFLAGS) $@ $(OBJECTS) + +$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + diff --git a/cocos/gui/Layout.cpp b/cocos/gui/Layout.cpp index b7014ac1ed..a9e4f75a30 100644 --- a/cocos/gui/Layout.cpp +++ b/cocos/gui/Layout.cpp @@ -22,7 +22,7 @@ THE SOFTWARE. ****************************************************************************/ -#include "gui/layout.h" +#include "gui/Layout.h" #include "gui/UILayer.h" #include "gui/UIHelper.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" @@ -782,4 +782,4 @@ bool RectClippingNode::isEnabled() const return _enabled; } -} \ No newline at end of file +} diff --git a/cocos/gui/Makefile b/cocos/gui/Makefile new file mode 100644 index 0000000000..0e8501cc63 --- /dev/null +++ b/cocos/gui/Makefile @@ -0,0 +1,44 @@ +TARGET = libgui.a + +INCLUDES = -I../ \ +-I../editor-support \ +-I../../external + +SOURCES = UIRootWidget.cpp \ +UIWidget.cpp \ +Layout.cpp \ +LayoutParameter.cpp \ +UILayoutDefine.cpp \ +CocosGUI.cpp \ +UIHelper.cpp \ +UIInputManager.cpp \ +UILayer.cpp \ +UIDragPanel.cpp \ +UIListView.cpp \ +UIPageView.cpp \ +UIScrollView.cpp \ +UIButton.cpp \ +UICheckBox.cpp \ +UIImageView.cpp \ +UILabel.cpp \ +UILabelAtlas.cpp \ +UILabelBMFont.cpp \ +UILoadingBar.cpp \ +UISlider.cpp \ +UITextField.cpp + +include ../2d/cocos2dx.mk + +CXXFLAGS += -Wno-multichar + +TARGET := $(LIB_DIR)/$(TARGET) + +all: $(TARGET) + +$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_AR)$(AR) $(ARFLAGS) $@ $(OBJECTS) + +$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/cocos/network/Makefile b/cocos/network/Makefile new file mode 100644 index 0000000000..029078722d --- /dev/null +++ b/cocos/network/Makefile @@ -0,0 +1,22 @@ +TARGET = libnetwork.a + +INCLUDES = -I.. + +SOURCES = HttpClient.cpp \ +SocketIO.cpp + +include ../2d/cocos2dx.mk + +CXXFLAGS += -Wno-multichar + +TARGET := $(LIB_DIR)/$(TARGET) + +all: $(TARGET) + +$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_AR)$(AR) $(ARFLAGS) $@ $(OBJECTS) + +$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/cocos/physics/CCPhysicsBody.cpp b/cocos/physics/CCPhysicsBody.cpp index 2dc38bf286..2fb6c4458b 100644 --- a/cocos/physics/CCPhysicsBody.cpp +++ b/cocos/physics/CCPhysicsBody.cpp @@ -37,16 +37,16 @@ #include "CCPhysicsWorld.h" #include "chipmunk/CCPhysicsBodyInfo.h" -#include "Box2D/CCPhysicsBodyInfo.h" +#include "box2d/CCPhysicsBodyInfo.h" #include "chipmunk/CCPhysicsJointInfo.h" -#include "Box2D/CCPhysicsJointInfo.h" +#include "box2d/CCPhysicsJointInfo.h" #include "chipmunk/CCPhysicsWorldInfo.h" -#include "Box2D/CCPhysicsWorldInfo.h" +#include "box2d/CCPhysicsWorldInfo.h" #include "chipmunk/CCPhysicsShapeInfo.h" -#include "Box2D/CCPhysicsShapeInfo.h" +#include "box2d/CCPhysicsShapeInfo.h" #include "chipmunk/CCPhysicsHelper.h" -#include "Box2D/CCPhysicsHelper.h" +#include "box2d/CCPhysicsHelper.h" NS_CC_BEGIN diff --git a/cocos/physics/CCPhysicsContact.cpp b/cocos/physics/CCPhysicsContact.cpp index 928c8c9e59..1ec9667d6f 100644 --- a/cocos/physics/CCPhysicsContact.cpp +++ b/cocos/physics/CCPhysicsContact.cpp @@ -31,7 +31,7 @@ #endif #include "chipmunk/CCPhysicsContactInfo.h" -#include "Box2D/CCPhysicsContactInfo.h" +#include "box2d/CCPhysicsContactInfo.h" NS_CC_BEGIN diff --git a/cocos/physics/CCPhysicsJoint.cpp b/cocos/physics/CCPhysicsJoint.cpp index 63b6ac052e..b2742720e4 100644 --- a/cocos/physics/CCPhysicsJoint.cpp +++ b/cocos/physics/CCPhysicsJoint.cpp @@ -34,11 +34,11 @@ #include "CCPhysicsBody.h" #include "chipmunk/CCPhysicsJointInfo.h" -#include "Box2D/CCPhysicsJointInfo.h" +#include "box2d/CCPhysicsJointInfo.h" #include "chipmunk/CCPhysicsBodyInfo.h" -#include "Box2D/CCPhysicsBodyInfo.h" +#include "box2d/CCPhysicsBodyInfo.h" #include "chipmunk/CCPhysicsHelper.h" -#include "Box2D/CCPhysicsHelper.h" +#include "box2d/CCPhysicsHelper.h" NS_CC_BEGIN diff --git a/cocos/physics/CCPhysicsShape.cpp b/cocos/physics/CCPhysicsShape.cpp index b373e0710e..15e0a82ca0 100644 --- a/cocos/physics/CCPhysicsShape.cpp +++ b/cocos/physics/CCPhysicsShape.cpp @@ -35,9 +35,9 @@ #include "CCPhysicsWorld.h" #include "chipmunk/CCPhysicsBodyInfo.h" -#include "Box2D/CCPhysicsBodyInfo.h" +#include "box2d/CCPhysicsBodyInfo.h" #include "chipmunk/CCPhysicsShapeInfo.h" -#include "Box2D/CCPhysicsShapeInfo.h" +#include "box2d/CCPhysicsShapeInfo.h" #include "chipmunk/CCPhysicsHelper.h" NS_CC_BEGIN @@ -518,4 +518,4 @@ bool PhysicsShapeEdgeChain::init(Point* points, int count, PhysicsMaterial mater NS_CC_END -#endif // CC_USE_PHYSICS \ No newline at end of file +#endif // CC_USE_PHYSICS diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index 1777a395f0..11859579ac 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -37,15 +37,15 @@ #include "CCPhysicsJoint.h" #include "chipmunk/CCPhysicsWorldInfo.h" -#include "Box2D/CCPhysicsWorldInfo.h" +#include "box2d/CCPhysicsWorldInfo.h" #include "chipmunk/CCPhysicsBodyInfo.h" -#include "Box2D/CCPhysicsBodyInfo.h" +#include "box2d/CCPhysicsBodyInfo.h" #include "chipmunk/CCPhysicsShapeInfo.h" -#include "Box2D/CCPhysicsShapeInfo.h" +#include "box2d/CCPhysicsShapeInfo.h" #include "chipmunk/CCPhysicsContactInfo.h" -#include "Box2D/CCPhysicsContactInfo.h" +#include "box2d/CCPhysicsContactInfo.h" #include "chipmunk/CCPhysicsJointInfo.h" -#include "Box2D/CCPhysicsJointInfo.h" +#include "box2d/CCPhysicsJointInfo.h" #include "chipmunk/CCPhysicsHelper.h" #include "CCDrawNode.h" diff --git a/cocos/scripting/lua/bindings/Makefile b/cocos/scripting/lua/bindings/Makefile index 1aaa6c897e..95145d5fbc 100644 --- a/cocos/scripting/lua/bindings/Makefile +++ b/cocos/scripting/lua/bindings/Makefile @@ -1,64 +1,72 @@ TARGET = liblua.so -INCLUDES += -I.. -I../lua -I../tolua -I../cocos2dx_support -I../../auto-generated/lua-bindings \ - -I../Classes -I../../../audio/include -I../../../extensions -I../../../external/chipmunk/include/chipmunk +INCLUDES += -I../../../../external/lua/tolua \ +-I../../../../external/lua/lua \ +-I../../auto-generated/lua-bindings \ +-I../../../../extensions \ +-I../../../editor-support \ +-I. \ +-I../../../editor-support/cocosbuilder \ +-I../../../editor-support/cocostudio \ +-I../../../../external \ +-I../../../ -SOURCES = ../lua/lapi.c \ - ../lua/lauxlib.c \ - ../lua/lbaselib.c \ - ../lua/lcode.c \ - ../lua/ldblib.c \ - ../lua/ldebug.c \ - ../lua/ldo.c \ - ../lua/ldump.c \ - ../lua/lfunc.c \ - ../lua/lgc.c \ - ../lua/linit.c \ - ../lua/liolib.c \ - ../lua/llex.c \ - ../lua/lmathlib.c \ - ../lua/lmem.c \ - ../lua/loadlib.c \ - ../lua/lobject.c \ - ../lua/lopcodes.c \ - ../lua/loslib.c \ - ../lua/lparser.c \ - ../lua/lstate.c \ - ../lua/lstring.c \ - ../lua/lstrlib.c \ - ../lua/ltable.c \ - ../lua/ltablib.c \ - ../lua/ltm.c \ - ../lua/lundump.c \ - ../lua/lvm.c \ - ../lua/lzio.c \ - ../lua/print.c \ - ../tolua/tolua_event.c \ - ../tolua/tolua_is.c \ - ../tolua/tolua_map.c \ - ../tolua/tolua_push.c \ - ../tolua/tolua_to.c \ - ../cocos2dx_support/tolua_fix.c \ +SOURCES = ../../../../external/lua/lua/lapi.c \ + ../../../../external/lua/lua/lauxlib.c \ + ../../../../external/lua/lua/lbaselib.c \ + ../../../../external/lua/lua/lcode.c \ + ../../../../external/lua/lua/ldblib.c \ + ../../../../external/lua/lua/ldebug.c \ + ../../../../external/lua/lua/ldo.c \ + ../../../../external/lua/lua/ldump.c \ + ../../../../external/lua/lua/lfunc.c \ + ../../../../external/lua/lua/lgc.c \ + ../../../../external/lua/lua/linit.c \ + ../../../../external/lua/lua/liolib.c \ + ../../../../external/lua/lua/llex.c \ + ../../../../external/lua/lua/lmathlib.c \ + ../../../../external/lua/lua/lmem.c \ + ../../../../external/lua/lua/loadlib.c \ + ../../../../external/lua/lua/lobject.c \ + ../../../../external/lua/lua/lopcodes.c \ + ../../../../external/lua/lua/loslib.c \ + ../../../../external/lua/lua/lparser.c \ + ../../../../external/lua/lua/lstate.c \ + ../../../../external/lua/lua/lstring.c \ + ../../../../external/lua/lua/lstrlib.c \ + ../../../../external/lua/lua/ltable.c \ + ../../../../external/lua/lua/ltablib.c \ + ../../../../external/lua/lua/ltm.c \ + ../../../../external/lua/lua/lundump.c \ + ../../../../external/lua/lua/lvm.c \ + ../../../../external/lua/lua/lzio.c \ + ../../../../external/lua/lua/print.c \ + ../../../../external/lua/tolua/tolua_event.c \ + ../../../../external/lua/tolua/tolua_is.c \ + ../../../../external/lua/tolua/tolua_map.c \ + ../../../../external/lua/tolua/tolua_push.c \ + ../../../../external/lua/tolua/tolua_to.c \ + tolua_fix.c \ ../../auto-generated/lua-bindings/lua_cocos2dx_auto.cpp \ ../../auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp \ - ../cocos2dx_support/CCLuaBridge.cpp \ - ../cocos2dx_support/CCLuaEngine.cpp \ - ../cocos2dx_support/CCLuaStack.cpp \ - ../cocos2dx_support/CCLuaValue.cpp \ - ../cocos2dx_support/Cocos2dxLuaLoader.cpp \ - ../cocos2dx_support/CCBProxy.cpp \ - ../cocos2dx_support/LuaOpengl.cpp \ - ../cocos2dx_support/LuaScriptHandlerMgr.cpp \ - ../cocos2dx_support/LuaBasicConversions.cpp \ - ../cocos2dx_support/lua_cocos2dx_manual.cpp \ - ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp \ - ../cocos2dx_support/lua_cocos2dx_deprecated.cpp + CCLuaBridge.cpp \ + CCLuaEngine.cpp \ + CCLuaStack.cpp \ + CCLuaValue.cpp \ + Cocos2dxLuaLoader.cpp \ + CCBProxy.cpp \ + LuaOpengl.cpp \ + LuaScriptHandlerMgr.cpp \ + LuaBasicConversions.cpp \ + lua_cocos2dx_manual.cpp \ + lua_cocos2dx_extension_manual.cpp \ + lua_cocos2dx_deprecated.cpp -include ../../../cocos2dx/proj.linux/cocos2dx.mk +include ../../../2d/cocos2dx.mk TARGET := $(LIB_DIR)/$(TARGET) -SHAREDLIBS += -lextension +SHAREDLIBS += -lextension -lcocostudio -lcocosbuilder STATICLIBS += $(LIB_DIR)/libbox2d.a all: $(TARGET) @@ -67,14 +75,18 @@ $(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -shared -o $@ $(SHAREDLIBS) $(STATICLIBS) +$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + $(OBJ_DIR)/%.o: ../../%.cpp $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ -$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - -$(OBJ_DIR)/%.o: ../%.c $(CORE_MAKEFILE_LIST) +$(OBJ_DIR)/%.o: ../../../../%.c $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + +$(OBJ_DIR)/%.o: %.c $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/extensions/proj.linux/Makefile b/extensions/proj.linux/Makefile index 6565ee9b94..fe07e988e5 100644 --- a/extensions/proj.linux/Makefile +++ b/extensions/proj.linux/Makefile @@ -1,146 +1,36 @@ TARGET = libextension.a -COCOS_ROOT=../.. +INCLUDES = -I.. -INCLUDES = -I$(COCOS_ROOT)/external \ - -I$(COCOS_ROOT)/external/chipmunk/include/chipmunk \ - -I$(COCOS_ROOT)/audio/include \ - -I.. \ - -I../CCBReader \ - -I../GUI/CCControlExtension \ - -I../GUI/CCEditBox \ - -I../network \ - -I../CocoStudio/Components \ - -I../CocoStudio/Armature +SOURCES = \ +assets-manager/AssetsManager.cpp \ +GUI/CCControlExtension/CCControl.cpp \ +GUI/CCControlExtension/CCControlButton.cpp \ +GUI/CCControlExtension/CCControlColourPicker.cpp \ +GUI/CCControlExtension/CCControlHuePicker.cpp \ +GUI/CCControlExtension/CCControlPotentiometer.cpp \ +GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp \ +GUI/CCControlExtension/CCControlSlider.cpp \ +GUI/CCControlExtension/CCControlStepper.cpp \ +GUI/CCControlExtension/CCControlSwitch.cpp \ +GUI/CCControlExtension/CCControlUtils.cpp \ +GUI/CCControlExtension/CCInvocation.cpp \ +GUI/CCControlExtension/CCScale9Sprite.cpp \ +GUI/CCEditBox/CCEditBox.cpp \ +GUI/CCEditBox/CCEditBoxImplAndroid.cpp \ +GUI/CCEditBox/CCEditBoxImplNone.cpp \ +GUI/CCEditBox/CCEditBoxImplTizen.cpp \ +GUI/CCEditBox/CCEditBoxImplWin.cpp \ +GUI/CCScrollView/CCScrollView.cpp \ +GUI/CCScrollView/CCSorting.cpp \ +GUI/CCScrollView/CCTableView.cpp \ +GUI/CCScrollView/CCTableViewCell.cpp \ +physics-nodes/CCPhysicsDebugNode.cpp \ +physics-nodes/CCPhysicsSprite.cpp -SOURCES = ../CCBReader/CCBFileLoader.cpp \ -../CCBReader/CCMenuItemImageLoader.cpp \ -../CCBReader/CCBReader.cpp \ -../CCBReader/CCMenuItemLoader.cpp \ -../CCBReader/CCControlButtonLoader.cpp \ -../CCBReader/CCNodeLoader.cpp \ -../CCBReader/CCControlLoader.cpp \ -../CCBReader/CCNodeLoaderLibrary.cpp \ -../CCBReader/CCLabelBMFontLoader.cpp \ -../CCBReader/CCParticleSystemQuadLoader.cpp \ -../CCBReader/CCLabelTTFLoader.cpp \ -../CCBReader/CCScale9SpriteLoader.cpp \ -../CCBReader/CCLayerColorLoader.cpp \ -../CCBReader/CCScrollViewLoader.cpp \ -../CCBReader/CCLayerGradientLoader.cpp \ -../CCBReader/CCSpriteLoader.cpp \ -../CCBReader/CCLayerLoader.cpp \ -../CCBReader/CCBAnimationManager.cpp \ -../CCBReader/CCBKeyframe.cpp \ -../CCBReader/CCBSequence.cpp \ -../CCBReader/CCBSequenceProperty.cpp \ -../CCBReader/CCBValue.cpp \ -../CCBReader/CCNode+CCBRelativePositioning.cpp \ -../GUI/CCScrollView/CCScrollView.cpp \ -../GUI/CCScrollView/CCSorting.cpp \ -../GUI/CCScrollView/CCTableView.cpp \ -../GUI/CCScrollView/CCTableViewCell.cpp \ -../GUI/CCControlExtension/CCControlButton.cpp \ -../GUI/CCControlExtension/CCControlColourPicker.cpp \ -../GUI/CCControlExtension/CCControl.cpp \ -../GUI/CCControlExtension/CCControlHuePicker.cpp \ -../GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp \ -../GUI/CCControlExtension/CCControlSlider.cpp \ -../GUI/CCControlExtension/CCControlSwitch.cpp \ -../GUI/CCControlExtension/CCControlUtils.cpp \ -../GUI/CCControlExtension/CCInvocation.cpp \ -../GUI/CCControlExtension/CCScale9Sprite.cpp \ -../GUI/CCControlExtension/CCControlPotentiometer.cpp \ -../GUI/CCControlExtension/CCControlStepper.cpp \ -../GUI/CCEditBox/CCEditBox.cpp \ -../GUI/CCEditBox/CCEditBoxImplNone.cpp \ -../network/HttpClient.cpp \ -../physics_nodes/CCPhysicsDebugNode.cpp \ -../physics_nodes/CCPhysicsSprite.cpp \ -../CocoStudio/Armature/CCArmature.cpp \ -../CocoStudio/Armature/CCBone.cpp \ -../CocoStudio/Armature/animation/CCArmatureAnimation.cpp \ -../CocoStudio/Armature/animation/CCProcessBase.cpp \ -../CocoStudio/Armature/animation/CCTween.cpp \ -../CocoStudio/Armature/datas/CCDatas.cpp \ -../CocoStudio/Armature/display/CCBatchNode.cpp \ -../CocoStudio/Armature/display/CCDecorativeDisplay.cpp \ -../CocoStudio/Armature/display/CCDisplayFactory.cpp \ -../CocoStudio/Armature/display/CCDisplayManager.cpp \ -../CocoStudio/Armature/display/CCSkin.cpp \ -../CocoStudio/Armature/physics/CCColliderDetector.cpp \ -../CocoStudio/Armature/utils/CCArmatureDefine.cpp \ -../CocoStudio/Armature/utils/CCArmatureDataManager.cpp \ -../CocoStudio/Armature/utils/CCDataReaderHelper.cpp \ -../CocoStudio/Armature/utils/CCSpriteFrameCacheHelper.cpp \ -../CocoStudio/Armature/utils/CCTransformHelp.cpp \ -../CocoStudio/Armature/utils/CCTweenFunction.cpp \ -../CocoStudio/Armature/utils/CCUtilMath.cpp \ -../CocoStudio/Components/CCComAttribute.cpp \ -../CocoStudio/Components/CCComAudio.cpp \ -../CocoStudio/Components/CCComController.cpp \ -../CocoStudio/Components/CCComRender.cpp \ -../CocoStudio/Components/CCInputDelegate.cpp \ -../CocoStudio/GUI/BaseClasses/UIRootWidget.cpp \ -../CocoStudio/GUI/BaseClasses/UIWidget.cpp \ -../CocoStudio/GUI/Layouts/Layout.cpp \ -../CocoStudio/GUI/Layouts/LayoutParameter.cpp \ -../CocoStudio/GUI/Layouts/UILayoutDefine.cpp \ -../CocoStudio/GUI/System/CocosGUI.cpp \ -../CocoStudio/GUI/System/UIHelper.cpp \ -../CocoStudio/GUI/System/UIInputManager.cpp \ -../CocoStudio/GUI/System/UILayer.cpp \ -../CocoStudio/GUI/UIWidgets/UIButton.cpp \ -../CocoStudio/GUI/UIWidgets/UICheckBox.cpp \ -../CocoStudio/GUI/UIWidgets/UIImageView.cpp \ -../CocoStudio/GUI/UIWidgets/UILabel.cpp \ -../CocoStudio/GUI/UIWidgets/UILabelAtlas.cpp \ -../CocoStudio/GUI/UIWidgets/UILabelBMFont.cpp \ -../CocoStudio/GUI/UIWidgets/UILoadingBar.cpp \ -../CocoStudio/GUI/UIWidgets/UISlider.cpp \ -../CocoStudio/GUI/UIWidgets/UITextField.cpp \ -../CocoStudio/GUI/UIWidgets/ScrollWidget/UIDragPanel.cpp \ -../CocoStudio/GUI/UIWidgets/ScrollWidget/UIListView.cpp \ -../CocoStudio/GUI/UIWidgets/ScrollWidget/UIPageView.cpp \ -../CocoStudio/GUI/UIWidgets/ScrollWidget/UIScrollView.cpp \ -../CocoStudio/Json/CSContentJsonDictionary.cpp \ -../CocoStudio/Json/DictionaryHelper.cpp \ -../CocoStudio/Json/lib_json/json_reader.cpp \ -../CocoStudio/Json/lib_json/json_value.cpp \ -../CocoStudio/Json/lib_json/json_writer.cpp \ -../CocoStudio/Reader/CCSGUIReader.cpp \ -../CocoStudio/Reader/CCSSceneReader.cpp \ -../CocoStudio/Action/CCActionFrame.cpp \ -../CocoStudio/Action/CCActionFrameEasing.cpp \ -../CocoStudio/Action/CCActionManagerEx.cpp \ -../CocoStudio/Action/CCActionNode.cpp \ -../CocoStudio/Action/CCActionObject.cpp \ -../spine/Animation.cpp \ -../spine/AnimationState.cpp \ -../spine/AnimationStateData.cpp \ -../spine/Atlas.cpp \ -../spine/AtlasAttachmentLoader.cpp \ -../spine/Attachment.cpp \ -../spine/AttachmentLoader.cpp \ -../spine/Bone.cpp \ -../spine/BoneData.cpp \ -../spine/Json.cpp \ -../spine/RegionAttachment.cpp \ -../spine/Skeleton.cpp \ -../spine/SkeletonData.cpp \ -../spine/SkeletonJson.cpp \ -../spine/Skin.cpp \ -../spine/Slot.cpp \ -../spine/SlotData.cpp \ -../spine/extension.cpp \ -../spine/spine-cocos2dx.cpp \ -../spine/CCSkeleton.cpp \ -../spine/CCSkeletonAnimation.cpp \ -../CCDeprecated-ext.cpp +include ../../cocos/2d/cocos2dx.mk -include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk - -CXXFLAGS += -Wno-multichar +CXXFLAGS += -Wno-multichar -Wno-unused-result TARGET := $(LIB_DIR)/$(TARGET) diff --git a/extensions/proj.linux/extensions.prf b/extensions/proj.linux/extensions.prf deleted file mode 100644 index d399b91272..0000000000 --- a/extensions/proj.linux/extensions.prf +++ /dev/null @@ -1,20 +0,0 @@ -################################################################################ -# Do not include this file in your project: see cocos2dx.pri. -################################################################################ - -linux { - # We will compile extensions on demand using Makefile. - build_extension.name = Build extension static library - build_extension.input = $$PWD/Makefile - build_extension.output = $$CC_LIBRARY_DIR/libextension.a - build_extension.target = $$CC_LIBRARY_DIR/libextension.a - build_extension.CONFIG = no_link target_predeps - build_extension.commands = cd $$PWD && make $$CC_MAKE_FLAGS - - QMAKE_EXTRA_COMPILERS += build_extension - QMAKE_EXTRA_TARGETS += build_extension - - PRE_TARGETDEPS += $$CC_LIBRARY_DIR/libextension.a - LIBS += -Wl,-Bstatic -lextension -Wl,-Bdynamic -} - diff --git a/external/Box2D/proj.linux/Makefile b/external/Box2D/proj.linux/Makefile index e430bc9883..b43814ccef 100644 --- a/external/Box2D/proj.linux/Makefile +++ b/external/Box2D/proj.linux/Makefile @@ -46,7 +46,7 @@ SOURCES = ../Collision/Shapes/b2ChainShape.cpp \ ../Dynamics/b2WorldCallbacks.cpp \ ../Rope/b2Rope.cpp -include ../../../cocos2dx/proj.linux/cocos2dx.mk +include ../../../cocos/2d/cocos2dx.mk INCLUDES = -I../.. diff --git a/external/chipmunk/proj.linux/Makefile b/external/chipmunk/proj.linux/Makefile index b0e5d1f572..a2cb985b7c 100644 --- a/external/chipmunk/proj.linux/Makefile +++ b/external/chipmunk/proj.linux/Makefile @@ -28,7 +28,7 @@ SOURCES = ../src/chipmunk.c \ ../src/constraints/cpSlideJoint.c \ ../src/constraints/cpPinJoint.c \ -include ../../../cocos2dx/proj.linux/cocos2dx.mk +include ../../../cocos/2d/cocos2dx.mk TARGET = $(LIB_DIR)/libchipmunk.a INCLUDES = -I../include/chipmunk diff --git a/samples/Cpp/HelloCpp/proj.linux/Makefile b/samples/Cpp/HelloCpp/proj.linux/Makefile index 178fa06a86..0548290a52 100644 --- a/samples/Cpp/HelloCpp/proj.linux/Makefile +++ b/samples/Cpp/HelloCpp/proj.linux/Makefile @@ -7,7 +7,7 @@ SOURCES = main.cpp \ ../Classes/HelloWorldScene.cpp COCOS_ROOT = ../../../.. -include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk +include $(COCOS_ROOT)/cocos/2d/cocos2dx.mk SHAREDLIBS += -lcocos2d COCOS_LIBS = $(LIB_DIR)/libcocos2d.so diff --git a/samples/Cpp/SimpleGame/proj.linux/Makefile b/samples/Cpp/SimpleGame/proj.linux/Makefile index 61485ebb7f..9204555b28 100644 --- a/samples/Cpp/SimpleGame/proj.linux/Makefile +++ b/samples/Cpp/SimpleGame/proj.linux/Makefile @@ -8,11 +8,10 @@ SOURCES = main.cpp \ ../Classes/GameOverScene.cpp COCOS_ROOT = ../../../.. -include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk +include $(COCOS_ROOT)/cocos/2d/cocos2dx.mk SHAREDLIBS += -lcocos2d -lcocosdenshion -COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so -INCLUDES += -I$(COCOS_ROOT)/audio/include +INCLUDES += -I$(COCOS_ROOT)/cocos/audio/include $(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) diff --git a/samples/Cpp/TestCpp/proj.linux/Makefile b/samples/Cpp/TestCpp/proj.linux/Makefile index 4dda11cafe..ea1051612c 100644 --- a/samples/Cpp/TestCpp/proj.linux/Makefile +++ b/samples/Cpp/TestCpp/proj.linux/Makefile @@ -2,6 +2,11 @@ EXECUTABLE = TestCpp DEFINES += -DCC_KEYBOARD_SUPPORT +INCLUDES = -I../../../../external \ + -I../../../../cocos/editor-support \ + -I../../../../cocos \ + -I../Classes + SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ ../Classes/ActionManagerTest/ActionManagerTest.cpp \ ../Classes/ActionsEaseTest/ActionsEaseTest.cpp \ @@ -135,22 +140,19 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ SHAREDLIBS = -lcocos2d -lcocosdenshion -lcurl -lpng COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so -include ../../../../cocos2dx/proj.linux/cocos2dx.mk - -INCLUDES += -I../ \ - -I../../ \ - -I../Classes \ - -I$(COCOS_ROOT)/audio/include \ - -I$(COCOS_ROOT)/extensions/ \ - -I$(COCOS_ROOT)/external/ \ - -I$(COCOS_ROOT)/external/chipmunk/include/chipmunk +include ../../../../cocos/2d/cocos2dx.mk STATICLIBS += \ - $(STATICLIBS_DIR)/libcurl.a \ + $(STATICLIBS_DIR)/curl/prebuilt/linux/$(POSTFIX)/libcurl.a \ $(LIB_DIR)/libextension.a \ $(LIB_DIR)/libbox2d.a \ - $(LIB_DIR)/libchipmunk.a + $(LIB_DIR)/libchipmunk.a \ + $(LIB_DIR)/libgui.a \ + $(LIB_DIR)/libcocosbuilder.a \ + $(LIB_DIR)/libspine.a \ + $(LIB_DIR)/libcocostudio.a \ + $(LIB_DIR)/libnetwork.a ####### Build rules $(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) diff --git a/samples/Lua/HelloLua/proj.linux/Makefile b/samples/Lua/HelloLua/proj.linux/Makefile index 1ebb038045..6a0ddf230c 100644 --- a/samples/Lua/HelloLua/proj.linux/Makefile +++ b/samples/Lua/HelloLua/proj.linux/Makefile @@ -1,28 +1,22 @@ EXECUTABLE = HelloLua COCOS_ROOT = ../../../.. -INCLUDES = -I../ -I../Classes -I$(COCOS_ROOT)/audio/include \ - -I$(COCOS_ROOT)/scripting/lua/lua \ - -I$(COCOS_ROOT)/scripting/lua/tolua \ - -I$(COCOS_ROOT)/scripting/lua/cocos2dx_support \ - -I$(COCOS_ROOT)/extensions \ +INCLUDES = -I../Classes \ + -I$(COCOS_ROOT)/audio/include \ + -I$(COCOS_ROOT)/cocos/scripting/lua/bindings \ + -I$(COCOS_ROOT)/external/lua/lua SOURCES = main.cpp ../Classes/AppDelegate.cpp SHAREDLIBS += -lcocos2d -lcocosdenshion -llua -lextension -COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so $(LIB_DIR)/liblua.so -include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk +include $(COCOS_ROOT)/cocos/2d/cocos2dx.mk $(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) - cp -n ../../../../scripting/lua/script/* ../../../../samples/Lua/HelloLua/Resources + cp -n ../../../../cocos/scripting/lua/script/* ../../../../samples/Lua/HelloLua/Resources $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) $(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ diff --git a/samples/Lua/TestLua/proj.linux/Makefile b/samples/Lua/TestLua/proj.linux/Makefile index a23cc6dda4..5151716394 100644 --- a/samples/Lua/TestLua/proj.linux/Makefile +++ b/samples/Lua/TestLua/proj.linux/Makefile @@ -1,22 +1,22 @@ EXECUTABLE = TestLua COCOS_ROOT = ../../../.. -INCLUDES = -I../ -I../Classes -I$(COCOS_ROOT)/audio/include \ - -I$(COCOS_ROOT)/scripting/lua/lua \ - -I$(COCOS_ROOT)/scripting/lua/tolua \ - -I$(COCOS_ROOT)/scripting/lua/cocos2dx_support +INCLUDES = -I../Classes \ + -I$(COCOS_ROOT)/audio/include \ + -I$(COCOS_ROOT)/cocos/scripting/lua/bindings \ + -I$(COCOS_ROOT)/external/lua/lua -SOURCES = main.cpp ../Classes/AppDelegate.cpp +SOURCES = main.cpp \ +../Classes/AppDelegate.cpp SHAREDLIBS += -lcocos2d -lcocosdenshion -llua -COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so $(LIB_DIR)/liblua.so -include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk +include $(COCOS_ROOT)/cocos/2d/cocos2dx.mk $(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) cp -R -n ../../../../samples/Cpp/TestCpp/Resources ../../../../samples/Lua/TestLua - cp -n ../../../../scripting/lua/script/* ../../../../samples/Lua/TestLua/Resources + cp -n ../../../../cocos/scripting/lua/script/* ../../../../samples/Lua/TestLua/Resources $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) $(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) From 3252a8979138bcd7bbada264d733474a6561854f Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Tue, 22 Oct 2013 18:11:07 +0800 Subject: [PATCH 42/48] issues #2905:add SimpleGame vs-project --- .../SimpleGame/proj.win32/SimpleGame.vcxproj | 151 ++++++++++++++++++ .../proj.win32/SimpleGame.vcxproj.filters | 41 +++++ .../proj.win32/SimpleGame.vcxproj.user | 11 ++ samples/Cpp/SimpleGame/proj.win32/main.cpp | 20 +++ samples/Cpp/SimpleGame/proj.win32/main.h | 13 ++ 5 files changed, 236 insertions(+) create mode 100644 samples/Cpp/SimpleGame/proj.win32/SimpleGame.vcxproj create mode 100644 samples/Cpp/SimpleGame/proj.win32/SimpleGame.vcxproj.filters create mode 100644 samples/Cpp/SimpleGame/proj.win32/SimpleGame.vcxproj.user create mode 100644 samples/Cpp/SimpleGame/proj.win32/main.cpp create mode 100644 samples/Cpp/SimpleGame/proj.win32/main.h diff --git a/samples/Cpp/SimpleGame/proj.win32/SimpleGame.vcxproj b/samples/Cpp/SimpleGame/proj.win32/SimpleGame.vcxproj new file mode 100644 index 0000000000..cb3c74751e --- /dev/null +++ b/samples/Cpp/SimpleGame/proj.win32/SimpleGame.vcxproj @@ -0,0 +1,151 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {E0E282F4-8487-452C-BFAB-CB960EB4D22F} + SimpleGame + Win32Proj + + + + Application + Unicode + true + v100 + v110 + v110_xp + + + Application + Unicode + v100 + v110 + v110_xp + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + true + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + false + AllRules.ruleset + + + AllRules.ruleset + + + + + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) + + + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) + + + + Disabled + ..\Classes;$(EngineRoot)cocos\audio\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + 4267;4251;4244;%(DisableSpecificWarnings) + + + $(OutDir)$(ProjectName).exe + $(OutDir);%(AdditionalLibraryDirectories) + true + Windows + MachineX86 + libcocos2d.lib;libchipmunk.lib;%(AdditionalDependencies) + + + + + + + + + MaxSpeed + true + ..\Classes;$(EngineRoot)cocos\audio\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level3 + ProgramDatabase + 4267;4251;4244;%(DisableSpecificWarnings) + + + libcocos2d.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).exe + $(OutDir);%(AdditionalLibraryDirectories) + true + Windows + true + true + MachineX86 + + + + + + + + + + + + + + + + + + + + + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} + false + + + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} + + + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} + + + + + + \ No newline at end of file diff --git a/samples/Cpp/SimpleGame/proj.win32/SimpleGame.vcxproj.filters b/samples/Cpp/SimpleGame/proj.win32/SimpleGame.vcxproj.filters new file mode 100644 index 0000000000..cf39562aaa --- /dev/null +++ b/samples/Cpp/SimpleGame/proj.win32/SimpleGame.vcxproj.filters @@ -0,0 +1,41 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Classes + + + Classes + + + win32 + + + Classes + + + + + Classes + + + Classes + + + win32 + + + Classes + + + \ No newline at end of file diff --git a/samples/Cpp/SimpleGame/proj.win32/SimpleGame.vcxproj.user b/samples/Cpp/SimpleGame/proj.win32/SimpleGame.vcxproj.user new file mode 100644 index 0000000000..32a6296820 --- /dev/null +++ b/samples/Cpp/SimpleGame/proj.win32/SimpleGame.vcxproj.user @@ -0,0 +1,11 @@ + + + + $(ProjectDir)..\Resources + WindowsLocalDebugger + + + $(ProjectDir)..\Resources + WindowsLocalDebugger + + \ No newline at end of file diff --git a/samples/Cpp/SimpleGame/proj.win32/main.cpp b/samples/Cpp/SimpleGame/proj.win32/main.cpp new file mode 100644 index 0000000000..d819bb02e0 --- /dev/null +++ b/samples/Cpp/SimpleGame/proj.win32/main.cpp @@ -0,0 +1,20 @@ +#include "main.h" +#include "../Classes/AppDelegate.h" +#include "CCEGLView.h" + +USING_NS_CC; + +int APIENTRY _tWinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPTSTR lpCmdLine, + int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + + // create the application instance + AppDelegate app; + EGLView eglView; + eglView.init("SimpleGame",900,640); + return Application::getInstance()->run(); +} diff --git a/samples/Cpp/SimpleGame/proj.win32/main.h b/samples/Cpp/SimpleGame/proj.win32/main.h new file mode 100644 index 0000000000..e74708bdf2 --- /dev/null +++ b/samples/Cpp/SimpleGame/proj.win32/main.h @@ -0,0 +1,13 @@ +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +// Windows Header Files: +#include +#include + +// C RunTime Header Files +#include "CCStdC.h" + +#endif // __MAIN_H__ From 51801d9218ee834616ff5f08b6a873ab8e25e78a Mon Sep 17 00:00:00 2001 From: boyu0 Date: Wed, 23 Oct 2013 10:11:08 +0800 Subject: [PATCH 43/48] issue #2771: fix some compile error in android and win32 --- cocos/physics/CCPhysicsJoint.cpp | 18 ++++++------ cocos/physics/CCPhysicsWorld.cpp | 5 ++++ cocos/physics/CCPhysicsWorld.h | 1 + cocos/physics/chipmunk/CCPhysicsJointInfo.cpp | 3 ++ .../Classes/PhysicsTest/PhysicsTest.cpp | 29 +++++++++++++++++++ .../TestCpp/Classes/PhysicsTest/PhysicsTest.h | 9 +++++- 6 files changed, 55 insertions(+), 10 deletions(-) diff --git a/cocos/physics/CCPhysicsJoint.cpp b/cocos/physics/CCPhysicsJoint.cpp index 18f63b7101..09b1de36dd 100644 --- a/cocos/physics/CCPhysicsJoint.cpp +++ b/cocos/physics/CCPhysicsJoint.cpp @@ -103,15 +103,15 @@ void PhysicsJoint::setEnable(bool enable) } } -//PhysicsJointPin::PhysicsJointPin() -//{ -// -//} -// -//PhysicsJointPin::~PhysicsJointPin() -//{ -// -//} +PhysicsJointPin::PhysicsJointPin() +{ + +} + +PhysicsJointPin::~PhysicsJointPin() +{ + +} PhysicsJointFixed::PhysicsJointFixed() { diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index cab183ba7a..ec7514ef6d 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -561,6 +561,11 @@ void PhysicsWorld::rectQuery(PhysicsRectQueryCallback& callback, Rect rect, void } } +Array* getShapesAtPoint(Point point) +{ + +} + Array* PhysicsWorld::getAllBody() const { return _bodys; diff --git a/cocos/physics/CCPhysicsWorld.h b/cocos/physics/CCPhysicsWorld.h index e61cde2763..868889b539 100644 --- a/cocos/physics/CCPhysicsWorld.h +++ b/cocos/physics/CCPhysicsWorld.h @@ -97,6 +97,7 @@ public: void rayCast(PhysicsRayCastCallback& callback, Point point1, Point point2, void* data); void rectQuery(PhysicsRectQueryCallback& callback, Rect rect, void* data); + Array* getShapesAtPoint(Point point); Array* getAllBody() const; /** Register a listener to receive contact callbacks*/ diff --git a/cocos/physics/chipmunk/CCPhysicsJointInfo.cpp b/cocos/physics/chipmunk/CCPhysicsJointInfo.cpp index 7a44587ba5..b3fc376710 100644 --- a/cocos/physics/chipmunk/CCPhysicsJointInfo.cpp +++ b/cocos/physics/chipmunk/CCPhysicsJointInfo.cpp @@ -24,8 +24,11 @@ #include "CCPhysicsJointInfo.h" #if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +#include NS_CC_BEGIN +std::map PhysicsJointInfo::map; + PhysicsJointInfo::PhysicsJointInfo(PhysicsJoint* joint) : joint(joint) { diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index 0c67ddc204..240d3ee2e8 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -673,4 +673,33 @@ void PhysicsDemoRayCast::onTouchesEnded(const std::vector& touches, Even std::string PhysicsDemoRayCast::title() { return "Ray Cast"; +} + + +void PhysicsDemoJoints::onEnter() +{ + PhysicsDemo::onEnter(); + + setTouchEnabled(true); + + _scene->getPhysicsWorld()->setGravity(Point::ZERO); + + +} + +void PhysicsDemoJoints::onTouchesEnded(const std::vector& touches, Event* event) +{ + //Add a new body/atlas sprite at the touched location + + for( auto &touch: touches) + { + auto location = touch->getLocation(); + + + } +} + +std::string PhysicsDemoJoints::title() +{ + return "Joints"; } \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h index 65c1c6bad9..9df12624de 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h @@ -85,7 +85,6 @@ public: void onEnter() override; std::string title() override; void update(float delta) override; - void onTouchesEnded(const std::vector& touches, Event* event) override; void changeModeCallback(Object* sender); @@ -98,4 +97,12 @@ private: int _mode; }; +class PhysicsDemoJoints : public PhysicsDemo +{ +public: + void onEnter() override; + std::string title() override; + void onTouchesEnded(const std::vector& touches, Event* event) override; +}; + #endif From 17422c31235e8cf22e0e9aaca84c325afdbb3fb2 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Wed, 23 Oct 2013 11:08:21 +0800 Subject: [PATCH 44/48] issue #2771: fix some compile error in win32 --- cocos/physics/CCPhysicsShape.h | 14 +++++--------- .../TestCpp/Classes/PhysicsTest/PhysicsTest.cpp | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cocos/physics/CCPhysicsShape.h b/cocos/physics/CCPhysicsShape.h index d1b5e0db04..ebbe646466 100644 --- a/cocos/physics/CCPhysicsShape.h +++ b/cocos/physics/CCPhysicsShape.h @@ -44,15 +44,11 @@ typedef struct PhysicsMaterial float restitution; float friction; - PhysicsMaterial() - : density(0.0f) - , restitution(0.0f) - , friction(0.0f){} - - PhysicsMaterial(float density, float restitution, float friction) - : density(density) - , restitution(restitution) - , friction(friction){} + static PhysicsMaterial make(float density, float restitution, float friction) + { + PhysicsMaterial var = {density, restitution, friction}; + return var; + } }PhysicsMaterial; const PhysicsMaterial PHYSICSSHAPE_MATERIAL_DEFAULT = {0.0f, 1.0f, 1.0f}; diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index 240d3ee2e8..907a0df83a 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -384,7 +384,7 @@ void PhysicsDemoLogoSmash::onEnter() Node* ball = makeBall(2*(x - logo_width/2 + x_jitter) + VisibleRect::getVisibleRect().size.width/2, 2*(logo_height-y + y_jitter) + VisibleRect::getVisibleRect().size.height/2 - logo_height/2, - 0.95f, PhysicsMaterial(1.0f, 0.0f, 0.0f)); + 0.95f, PhysicsMaterial::make(1.0f, 0.0f, 0.0f)); ball->getPhysicsBody()->setMass(1.0); ball->getPhysicsBody()->setMoment(PHYSICS_INFINITY); @@ -396,7 +396,7 @@ void PhysicsDemoLogoSmash::onEnter() } - auto bullet = makeBall(400, 0, 10, PhysicsMaterial(PHYSICS_INFINITY, 0, 0)); + auto bullet = makeBall(400, 0, 10, PhysicsMaterial::make(PHYSICS_INFINITY, 0, 0)); bullet->getPhysicsBody()->setVelocity(Point(400, 0)); bullet->setPosition(Point(-1000, VisibleRect::getVisibleRect().size.height/2)); From dfd69d262aafacea1c77fbb0d932dd549d4c20f2 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Wed, 23 Oct 2013 16:48:51 +0800 Subject: [PATCH 46/48] adjust std:function support 10 parameter --- cocos/2d/cocos2d_headers.props | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/2d/cocos2d_headers.props b/cocos/2d/cocos2d_headers.props index a5d8616d03..020fd07d2f 100644 --- a/cocos/2d/cocos2d_headers.props +++ b/cocos/2d/cocos2d_headers.props @@ -8,6 +8,7 @@ $(EngineRoot)cocos\2d;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath\include;$(EngineRoot)cocos\2d\platform\win32;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES; + _VARIADIC_MAX=10;%(PreprocessorDefinitions) From e81efb24c932275090b45461f2fd4a07279d082d Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 23 Oct 2013 16:49:50 +0800 Subject: [PATCH 47/48] issue #2905: android samples run ok --- .../Cpp/AssetsManagerTest/proj.android/project.properties | 4 ++-- samples/Cpp/HelloCpp/proj.android/project.properties | 5 ++--- samples/Cpp/SimpleGame/proj.android/project.properties | 4 ++-- samples/Cpp/TestCpp/proj.android/project.properties | 4 ++-- .../Javascript/CocosDragonJS/proj.android/project.properties | 4 ++-- .../Javascript/CrystalCraze/proj.android/project.properties | 4 ++-- .../Javascript/MoonWarriors/proj.android/project.properties | 4 ++-- .../TestJavascript/proj.android/project.properties | 4 ++-- .../WatermelonWithMe/proj.android/project.properties | 4 ++-- samples/Lua/HelloLua/proj.android/project.properties | 4 ++-- samples/Lua/TestLua/proj.android/project.properties | 4 ++-- template/multi-platform-cpp/proj.android/project.properties | 4 ++-- template/multi-platform-js/proj.android/project.properties | 2 +- template/multi-platform-lua/proj.android/project.properties | 4 ++-- 14 files changed, 27 insertions(+), 28 deletions(-) diff --git a/samples/Cpp/AssetsManagerTest/proj.android/project.properties b/samples/Cpp/AssetsManagerTest/proj.android/project.properties index 5c08afb38c..f7e62936d0 100644 --- a/samples/Cpp/AssetsManagerTest/proj.android/project.properties +++ b/samples/Cpp/AssetsManagerTest/proj.android/project.properties @@ -11,5 +11,5 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-13 -android.library.reference.1=../../../../cocos2dx/platform/android/java +target=android-10 +android.library.reference.1=../../../../cocos/2d/platform/android/java diff --git a/samples/Cpp/HelloCpp/proj.android/project.properties b/samples/Cpp/HelloCpp/proj.android/project.properties index 088495876a..0a6dc6664d 100644 --- a/samples/Cpp/HelloCpp/proj.android/project.properties +++ b/samples/Cpp/HelloCpp/proj.android/project.properties @@ -8,7 +8,6 @@ # project structure. # Project target. -target=android-13 +target=android-10 -android.library.reference.1=../../../../cocos2dx/platform/android/java -android.library=false +android.library.reference.1=../../../../cocos/2d/platform/android/java diff --git a/samples/Cpp/SimpleGame/proj.android/project.properties b/samples/Cpp/SimpleGame/proj.android/project.properties index 5c08afb38c..f7e62936d0 100644 --- a/samples/Cpp/SimpleGame/proj.android/project.properties +++ b/samples/Cpp/SimpleGame/proj.android/project.properties @@ -11,5 +11,5 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-13 -android.library.reference.1=../../../../cocos2dx/platform/android/java +target=android-10 +android.library.reference.1=../../../../cocos/2d/platform/android/java diff --git a/samples/Cpp/TestCpp/proj.android/project.properties b/samples/Cpp/TestCpp/proj.android/project.properties index db4ff43492..0a6dc6664d 100644 --- a/samples/Cpp/TestCpp/proj.android/project.properties +++ b/samples/Cpp/TestCpp/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-13 +target=android-10 -android.library.reference.1=../../../../cocos2dx/platform/android/java +android.library.reference.1=../../../../cocos/2d/platform/android/java diff --git a/samples/Javascript/CocosDragonJS/proj.android/project.properties b/samples/Javascript/CocosDragonJS/proj.android/project.properties index db4ff43492..0a6dc6664d 100644 --- a/samples/Javascript/CocosDragonJS/proj.android/project.properties +++ b/samples/Javascript/CocosDragonJS/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-13 +target=android-10 -android.library.reference.1=../../../../cocos2dx/platform/android/java +android.library.reference.1=../../../../cocos/2d/platform/android/java diff --git a/samples/Javascript/CrystalCraze/proj.android/project.properties b/samples/Javascript/CrystalCraze/proj.android/project.properties index db4ff43492..0a6dc6664d 100644 --- a/samples/Javascript/CrystalCraze/proj.android/project.properties +++ b/samples/Javascript/CrystalCraze/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-13 +target=android-10 -android.library.reference.1=../../../../cocos2dx/platform/android/java +android.library.reference.1=../../../../cocos/2d/platform/android/java diff --git a/samples/Javascript/MoonWarriors/proj.android/project.properties b/samples/Javascript/MoonWarriors/proj.android/project.properties index db4ff43492..0a6dc6664d 100644 --- a/samples/Javascript/MoonWarriors/proj.android/project.properties +++ b/samples/Javascript/MoonWarriors/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-13 +target=android-10 -android.library.reference.1=../../../../cocos2dx/platform/android/java +android.library.reference.1=../../../../cocos/2d/platform/android/java diff --git a/samples/Javascript/TestJavascript/proj.android/project.properties b/samples/Javascript/TestJavascript/proj.android/project.properties index db4ff43492..0a6dc6664d 100644 --- a/samples/Javascript/TestJavascript/proj.android/project.properties +++ b/samples/Javascript/TestJavascript/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-13 +target=android-10 -android.library.reference.1=../../../../cocos2dx/platform/android/java +android.library.reference.1=../../../../cocos/2d/platform/android/java diff --git a/samples/Javascript/WatermelonWithMe/proj.android/project.properties b/samples/Javascript/WatermelonWithMe/proj.android/project.properties index db4ff43492..0a6dc6664d 100644 --- a/samples/Javascript/WatermelonWithMe/proj.android/project.properties +++ b/samples/Javascript/WatermelonWithMe/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-13 +target=android-10 -android.library.reference.1=../../../../cocos2dx/platform/android/java +android.library.reference.1=../../../../cocos/2d/platform/android/java diff --git a/samples/Lua/HelloLua/proj.android/project.properties b/samples/Lua/HelloLua/proj.android/project.properties index db4ff43492..0a6dc6664d 100644 --- a/samples/Lua/HelloLua/proj.android/project.properties +++ b/samples/Lua/HelloLua/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-13 +target=android-10 -android.library.reference.1=../../../../cocos2dx/platform/android/java +android.library.reference.1=../../../../cocos/2d/platform/android/java diff --git a/samples/Lua/TestLua/proj.android/project.properties b/samples/Lua/TestLua/proj.android/project.properties index db4ff43492..0a6dc6664d 100644 --- a/samples/Lua/TestLua/proj.android/project.properties +++ b/samples/Lua/TestLua/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-13 +target=android-10 -android.library.reference.1=../../../../cocos2dx/platform/android/java +android.library.reference.1=../../../../cocos/2d/platform/android/java diff --git a/template/multi-platform-cpp/proj.android/project.properties b/template/multi-platform-cpp/proj.android/project.properties index 6495217b66..16f145cfc9 100644 --- a/template/multi-platform-cpp/proj.android/project.properties +++ b/template/multi-platform-cpp/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-13 +target=android-10 -android.library.reference.1=../../../cocos2dx/platform/android/java +android.library.reference.1=../../../cocos/2d/platform/android/java diff --git a/template/multi-platform-js/proj.android/project.properties b/template/multi-platform-js/proj.android/project.properties index 6495217b66..f0d6a80641 100644 --- a/template/multi-platform-js/proj.android/project.properties +++ b/template/multi-platform-js/proj.android/project.properties @@ -10,4 +10,4 @@ # Project target. target=android-13 -android.library.reference.1=../../../cocos2dx/platform/android/java +android.library.reference.1=../../../cocos/2d/platform/android/java diff --git a/template/multi-platform-lua/proj.android/project.properties b/template/multi-platform-lua/proj.android/project.properties index 6495217b66..16f145cfc9 100644 --- a/template/multi-platform-lua/proj.android/project.properties +++ b/template/multi-platform-lua/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-13 +target=android-10 -android.library.reference.1=../../../cocos2dx/platform/android/java +android.library.reference.1=../../../cocos/2d/platform/android/java From d07d054a01991fd3b2d9a2c2c36f3194018febf1 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 23 Oct 2013 17:44:20 +0800 Subject: [PATCH 48/48] issue #2905:ndk-r8e build ok now --- cocos/2d/Android.mk | 4 ---- cocos/editor-support/cocostudio/Android.mk | 3 +-- cocos/gui/Android.mk | 14 +++++++++----- samples/Cpp/TestCpp/Android.mk | 5 +++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cocos/2d/Android.mk b/cocos/2d/Android.mk index ec9f2dbf6e..6a25764f44 100644 --- a/cocos/2d/Android.mk +++ b/cocos/2d/Android.mk @@ -203,10 +203,6 @@ LOCAL_EXPORT_CPPFLAGS := -Wno-literal-suffix include $(BUILD_STATIC_LIBRARY) -$(call import-module,jpeg/prebuilt/android) -$(call import-module,png/prebuilt/android) -$(call import-module,tiff/prebuilt/android) -$(call import-module,webp/prebuilt/android) $(call import-module,freetype2/prebuilt/android) $(call import-module,chipmunk) $(call import-module,2d/platform/android) diff --git a/cocos/editor-support/cocostudio/Android.mk b/cocos/editor-support/cocostudio/Android.mk index b9b1535fe6..ea352f8485 100644 --- a/cocos/editor-support/cocostudio/Android.mk +++ b/cocos/editor-support/cocostudio/Android.mk @@ -48,8 +48,7 @@ $(LOCAL_PATH)/../../../external LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../2d \ $(LOCAL_PATH)/../../../external \ $(LOCAL_PATH)/.. \ -$(LOCAL_PATH)/../.. \ -$(LOCAL_PATH)/../../../external +$(LOCAL_PATH)/../.. LOCAL_CFLAGS += -Wno-psabi -fexceptions LOCAL_EXPORT_CFLAGS += -Wno-psabi diff --git a/cocos/gui/Android.mk b/cocos/gui/Android.mk index 49f33a17e6..33171c7c1d 100644 --- a/cocos/gui/Android.mk +++ b/cocos/gui/Android.mk @@ -29,18 +29,22 @@ UISlider.cpp \ UITextField.cpp -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \ +$(LOCAL_PATH)/../editor-support -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../2d \ -$(LOCAL_PATH)/.. +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../2d \ +$(LOCAL_PATH)/../../external \ +$(LOCAL_PATH)/.. \ +$(LOCAL_PATH)/../.. \ +$(LOCAL_PATH)/../editor-support LOCAL_CFLAGS += -Wno-psabi LOCAL_EXPORT_CFLAGS += -Wno-psabi -LOCAL_WHOLE_STATIC_LIBRARIES := cocostudio_static +LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static include $(BUILD_STATIC_LIBRARY) -$(call import-module,editor-support/cocostudio) $(call import-module,extensions) +$(call import-module,2d) diff --git a/samples/Cpp/TestCpp/Android.mk b/samples/Cpp/TestCpp/Android.mk index af16f48433..c848586fbb 100644 --- a/samples/Cpp/TestCpp/Android.mk +++ b/samples/Cpp/TestCpp/Android.mk @@ -141,11 +141,11 @@ Classes/ZwoptexTest/ZwoptexTest.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/Classes -LOCAL_WHOLE_STATIC_LIBRARIES := cocos_extension_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_static +LOCAL_WHOLE_STATIC_LIBRARIES := cocosbuilder_static LOCAL_WHOLE_STATIC_LIBRARIES += spine_static LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/Classes @@ -157,3 +157,4 @@ $(call import-module,editor-support/cocosbuilder) $(call import-module,editor-support/spine) $(call import-module,editor-support/cocostudio) $(call import-module,network) +$(call import-module,2d)