修复了Sprite的碰撞判断bug
This commit is contained in:
parent
282fc1bc38
commit
3e31a3af55
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue