本文整理汇总了C++中Enemy::getContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Enemy::getContentSize方法的具体用法?C++ Enemy::getContentSize怎么用?C++ Enemy::getContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy::getContentSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerationUFO
void SceneGame::GenerationUFO()
{
float curTimeMillis = getTimeTick();
if (curTimeMillis > _nextUfoSpawn)
{
float randMillisecs = randomValueBetween(0.20, 1.0) * 1000;
_nextUfoSpawn = randMillisecs + curTimeMillis;
float randY = randomValueBetween(0.0, winSize.height);
float randDuration = randomValueBetween(2.0, 10.0);
Enemy *ufo = _ufos.at(_nextUfo);
_nextUfo++;
if (_nextUfo >= _ufos.size())
_nextUfo = 0;
ufo->stopAllActions();
ufo->setPosition(Point(winSize.width + ufo->getContentSize().width / 2, randY));
ufo->setVisible(true);
ufo->runAction(Sequence::create(
MoveBy::create(randDuration, Point(-winSize.width - ufo->getContentSize().width, 0)),
CallFuncN::create(this, callfuncN_selector(SceneGame::setInvisible)),
NULL
));
}
}
示例2: addEnemyToGameLayer
void LevelManager::addEnemyToGameLayer(int type)
{
Size winSize = Director::getInstance()->getWinSize();
EnemyType enemyType = m_enemyType[type];
Enemy * enemy = Enemy::create(enemyType);
Vec2 enemyPos = Vec2( 80 + (winSize.width - 160) * CCRANDOM_0_1(), winSize.height);
Size eSize = enemy->getContentSize();
enemy->setPosition(enemyPos);
Vec2 offset; //= ((GameLayer*)m_gameLayer)->getShip()->getPosition();
Action *tempAction; //= CCMoveTo::create(1, offset);
MoveBy *a0;
MoveBy *a1;
CallFuncN *onComplete;
switch (enemy->getMoveType()) {
case 0:
// 直接冲着你过去
if (((GameLayer*)m_gameLayer)->getShip()) {
offset = ((GameLayer*)m_gameLayer)->getShip()->getPosition();
}else{
offset = Vec2(winSize.width / 2, 0);
}
tempAction = MoveTo::create(1, offset);
break;
case 1:
offset = Vec2(0, -winSize.height - eSize.height);
tempAction = MoveBy::create(4, offset);
break;
case 2:
offset = Vec2(0, -100 - 200 * CCRANDOM_0_1());
a0 = MoveBy::create(0.5, offset);
a1 = MoveBy::create(1, Vec2(-50 - 100 * CCRANDOM_0_1(), 0));
onComplete = CallFuncN::create(CC_CALLBACK_0(LevelManager::repeatAction, this, enemy));
tempAction = Sequence::create(a0, a1, onComplete, NULL);
break;
case 3:
int newX = (enemyPos.x <= winSize.width / 2) ?
(winSize.width - enemyPos.x) : -enemyPos.x;
a0 = MoveBy::create(4, Vec2(newX, -240));
a1 = MoveBy::create(4, Vec2(-newX, -320));
tempAction = Sequence::create(a0, a1, NULL);
break;
}
m_gameLayer->addChild(enemy,enemy->getZOrder());
enemy_items->addObject(enemy);
enemy->runAction(tempAction);
}
示例3: addEnemyToGamelayer
void LevelManager::addEnemyToGamelayer(int type)
{
CCSize winsize = CCDirector::sharedDirector()->getWinSize();
EnemyType enemytype = m_enemytype[type];
Enemy* enemy = Enemy::create(enemytype);
CCPoint enemyPos = ccp(80+(winsize.width-160)*CCRANDOM_0_1(),winsize.height);
CCSize esize = enemy->getContentSize();
enemy->setPosition(enemyPos);
CCPoint offset;
CCAction* tmpaction;
CCMoveBy* a0;
CCMoveBy* a1;
CCCallFuncN* oncomplete;
switch (enemy->getmovetype())
{
case 0:
if (((GameLayer*)m_gamelayer)->getship())
{
offset = ((GameLayer*)m_gamelayer)->getship()->getPosition();
}else
{
offset = ccp(winsize.width/2,0);
}
tmpaction = CCMoveTo::create(1,offset);
break;
case 1:
offset = ccp(0, -winsize.height-esize.height);
tmpaction = CCMoveBy::create(4,offset);
break;
case 2:
offset = ccp(0, -100-200*CCRANDOM_0_1());
a0 = CCMoveBy::create(0.5,offset);
a1 = CCMoveBy::create(1,ccp(-50-100*CCRANDOM_0_1(),0));
oncomplete = CCCallFuncN::create(enemy,callfuncN_selector(LevelManager::repeatAction));
tmpaction = CCSequence::create(a0,a1,oncomplete,NULL);
break;
case 3:
int newx = (enemyPos.x<=winsize.width/2) ? 320 : -320;
a0 = CCMoveBy::create(4,ccp(newx,-240));
a1 = CCMoveBy::create(4,ccp(-newx,-320));
tmpaction = CCSequence::create(a0,a1,NULL);
break;
}
m_gamelayer->addChild(enemy,enemy->getZOrder(),1000);
enemy_items->addObject(enemy);
enemy->runAction(tmpaction);
}