18 #ifndef __CC_COMPLEX_OBSTACLE_H__
19 #define __CC_COMPLEX_OBSTACLE_H__
21 #include <Box2D/Dynamics/Joints/b2Joint.h>
22 #include "CUObstacle.h"
28 #pragma mark Simple Obstacle
71 #pragma mark BodyDef Methods
84 return (_body !=
nullptr ? _body->GetType() : _bodyinfo.type);
100 if (_body !=
nullptr) {
101 _body->SetType(value);
103 _bodyinfo.type = value;
119 if (_body !=
nullptr) {
120 return Vec2(_body->GetPosition().x,_body->GetPosition().y);
122 return Vec2(_bodyinfo.position.x,_bodyinfo.position.y);
148 if (_body !=
nullptr) {
149 _body->SetTransform(b2Vec2(x,y),_body->GetAngle());
151 _bodyinfo.position.Set(x,y);
162 virtual float getX()
const override {
163 return (_body !=
nullptr ? _body->GetPosition().x : _bodyinfo.position.x);
176 virtual void setX(
float value)
override {
177 if (_body !=
nullptr) {
178 _body->SetTransform(b2Vec2(value,_body->GetPosition().y),_body->GetAngle());
180 _bodyinfo.position.x = value;
191 virtual float getY()
const override {
192 return (_body !=
nullptr ? _body->GetPosition().y : _bodyinfo.position.y);
205 virtual void setY(
float value)
override {
206 if (_body !=
nullptr) {
207 _body->SetTransform(b2Vec2(_body->GetPosition().x,value),_body->GetAngle());
209 _bodyinfo.position.y = value;
222 return (_body !=
nullptr ? _body->GetAngle() : _bodyinfo.angle);
236 if (_body !=
nullptr) {
237 _body->SetTransform(_body->GetPosition(),value);
239 _bodyinfo.angle = value;
255 if (_body !=
nullptr) {
256 return Vec2(_body->GetLinearVelocity().x,_body->GetLinearVelocity().y);
258 return Vec2(_bodyinfo.linearVelocity.x,_bodyinfo.linearVelocity.y);
284 if (_body !=
nullptr) {
285 _body->SetLinearVelocity(b2Vec2(x,y));
287 _bodyinfo.linearVelocity.Set(x,y);
298 virtual float getVX()
const override {
299 if (_body !=
nullptr) {
300 return _body->GetLinearVelocity().x;
302 return _bodyinfo.linearVelocity.x;
316 virtual void setVX(
float value)
override {
317 if (_body !=
nullptr) {
318 _body->SetLinearVelocity(b2Vec2(value,_body->GetLinearVelocity().y));
320 _bodyinfo.linearVelocity.x = value;
329 virtual float getVY()
const override {
330 if (_body !=
nullptr) {
331 return _body->GetLinearVelocity().y;
333 return _bodyinfo.linearVelocity.y;
347 virtual void setVY(
float value)
override {
348 if (_body !=
nullptr) {
349 _body->SetLinearVelocity(b2Vec2(value,_body->GetLinearVelocity().y));
351 _bodyinfo.linearVelocity.x = value;
364 return (_body !=
nullptr ? _body->GetAngularVelocity() : _bodyinfo.angularVelocity);
378 if (_body !=
nullptr) {
379 _body->SetAngularVelocity(value);
381 _bodyinfo.angularVelocity = value;
400 return (_body !=
nullptr ? _body->IsActive() : _bodyinfo.active);
417 if (_body !=
nullptr) {
418 _body->SetActive(value);
420 _bodyinfo.active = value;
439 return (_body !=
nullptr ? _body->IsAwake() : _bodyinfo.awake);
456 if (_body !=
nullptr) {
457 _body->SetAwake(value);
459 _bodyinfo.awake = value;
478 return (_body !=
nullptr ? _body->IsSleepingAllowed() : _bodyinfo.allowSleep);
495 if (_body !=
nullptr) {
496 _body->SetSleepingAllowed(value);
498 _bodyinfo.allowSleep = value;
524 return (_body !=
nullptr ? _body->IsBullet() : _bodyinfo.bullet);
547 if (_body !=
nullptr) {
548 _body->SetBullet(value);
550 _bodyinfo.bullet = value;
564 return (_body !=
nullptr ? _body->IsFixedRotation() : _bodyinfo.fixedRotation);
578 if (_body !=
nullptr) {
579 _body->SetFixedRotation(value);
581 _bodyinfo.fixedRotation = value;
598 return (_body !=
nullptr ? _body->GetGravityScale() : _bodyinfo.gravityScale);
613 if (_body !=
nullptr) {
614 _body->SetGravityScale(value);
616 _bodyinfo.gravityScale = value;
638 return (_body !=
nullptr ? _body->GetLinearDamping() : _bodyinfo.linearDamping);
658 if (_body !=
nullptr) {
659 _body->SetLinearDamping(value);
661 _bodyinfo.linearDamping = value;
683 return (_body !=
nullptr ? _body->GetAngularDamping() : _bodyinfo.angularDamping);
703 if (_body !=
nullptr) {
704 _body->SetAngularDamping(value);
706 _bodyinfo.angularDamping = value;
712 #pragma mark FixtureDef Methods
725 virtual void setDensity(
float value)
override;
771 virtual void setSensor(
bool value)
override;
792 #pragma mark MassData Methods
807 if (_body !=
nullptr) {
808 return Vec2(_body->GetLocalCenter().x,_body->GetLocalCenter().y);
810 return Vec2(_massdata.center.x,_massdata.center.y);
836 if (_body !=
nullptr) {
837 _body->SetMassData(&_massdata);
854 return (_body !=
nullptr ? _body->GetInertia() : _massdata.I);
871 if (_body !=
nullptr) {
872 _body->SetMassData(&_massdata);
886 return (_body !=
nullptr ? _body->GetMass() : _massdata.mass);
900 if (_body !=
nullptr) {
901 _body->SetMassData(&_massdata);
914 if (_body !=
nullptr) {
915 _body->ResetMassData();
920 #pragma mark Physics Methods
929 virtual b2Body*
getBody()
const override {
return _body; }
939 const vector<Obstacle*>&
getBodies() {
return _bodies; }
1013 virtual void update(
float delta)
override;
1017 #pragma mark Scene Graph Methods
1095 #pragma mark Initializers
1096 CC_CONSTRUCTOR_ACCESS:
virtual Vec2 getCentroid() const override
Definition: CUComplexObstacle.h:806
virtual void setAngle(float value) override
Definition: CUComplexObstacle.h:235
vector< Obstacle * > _bodies
Definition: CUComplexObstacle.h:63
virtual void setInertia(float value)
Definition: CUObstacle.cpp:126
virtual void setDrawScale(const Vec2 &value) override
Definition: CUComplexObstacle.h:1030
virtual float getAngularDamping() const override
Definition: CUComplexObstacle.h:682
virtual void resetMass() override
Definition: CUComplexObstacle.h:912
virtual void setCentroid(float x, float y) override
Definition: CUComplexObstacle.h:834
virtual void setLinearDamping(float value) override
Definition: CUComplexObstacle.h:657
virtual void setLinearVelocity(float x, float y) override
Definition: CUComplexObstacle.h:283
virtual void releaseFixtures()
Definition: CUComplexObstacle.h:989
virtual void setGravityScale(float value) override
Definition: CUComplexObstacle.h:612
virtual void setSleepingAllowed(bool value) override
Definition: CUComplexObstacle.h:494
virtual float getAngle() const override
Definition: CUComplexObstacle.h:221
virtual void setFriction(float value)
Definition: CUObstacle.h:562
virtual float getVY() const override
Definition: CUComplexObstacle.h:329
virtual float getInertia() const override
Definition: CUComplexObstacle.h:853
virtual void setAwake(bool value) override
Definition: CUComplexObstacle.h:455
virtual void setActive(bool value) override
Definition: CUComplexObstacle.h:416
bool isSceneTracking()
Definition: CUComplexObstacle.h:1059
virtual void setAngularDamping(float value) override
Definition: CUComplexObstacle.h:702
virtual void setFilterData(b2Filter value)
Definition: CUObstacle.h:638
virtual bool createJoints(b2World &world)
Definition: CUComplexObstacle.h:1001
virtual float getY() const override
Definition: CUComplexObstacle.h:191
void setSceneTracking(bool track)
Definition: CUComplexObstacle.h:1071
virtual bool isSleepingAllowed() const override
Definition: CUComplexObstacle.h:477
virtual void resetMass()
Definition: CUObstacle.h:713
Definition: CUComplexObstacle.h:54
virtual float getX() const override
Definition: CUComplexObstacle.h:162
virtual void setSensor(bool value)
Definition: CUObstacle.h:610
b2Body * _body
Definition: CUComplexObstacle.h:61
virtual float getAngularVelocity() const override
Definition: CUComplexObstacle.h:363
virtual b2Body * getBody() const override
Definition: CUComplexObstacle.h:929
virtual void setCentroid(const Vec2 &value)
Definition: CUObstacle.h:662
virtual b2BodyType getBodyType() const override
Definition: CUComplexObstacle.h:83
virtual void positionSceneNode()
Definition: CUObstacle.cpp:240
virtual float getGravityScale() const override
Definition: CUComplexObstacle.h:597
virtual void setBodyType(b2BodyType value) override
Definition: CUComplexObstacle.h:99
virtual void setLinearVelocity(const Vec2 &value) override
Definition: CUComplexObstacle.h:270
virtual bool isFixedRotation() const override
Definition: CUComplexObstacle.h:563
virtual void positionDebugNode()
Definition: CUObstacle.cpp:257
virtual void setVY(float value) override
Definition: CUComplexObstacle.h:347
virtual void setAngularVelocity(float value) override
Definition: CUComplexObstacle.h:377
virtual void setFixedRotation(bool value) override
Definition: CUComplexObstacle.h:577
virtual Vec2 getPosition() const override
Definition: CUComplexObstacle.h:118
virtual Vec2 getLinearVelocity() const override
Definition: CUComplexObstacle.h:254
virtual bool isAwake() const override
Definition: CUComplexObstacle.h:438
virtual bool isActive() const override
Definition: CUComplexObstacle.h:399
virtual void deactivatePhysics(b2World &world)
Definition: CUObstacle.h:895
virtual bool activatePhysics(b2World &world)
Definition: CUObstacle.h:887
virtual void setInertia(float value) override
Definition: CUComplexObstacle.h:869
virtual void setDensity(float value)
Definition: CUObstacle.h:536
virtual void setMass(float value)
Definition: CUObstacle.cpp:142
virtual void setCentroid(const Vec2 &value) override
Definition: CUComplexObstacle.h:822
const vector< Obstacle * > & getBodies()
Definition: CUComplexObstacle.h:939
virtual float getMass() const override
Definition: CUComplexObstacle.h:885
vector< b2Joint * > _joints
Definition: CUComplexObstacle.h:65
virtual void setVX(float value) override
Definition: CUComplexObstacle.h:316
virtual void setY(float value) override
Definition: CUComplexObstacle.h:205
bool _tracking
Definition: CUComplexObstacle.h:67
const vector< b2Joint * > & getJoints()
Definition: CUComplexObstacle.h:949
virtual float getLinearDamping() const override
Definition: CUComplexObstacle.h:637
virtual void setPosition(float x, float y) override
Definition: CUComplexObstacle.h:147
virtual float getVX() const override
Definition: CUComplexObstacle.h:298
Definition: CUObstacle.h:46
virtual void update(float delta)
Definition: CUObstacle.h:910
virtual void setPosition(const Vec2 &value) override
Definition: CUComplexObstacle.h:134
virtual void setBullet(bool value) override
Definition: CUComplexObstacle.h:546
virtual void setDrawScale(const Vec2 &value)
Definition: CUObstacle.h:789
virtual void setRestitution(float value)
Definition: CUObstacle.h:588
virtual void setMass(float value) override
Definition: CUComplexObstacle.h:898
virtual bool isBullet() const override
Definition: CUComplexObstacle.h:523
virtual void setX(float value) override
Definition: CUComplexObstacle.h:176
virtual void createFixtures()
Definition: CUComplexObstacle.h:980