void HelloWorld::check(float df)
{
CCObject* bt;
CCObject* et;
CCARRAY_FOREACH(Enemy1,bt)//遍历所有子弹
{
CCSprite* bullet = (CCSprite*)et;
CCARRAY_FOREACH(Bullet,et)//遍历所有敌机
{
CCSprite*emeny1 = (CCSprite*)et;
if (bullet->boundingBox().intersectsRect(emeny1->boundingBox()))//检测碰撞,即矩形区域是否相交
{
emeny1->stopAllActions();
bullet->stopAllActions();
}
}
}
}
{
CCObject* bt;
CCObject* et;
CCARRAY_FOREACH(Enemy1,bt)//遍历所有子弹
{
CCSprite* bullet = (CCSprite*)et;
CCARRAY_FOREACH(Bullet,et)//遍历所有敌机
{
CCSprite*emeny1 = (CCSprite*)et;
if (bullet->boundingBox().intersectsRect(emeny1->boundingBox()))//检测碰撞,即矩形区域是否相交
{
emeny1->stopAllActions();
bullet->stopAllActions();
}
}
}
}