一次碰撞触发两次碰撞事件,两次都调用Scene::onCollision
This commit is contained in:
parent
be8972f52a
commit
85a4c0584a
|
|
@ -70,8 +70,14 @@ void e2d::CollisionManager::__updateCollider(Collider* collider)
|
||||||
if (relation != Collider::Relation::Unknown &&
|
if (relation != Collider::Relation::Unknown &&
|
||||||
relation != Collider::Relation::Disjoin)
|
relation != Collider::Relation::Disjoin)
|
||||||
{
|
{
|
||||||
active->onCollision(Collision(passive, relation));
|
// 触发两次碰撞事件
|
||||||
passive->onCollision(Collision(active, relation));
|
Collision activeCollision(passive, relation);
|
||||||
|
active->getParentScene()->onCollision(activeCollision);
|
||||||
|
active->onCollision(activeCollision);
|
||||||
|
|
||||||
|
Collision passiveCollision(active, passive->getCollider()->getRelationWith(active->getCollider()));
|
||||||
|
passive->getParentScene()->onCollision(passiveCollision);
|
||||||
|
passive->onCollision(passiveCollision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ void e2d::Node::_render()
|
||||||
// 转换渲染器的二维矩阵
|
// 转换渲染器的二维矩阵
|
||||||
Renderer::getInstance()->getRenderTarget()->SetTransform(_finalMatri);
|
Renderer::getInstance()->getRenderTarget()->SetTransform(_finalMatri);
|
||||||
// 渲染自身
|
// 渲染自身
|
||||||
//this->onRender();
|
this->onRender();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -174,7 +174,7 @@ void e2d::Node::_render()
|
||||||
// 转换渲染器的二维矩阵
|
// 转换渲染器的二维矩阵
|
||||||
Renderer::getInstance()->getRenderTarget()->SetTransform(_finalMatri);
|
Renderer::getInstance()->getRenderTarget()->SetTransform(_finalMatri);
|
||||||
// 渲染自身
|
// 渲染自身
|
||||||
//this->onRender();
|
this->onRender();
|
||||||
|
|
||||||
// 访问剩余节点
|
// 访问剩余节点
|
||||||
for (; i < _children.size(); ++i)
|
for (; i < _children.size(); ++i)
|
||||||
|
|
|
||||||
|
|
@ -911,6 +911,9 @@ public:
|
||||||
// 说明:返回 false 将阻止消息继续传递
|
// 说明:返回 false 将阻止消息继续传递
|
||||||
virtual bool onMouseEvent(MouseEvent e) { return true; }
|
virtual bool onMouseEvent(MouseEvent e) { return true; }
|
||||||
|
|
||||||
|
// ÅöײÏûÏ¢
|
||||||
|
virtual void onCollision(Collision collision) { }
|
||||||
|
|
||||||
// 关闭窗口
|
// 关闭窗口
|
||||||
// 说明:返回 false 将阻止窗口关闭
|
// 说明:返回 false 将阻止窗口关闭
|
||||||
virtual bool onCloseWindow() { return true; }
|
virtual bool onCloseWindow() { return true; }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue