本文整理汇总了C++中Enemy::collideRect方法的典型用法代码示例。如果您正苦于以下问题:C++ Enemy::collideRect方法的具体用法?C++ Enemy::collideRect怎么用?C++ Enemy::collideRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy::collideRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkIsCollide
void GameLayer::checkIsCollide() {
Enemy *enemy;
Bullet *bullet;
CCObject *it;
CCObject *jt;
CCArray* toRemoveEnemy = new CCArray();
CCArray* toRemoveEnemyBullet = new CCArray();
CCArray* toRemovePlayerBullet = new CCArray();
int exploveCount = 0;
CCARRAY_FOREACH(GV::getInstance()->enemies, it) {
enemy = dynamic_cast<Enemy *>(it);
CCARRAY_FOREACH(GV::getInstance()->player_bullets, jt) {
bullet = dynamic_cast<Bullet *>(jt);
if (bullet->collideRect().intersectsRect(enemy->collideRect())) {
CCSprite *explode = CCSprite::create("hit.jpg");
toRemoveExplove->addObject(explode);
ccBlendFunc cbl = {GL_SRC_ALPHA, GL_ONE};
explode->setBlendFunc(cbl);
explode->setPosition(enemy->getPosition());
explode->setRotation(CCRANDOM_0_1() * 360);
explode->setScale(0.75 * SCALE_FACTOR);
this->addChild(explode, 9999);
explode->runAction(CCScaleBy::create(2, 2, 2));
explode->runAction(CCFadeOut::create(2));
//explode->runAction(CCSequence::create(CCFadeOut::create(2),
// CCCallFunc::create(this, callfunc_selector(GameLayer::removeExplove))));
this->removeChild(bullet, true);
this->removeChild(enemy, true);
toRemovePlayerBullet->addObject(bullet);
toRemoveEnemy->addObject(enemy);
exploveCount++;
}
if (bullet->getPosition().y >= winSize.height || bullet->getPosition().y <= 0) {
this->removeChild(bullet, true);
toRemovePlayerBullet->addObject(bullet);
}
}