本文整理汇总了C++中Star::setVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ Star::setVisible方法的具体用法?C++ Star::setVisible怎么用?C++ Star::setVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Star
的用法示例。
在下文中一共展示了Star::setVisible方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addStars
void GameLayer::addStars(void) {
Star * star;
//number of stars and boosts to add to this level
_numStars = _manager->getTotalStars();
int numBoosts = _manager->getBoostNumber();
int cnt = 0;
int i = 0;
int index;
CCPoint starPosition;
CCPoint position;
while (cnt < _numStars) {
starPosition = _manager->starPosition(i);
i++;
//grab stars array index based on selected Grid Cell
index = starPosition.y * _manager->getColumns() + starPosition.x;
if (index >= STARS_IN_POOL) {
continue;
}
//grab position from selected Grid Cell
position.x = starPosition.x * TILE;
position.y = _screenSize.height - starPosition.y * TILE;
//don't use cells too close to moon perch
if (fabs(position.x - _moonStartPoint.x) < _moon->getRadius() * 2 &&
fabs(position.y - _moonStartPoint.y) < _moon->getRadius() * 2) {
continue;
}
//grab star from pool
star = (Star *) _manager->starFromPool(index);
if (star->getParent()) star->removeFromParentAndCleanup(false);
if (star->getOpacity() != 255) star->setOpacity(255);
//add boosts first, if any
if ( cnt >= _numStars - numBoosts) {
star->setValues(position, true);
} else {
star->setValues(position, false);
}
_gameBatchNode->addChild(star, kMiddleground);
star->setVisible(true);
cnt++;
}
}
示例2: 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");
}
}
}
}
}
示例3: createHelpScreen
void HelpLayer::createHelpScreen () {
_bgLight = CCSprite::create("bg_light.jpg");
_bgLight->setPosition(ccp(_screenSize.width * 0.5f, _screenSize.height * 0.5f));
this->addChild(_bgLight, kBackground);
_bgLight->setVisible(false);
_bgLight->setOpacity(0);
_bgDark = CCSprite::create("bg_dark.jpg");
_bgDark->setPosition(ccp(_screenSize.width * 0.5f, _screenSize.height * 0.5f));
this->addChild(_bgDark, kBackground);
_gameBatchNode = CCSpriteBatchNode::create("sprite_sheet.png", 800);
this->addChild(_gameBatchNode, kMiddleground);
_moonPerch = CCSprite::createWithSpriteFrameName("moon_perch.png");
_moonPerch->setPosition(_moonStartPoint);
_moonPerch->setOpacity(50);
_gameBatchNode->addChild(_moonPerch, kBackground);
CCSprite * ground = CCSprite::createWithSpriteFrameName("ground.png");
ground->setAnchorPoint(ccp(0,0));
_gameBatchNode->addChild(ground, kForeground);
_moon = Moon::create();
_moon->setPosition(_moonStartPoint);
_moon->setNextPosition(_moonStartPoint);
_gameBatchNode->addChild(_moon, kMiddleground);
_sun = Sun::create();
_sun->setPosition(ccp(_screenSize.width * 0.5, -_sun->getRadius()));
_sun->setNextPosition(ccp(_screenSize.width * 0.5, -_sun->getRadius()));
_sun->setVisible(false);
_gameBatchNode->addChild(_sun, kMiddleground);
_boostHitParticles = CCParticleSystemQuad::create("boost_hit.plist");
_lineHitParticles = CCParticleSystemQuad::create("line_burst.plist");
_groundHitParticles = CCParticleSystemQuad::create("off_screen.plist");
_starHitParticles = CCParticleSystemQuad::create("star_burst.plist");
_boostHitParticles->stopSystem();
_lineHitParticles->stopSystem();
_groundHitParticles->stopSystem();
_starHitParticles->stopSystem();
this->addChild(_boostHitParticles);
this->addChild(_lineHitParticles);
this->addChild(_groundHitParticles);
this->addChild(_starHitParticles);
_drawLayer = DrawLayer::create();
this->addChild(_drawLayer, kForeground);
_sun->setPosition(ccp(_screenSize.width * 0.5f, -_sun->getRadius()));
_sun->setNextPosition(ccp(_screenSize.width * 0.5f, -_sun->getRadius()));
_sun->setVisible(false);
_sun->reset();
//reset moon and perch
_moon->setPosition(_moonStartPoint);
_moon->setNextPosition(_moonStartPoint);
_moon->reset();
_moonPerch->setOpacity(50);
_starsCollected = false;
_drawLayer->setStartPoint(ccp(0,0));
_drawLayer->setTouchPoint(ccp(0,0));
_bgDark->setOpacity (255);
_bgLight->setOpacity(0);
_starsUpdateIndex = 0;
_starsUpdateRange = 10;
_starsUpdateInterval = 5;
_starsUpdateTimer = 0.0;
//add stars
Star * star;
//number of stars and boosts to add to this level
_numStars = 5;
int numBoosts = 1;
int cnt = 0;
int i = 0;
int index;
CCPoint starPosition;
CCPoint position;
while (cnt < _numStars) {
starPosition = _manager->starPosition(i);
i++;
//.........这里部分代码省略.........