Update physicsTest.

This commit is contained in:
James Chen 2013-10-24 17:46:13 +08:00
parent 7854a13278
commit 9c4bc9e8ed
2 changed files with 9 additions and 6 deletions

View File

@ -511,7 +511,10 @@ PhysicsDemoRayCast::PhysicsDemoRayCast()
void PhysicsDemoRayCast::onEnter()
{
PhysicsDemo::onEnter();
setTouchEnabled(true);
auto listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesEnded = CC_CALLBACK_2(PhysicsDemoRayCast::onTouchesEnded, this);
EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, this);
_scene->getPhysicsWorld()->setGravity(Point::ZERO);
@ -712,7 +715,9 @@ void PhysicsDemoJoints::onEnter()
{
PhysicsDemo::onEnter();
setTouchEnabled(true);
auto listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesEnded = CC_CALLBACK_2(PhysicsDemoJoints::onTouchesEnded, this);
EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, this);
_scene->getPhysicsWorld()->setGravity(Point::ZERO);

View File

@ -90,7 +90,7 @@ public:
void onEnter() override;
std::string title() override;
void update(float delta) override;
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event) override;
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
void changeModeCallback(Object* sender);
@ -110,9 +110,7 @@ public:
public:
void onEnter() override;
std::string title() override;
private:
PhysicsShape* _touchesShape;
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event) override;
};
#endif