From a8ddca81bd165d8d06f04f63d22f7d1d17626440 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Wed, 23 Oct 2013 18:52:09 +0800 Subject: [PATCH] issue #2771: fix some compile error in win32 --- cocos/physics/CCPhysicsBody.h | 2 +- cocos/physics/CCPhysicsShape.h | 18 ++++++++++++------ .../Classes/PhysicsTest/PhysicsTest.cpp | 10 +++++----- .../TestCpp/Classes/PhysicsTest/PhysicsTest.h | 6 +++--- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/cocos/physics/CCPhysicsBody.h b/cocos/physics/CCPhysicsBody.h index 65d9f7318a..f1715b0f1a 100644 --- a/cocos/physics/CCPhysicsBody.h +++ b/cocos/physics/CCPhysicsBody.h @@ -43,7 +43,7 @@ class PhysicsJoint; class PhysicsBodyInfo; -const PhysicsMaterial PHYSICSBODY_MATERIAL_DEFAULT = {1.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/CCPhysicsShape.h b/cocos/physics/CCPhysicsShape.h index ebbe646466..6cd5329f6d 100644 --- a/cocos/physics/CCPhysicsShape.h +++ b/cocos/physics/CCPhysicsShape.h @@ -44,14 +44,20 @@ typedef struct PhysicsMaterial float restitution; float friction; - static PhysicsMaterial make(float density, float restitution, float friction) - { - PhysicsMaterial var = {density, restitution, friction}; - return var; - } + 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}; +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. diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index c92b431716..f0ceb3553c 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -50,7 +50,7 @@ namespace return layer; } - static const Color4F STATIC_COLOR = {1.0f, 0.0f, 0.0f, 1.0f}; + static const Color4F STATIC_COLOR(1.0f, 0.0f, 0.0f, 1.0f); } @@ -411,7 +411,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::make(1.0f, 0.0f, 0.0f)); + 0.95f, PhysicsMaterial(1.0f, 0.0f, 0.0f)); ball->getPhysicsBody()->setMass(1.0); ball->getPhysicsBody()->setMoment(PHYSICS_INFINITY); @@ -423,7 +423,7 @@ void PhysicsDemoLogoSmash::onEnter() } - auto bullet = makeBall(400, 0, 10, PhysicsMaterial::make(PHYSICS_INFINITY, 0, 0)); + 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)); @@ -454,7 +454,7 @@ void PhysicsDemoPyramidStack::onEnter() { for(int j=0; j<=i; j++) { - addGrossiniAtPosition(VisibleRect::bottom() + Point((i/2 - j) * 11, (14 - i) * 23 + 100), 0.2); + addGrossiniAtPosition(VisibleRect::bottom() + Point((i/2 - j) * 11, (14 - i) * 23 + 100), 0.2f); } } } @@ -671,7 +671,7 @@ void PhysicsDemoRayCast::update(float delta) break; } - _angle += 0.25f * M_PI / 180.0f; + _angle += 0.25f * (float)M_PI / 180.0f; } void PhysicsDemoRayCast::onTouchesEnded(const std::vector& touches, Event* event) diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h index b915e9d664..0c685ef98e 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h @@ -37,9 +37,9 @@ 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}); + Sprite* makeBall(float x, float y, float radius, PhysicsMaterial material = PhysicsMaterial(1.0f, 1.0f, 1.0f)); + Sprite* makeBox(float x, float y, Size size, PhysicsMaterial material = PhysicsMaterial(1.0f, 1.0f, 1.0f)); + Sprite* makeTriangle(float x, float y, Size size, PhysicsMaterial material = PhysicsMaterial(1.0f, 1.0f, 1.0f)); void onTouchesBegan(const std::vector& touches, Event* event) override; void onTouchesMoved(const std::vector& touches, Event* event) override;