diff --git a/core/Manager/CollisionManager.cpp b/core/Manager/CollisionManager.cpp index 08c5ffce..bca87b15 100644 --- a/core/Manager/CollisionManager.cpp +++ b/core/Manager/CollisionManager.cpp @@ -70,8 +70,14 @@ void e2d::CollisionManager::__updateCollider(Collider* collider) if (relation != Collider::Relation::Unknown && 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); } } } diff --git a/core/Node/Node.cpp b/core/Node/Node.cpp index 661ee7d9..29bed8c6 100644 --- a/core/Node/Node.cpp +++ b/core/Node/Node.cpp @@ -149,7 +149,7 @@ void e2d::Node::_render() // 转换渲染器的二维矩阵 Renderer::getInstance()->getRenderTarget()->SetTransform(_finalMatri); // 渲染自身 - //this->onRender(); + this->onRender(); } else { @@ -174,7 +174,7 @@ void e2d::Node::_render() // 转换渲染器的二维矩阵 Renderer::getInstance()->getRenderTarget()->SetTransform(_finalMatri); // 渲染自身 - //this->onRender(); + this->onRender(); // 访问剩余节点 for (; i < _children.size(); ++i) diff --git a/core/e2dcommon.h b/core/e2dcommon.h index c07a9f00..98690f0b 100644 --- a/core/e2dcommon.h +++ b/core/e2dcommon.h @@ -911,6 +911,9 @@ public: // 说明:返回 false 将阻止消息继续传递 virtual bool onMouseEvent(MouseEvent e) { return true; } + // 碰撞消息 + virtual void onCollision(Collision collision) { } + // 关闭窗口 // 说明:返回 false 将阻止窗口关闭 virtual bool onCloseWindow() { return true; }