本文整理汇总了C++中Star::getIsBoost方法的典型用法代码示例。如果您正苦于以下问题:C++ Star::getIsBoost方法的具体用法?C++ Star::getIsBoost怎么用?C++ Star::getIsBoost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Star
的用法示例。
在下文中一共展示了Star::getIsBoost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clearStarAt
void GameLayer::clearStarAt(CCPoint point) {
int col = (int) point.x / TILE;
int row = (int) (_screenSize.height - point.y) / TILE;
if (row < 0 || col < 0 || row >= _manager->getRows() || col >= _manager->getColumns() ||
row * _manager->getColumns() + col >= STARS_IN_POOL) {
return;
}
//identify cell in array
Star * star = _manager->starFromPool(row * _manager->getColumns() + col);
//CCLOG ("COL: %i ROW: %i", col, row);
if (star->isVisible()) {
float diffx = _moon->getPositionX() - star->getPositionX();
float diffy = _moon->getPositionY() - star->getPositionY();
if ((diffx * diffx + diffy * diffy) <= _moon->getSquaredRadius()) {
int starsCollected = _manager->getCollectedStars();
int totalStarsCollected = _manager->getTotalCollectedStars();
starsCollected++;
totalStarsCollected++;
_manager->setCollectedStars(starsCollected);
_manager->setTotalCollectedStars(totalStarsCollected);
star->setVisible(false);
int totalStars = _manager->getTotalStars();
//did we hit a boost?
if (star->getIsBoost()) {
_manager->setBoosting(true);
if (starsCollected != totalStars) {
_boostHitParticles->setPosition(star->getPosition());
_boostHitParticles->resetSystem();
}
}
//if last star on screen, show particles, show Moon Perch...
if (starsCollected == totalStars) {
SimpleAudioEngine::sharedEngine()->playEffect("last_star_hit.wav");
_starHitParticles->setPosition(star->getPosition());
_starHitParticles->resetSystem();
_starsCollected = true;
if (_sun->isVisible()) {
_moonPerch->setOpacity(100);
} else {
_moonPerch->setOpacity(200);
}
} else {
if (star->getIsBoost()) {
SimpleAudioEngine::sharedEngine()->playEffect("boost_hit.wav");
} else {
SimpleAudioEngine::sharedEngine()->playEffect("star_hit.wav");
}
}
}
}
}
示例2: update
//.........这里部分代码省略.........
clearStarAt(ccp(posX - range, posY - range));
clearStarAt(ccp(posX - range, posY + range));
//update bars
//check timer
if (_manager->getTime() <= 0.65f && !_sun->isVisible()) {
SimpleAudioEngine::sharedEngine()->playEffect("sun_rise.wav");
_sun->setVisible(true);
_sun->setHasRisen(false);
} else if (_manager->getTime() <= 0.25f && _sun->isVisible() && !_sun->getHasGrown()) {
SimpleAudioEngine::sharedEngine()->playEffect("sun_grow.wav");
_sun->highNoon();
} else if (_manager->getTime() <= 0.0f) {
//if you want game over once time runs out.
//game;
}
if (_sun->isVisible()) {
if (!_bgLight->isVisible()) {
_bgLight->setVisible(true);
}
//when sun is added to screen, fade out dark bg
if (_bgLight->getOpacity() + 5 < 255) {
_bgLight->setOpacity(_bgLight->getOpacity() + 5 );
_bgDark->setOpacity (_bgDark->getOpacity() - 5);
} else {
_bgDark->setVisible(false);
_bgDark->setOpacity(255);
_bgLight->setOpacity(255);
}
_sun->place();
}
//check power
if (_manager->getLineEnergy() <= 0) {
if (!_moon->getIsOff()) {
_moon->turnOnOff(false);
}
}
//track collision between Moon and Moon's perch
if (_starsCollected) {
if (pow (_moonStartPoint.x - _moon->getPositionX(), 2) +
pow (_moonStartPoint.y - _moon->getPositionY(), 2) < _moon->getSquaredRadius()) {
_moon->setPosition(_moonStartPoint);
_moon->setNextPosition(_moonStartPoint);
_moon->setActive(false);
newLevel();
}
}
if (_moon->getPositionY() < _moon->getRadius() && _moon->getActive()) {
_groundHitParticles->setPosition(_moon->getPosition());
_groundHitParticles->resetSystem();
SimpleAudioEngine::sharedEngine()->playEffect("ground_hit.wav");
_moon->setActive(false);
gameOver();
}
//make stars blink
if (!_sun->isVisible()) {
_starsUpdateTimer += dt;
int stars_count = _numStars;
if (_starsUpdateTimer > _starsUpdateInterval) {
if (stars_count - _starsUpdateIndex < _starsUpdateRange) {
_starsUpdateIndex = 0;
} else if (_starsUpdateIndex + _starsUpdateRange > stars_count - 1) {
_starsUpdateIndex += stars_count - _starsUpdateIndex - 1;
} else {
_starsUpdateIndex += _starsUpdateRange;
}
_starsUpdateTimer = 0;
_starsUpdateInterval = ((float)rand() / RAND_MAX) * 5;
}
//update stars within update range
Star * star;
for (int i = _starsUpdateIndex; i < _starsUpdateIndex + _starsUpdateRange; i++) {
if (i < stars_count) {
CCPoint point = _manager->starPosition(i);
int index = point.y * _manager->getColumns() + point.x;
if (index >= STARS_IN_POOL) index = STARS_IN_POOL - 1;
//identify cell in array
star = _manager->starFromPool(index);
if (star->isVisible() && !star->getIsBoost()) star->update(dt);
}
}
}
}
}
}