现在的位置: 首页 > 综合 > 正文

cocos2d CCRect 判断碰撞

2013年10月20日 ⁄ 综合 ⁄ 共 351字 ⁄ 字号 评论关闭
auto getTargetRect = [](CCNode* node) -> CCRect { return CCRectMake(node->getPosition().x ,node->getPosition().y ,node->getContentSize().width,node->getContentSize().height); };

CCRect nodeRect   = getTargetRect(m_node               );
CCRect targetRect = getTargetRect(m_vector_daoju.at(i) );

if (nodeRect.intersectsRect(targetRect) == true)
{
	// 碰撞到处理代码
	m_vector_daoju.at(i)->setVisible(false);
}

抱歉!评论已关闭.