本文整理汇总了C++中Star::update方法的典型用法代码示例。如果您正苦于以下问题:C++ Star::update方法的具体用法?C++ Star::update怎么用?C++ Star::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Star
的用法示例。
在下文中一共展示了Star::update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void GameLayer::update (float dt) {
if (_gameState == kGameStatePlay) {
//if running game logic
if (_running) {
_manager->update(dt);
dt *= DT_RATE;
//update elements
_moon->update(dt);
if (_sun->isVisible()) {
_sun->update(dt);
if (_sun->checkCollisionWithMoon(_moon)) {
SimpleAudioEngine::sharedEngine()->playEffect("sun_hit.wav");
}
}
//check collision with lines, update, draw
Line * line;
int len = _manager->getLines()->count();
bool collisionDetected = false;
for (int i = len-1; i >= 0; i--) {
line = (Line *) _manager->getLines()->objectAtIndex(i);
if (!collisionDetected && line->getActive()) {
if (line->collidesWithMoon(_moon)) {
collisionDetected = true;
SimpleAudioEngine::sharedEngine()->playEffect("line_hit.wav");
_lineHitParticles->setPosition(line->getCollisionPoint());
_lineHitParticles->resetSystem();
}
}
if (line->getTrashme()) {
_manager->getLines()->removeObjectAtIndex(i);
} else {
line->update(dt);
}
}
_moon->place();
//if moon off screen to the top, make screen darker as moons gets farther and farther away
if (_moon->getPositionY() > _screenSize.height) {
if (!_sun->isVisible()) {
float opacity = fabs((255 * (_moon->getPositionY() - _screenSize.height))/_screenSize.height);
if (opacity > 200) opacity = 200;
if (!_sun->isVisible()) _bgDark->setOpacity ( 255 - opacity );
}
} else {
if (!_sun->isVisible()) {
if (_bgDark->getOpacity() != 255) _bgDark->setOpacity ( 255 );
}
}
//track collision with MOON and STAR (usign grid logic)
float range = _moon->getRadius();
float posX = _moon->getPositionX();
float posY = _moon->getPositionY();
//I decided to check 9 cells for precision sake
clearStarAt(ccp(posX, posY));
clearStarAt(ccp(posX, posY + range));
clearStarAt(ccp(posX, posY - range));
clearStarAt(ccp(posX + range, posY));
clearStarAt(ccp(posX + range, posY + range));
clearStarAt(ccp(posX + range, posY - range));
clearStarAt(ccp(posX - range, posY));
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
//.........这里部分代码省略.........