diff --git a/Easy2D/Object/BatchNode.cpp b/Easy2D/Object/BatchNode.cpp index 316c40b8..1c05f832 100644 --- a/Easy2D/Object/BatchNode.cpp +++ b/Easy2D/Object/BatchNode.cpp @@ -38,13 +38,15 @@ void BatchNode::_onDraw() return; } - // 在相对位置绘制子节点 - App::setOrigin(App::getOriginX() + getX(), App::getOriginY() + getY()); for (auto child : m_vChildren) { + // 将子节点移动到相对位置 + child->move(getX(), getY()); + // 绘制子节点 child->_onDraw(); + // 将子节点移回原位 + child->move(-getX(), -getY()); } - App::setOrigin(App::getOriginX() - getX(), App::getOriginY() - getY()); } void BatchNode::add(Node * child, int z_Order) diff --git a/Easy2D/Object/BatchSprite.cpp b/Easy2D/Object/BatchSprite.cpp index 4170629d..cd36394e 100644 --- a/Easy2D/Object/BatchSprite.cpp +++ b/Easy2D/Object/BatchSprite.cpp @@ -99,12 +99,15 @@ void BatchSprite::_onDraw() } // 在相对位置绘制子节点 - App::setOrigin(App::getOriginX() + getX(), App::getOriginY() + getY()); for (auto sprite : m_vSprites) { + // 将子节点移动到相对位置 + sprite->move(getX(), getY()); + // 绘制子节点 sprite->_onDraw(); + // 将子节点移回原位 + sprite->move(-getX(), -getY()); } - App::setOrigin(App::getOriginX() - getX(), App::getOriginY() - getY()); } Sprite * BatchSprite::isCollisionWith(Sprite * sprite) diff --git a/Easy2D/Object/Sprite.cpp b/Easy2D/Object/Sprite.cpp index e2f59d23..0daf260d 100644 --- a/Easy2D/Object/Sprite.cpp +++ b/Easy2D/Object/Sprite.cpp @@ -60,7 +60,7 @@ void Sprite::setImage(Image * image) bool Sprite::isCollisionWith(Sprite * sprite) { - return IntersectRect(NULL, &getRect(), &sprite->getRect()); + return IntersectRect(new CRect(), &getRect(), &sprite->getRect()); } void Sprite::addAction(Action * action)