1
PhysicsJoint的使用
T09Join.h |
#ifndef__T09Joint_H__ #define__T09Joint_H__ #include"T32.h" classT09Joint: { public: CREATE_FUNC(T09Joint); voidonEnter(); PhysicsWorld*getPhysicsWorld() { return((Scene*)getParent())->getPhysicsWorld(); } Sprite*_A; Sprite*_B; Sprite*_C; }; #endif |
T09Join.cpp |
#include"T09Join.h" voidT09Joint::onEnter() { Layer::onEnter(); PhysicsBody*bodyA; PhysicsBody*bodyB; { PhysicsBody*body= bodyA= Sprite*sprite= _A= sprite->setContentSize(Size(40,40)); sprite->setPhysicsBody(body); sprite->setPosition(winSize.width/ addChild(sprite); } { //PhysicsBody*body PhysicsBody*body= bodyB= Sprite*sprite= sprite->setContentSize(Size(40,40)); _B= sprite->setPhysicsBody(body); sprite->setPosition(winSize.width/ addChild(sprite); } { PhysicsBody*body= Sprite*sprite= addChild(sprite); sprite->setPhysicsBody(body); sprite->setPosition(winSize.width/ } // // // PhysicsJoint*joint= { autoev= ev->onTouchBegan= Pointpt= if(_A->getBoundingBox().containsPoint(pt)); { _C= returntrue; } if(_B->getBoundingBox().containsPoint(pt)) { _C= returntrue; } returnfalse; }; ev->onTouchEnded= Vec2pt= _C->getPhysicsBody()->setVelocity(Vec2(pt)); }; } } |