[deploy] Merge pull request #43 from KiwanoEngine/dev
Update ContactListener
This commit is contained in:
commit
813b82ccc7
|
|
@ -63,7 +63,7 @@ namespace kiwano
|
|||
PhysicFixture AddChainShape(Vector<Point> const& vertexs, bool loop, float density = 0.f);
|
||||
|
||||
// 삿혤셸야
|
||||
PhysicFixture GetFixtureList() const { KGE_ASSERT(body_); PhysicFixture(body_->GetFixtureList()); }
|
||||
PhysicFixture GetFixtureList() const { KGE_ASSERT(body_); return PhysicFixture(body_->GetFixtureList()); }
|
||||
|
||||
// 盧뇜셸야
|
||||
void RemoveFixture(PhysicFixture const& fixture);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace kiwano
|
|||
|
||||
void PhysicContactDispatcher::StartContactListeners(String const& listener_name)
|
||||
{
|
||||
for (auto listener = listeners_.first_item(); listener; listener = listener->next_item())
|
||||
for (auto listener : listeners_)
|
||||
{
|
||||
if (listener->IsName(listener_name))
|
||||
{
|
||||
|
|
@ -74,7 +74,7 @@ namespace kiwano
|
|||
|
||||
void PhysicContactDispatcher::StopContactListeners(String const& listener_name)
|
||||
{
|
||||
for (auto listener = listeners_.first_item(); listener; listener = listener->next_item())
|
||||
for (auto listener : listeners_)
|
||||
{
|
||||
if (listener->IsName(listener_name))
|
||||
{
|
||||
|
|
@ -97,6 +97,27 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void PhysicContactDispatcher::StartAllContactListeners()
|
||||
{
|
||||
for (auto listener : listeners_)
|
||||
{
|
||||
listener->Start();
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicContactDispatcher::StopAllContactListeners()
|
||||
{
|
||||
for (auto listener : listeners_)
|
||||
{
|
||||
listener->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicContactDispatcher::RemoveAllContactListeners()
|
||||
{
|
||||
listeners_.clear();
|
||||
}
|
||||
|
||||
void PhysicContactDispatcher::OnContactBegin(b2Contact* b2contact)
|
||||
{
|
||||
if (listeners_.empty())
|
||||
|
|
|
|||
|
|
@ -120,6 +120,15 @@ namespace kiwano
|
|||
String const& listener_name
|
||||
);
|
||||
|
||||
// 启动所有监听器
|
||||
void StartAllContactListeners();
|
||||
|
||||
// 停止所有监听器
|
||||
void StopAllContactListeners();
|
||||
|
||||
// 移除所有监听器
|
||||
void RemoveAllContactListeners();
|
||||
|
||||
protected:
|
||||
void OnContactBegin(b2Contact* contact);
|
||||
|
||||
|
|
|
|||
|
|
@ -102,6 +102,8 @@ namespace kiwano
|
|||
contact_listener_ = nullptr;
|
||||
}
|
||||
|
||||
RemoveAllContactListeners();
|
||||
|
||||
// Make sure b2World was destroyed after b2Body
|
||||
RemoveAllChildren();
|
||||
RemoveAllBodies();
|
||||
|
|
@ -110,14 +112,11 @@ namespace kiwano
|
|||
|
||||
void PhysicWorld::RemoveBody(PhysicBody* body)
|
||||
{
|
||||
if (body)
|
||||
{
|
||||
if (body->GetB2Body())
|
||||
if (body && body->GetB2Body())
|
||||
{
|
||||
world_.DestroyBody(body->GetB2Body());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicWorld::RemoveAllBodies()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue