issue #2771: fix some compile error in win32

This commit is contained in:
boyu0 2013-10-23 18:52:09 +08:00
parent 912a9a2887
commit a8ddca81bd
4 changed files with 21 additions and 15 deletions

View File

@ -43,7 +43,7 @@ class PhysicsJoint;
class PhysicsBodyInfo; 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. * A body affect by physics.

View File

@ -44,14 +44,20 @@ typedef struct PhysicsMaterial
float restitution; float restitution;
float friction; float friction;
static PhysicsMaterial make(float density, float restitution, float friction) PhysicsMaterial()
{ : density(0.0f)
PhysicsMaterial var = {density, restitution, friction}; , restitution(0.0f)
return var; , friction(0.0f)
} {}
PhysicsMaterial(float density, float restitution, float friction)
: density(density)
, restitution(restitution)
, friction(friction)
{}
}PhysicsMaterial; }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. * @brief A shape for body. You do not create PhysicsWorld objects directly, instead, you can view PhysicsBody to see how to create it.

View File

@ -50,7 +50,7 @@ namespace
return layer; 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, 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, 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()->setMass(1.0);
ball->getPhysicsBody()->setMoment(PHYSICS_INFINITY); 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->getPhysicsBody()->setVelocity(Point(400, 0));
bullet->setPosition(Point(-1000, VisibleRect::getVisibleRect().size.height/2)); bullet->setPosition(Point(-1000, VisibleRect::getVisibleRect().size.height/2));
@ -454,7 +454,7 @@ void PhysicsDemoPyramidStack::onEnter()
{ {
for(int j=0; j<=i; j++) 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; break;
} }
_angle += 0.25f * M_PI / 180.0f; _angle += 0.25f * (float)M_PI / 180.0f;
} }
void PhysicsDemoRayCast::onTouchesEnded(const std::vector<Touch*>& touches, Event* event) void PhysicsDemoRayCast::onTouchesEnded(const std::vector<Touch*>& touches, Event* event)

View File

@ -37,9 +37,9 @@ public:
void toggleDebugCallback(Object* sender); void toggleDebugCallback(Object* sender);
void addGrossiniAtPosition(Point p, float scale = 1.0); 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* 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 = {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 = {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<Touch*>& touches, Event* event) override; void onTouchesBegan(const std::vector<Touch*>& touches, Event* event) override;
void onTouchesMoved(const std::vector<Touch*>& touches, Event* event) override; void onTouchesMoved(const std::vector<Touch*>& touches, Event* event) override;