From 22e0c657ff8b86fb6541854e5281f0ffff344468 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 31 Jul 2017 10:55:50 +0800 Subject: [PATCH] const reference. --- .../creator/physics/CCPhysicsContactListener.cpp | 8 ++++---- .../creator/physics/CCPhysicsContactListener.h | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.cpp b/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.cpp index 16d304be9c..645eef1f48 100644 --- a/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.cpp +++ b/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.cpp @@ -12,22 +12,22 @@ PhysicsContactListener::PhysicsContactListener() PhysicsContactListener::~PhysicsContactListener() { } -void PhysicsContactListener::setBeginContact(std::function callback) +void PhysicsContactListener::setBeginContact(const std::function& callback) { _beginContact = callback; } -void PhysicsContactListener::setEndContact(std::function callback) +void PhysicsContactListener::setEndContact(const std::function& callback) { _endContact = callback; } -void PhysicsContactListener::setPreSolve(std::function callback) +void PhysicsContactListener::setPreSolve(const std::function& callback) { _preSolve = callback; } -void PhysicsContactListener::setPostSolve(std::function callback) +void PhysicsContactListener::setPostSolve(const std::function& callback) { _postSolve = callback; } diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.h b/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.h index b3434cac50..dea536cb33 100644 --- a/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.h +++ b/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.h @@ -41,16 +41,16 @@ public: PhysicsContactListener(); virtual ~PhysicsContactListener(); - void setBeginContact(std::function callback); - void setEndContact(std::function callback); - void setPreSolve(std::function callback); - void setPostSolve(std::function callback); + void setBeginContact(const std::function& callback); + void setEndContact(const std::function& callback); + void setPreSolve(const std::function& callback); + void setPostSolve(const std::function& callback); - virtual void BeginContact(b2Contact* contact); - virtual void EndContact(b2Contact* contact); - virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold); - virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse); + virtual void BeginContact(b2Contact* contact) override; + virtual void EndContact(b2Contact* contact) override; + virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) override; + virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) override; void registerContactFixture(b2Fixture* fixture); void unregisterContactFixture(b2Fixture* fixture);