本文整理汇总了C++中BaseSprite::setFlippedX方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseSprite::setFlippedX方法的具体用法?C++ BaseSprite::setFlippedX怎么用?C++ BaseSprite::setFlippedX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseSprite
的用法示例。
在下文中一共展示了BaseSprite::setFlippedX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initBSandMagic
void SpriteSystem::initBSandMagic()
{
//初始化人物
struct _stHeroConf
{
float spScale[3];//缩放
Point spPosStart[3];//起始位置
Point spPosEnd[3];//结束位置
bool spFlip[3];//是否翻转,英雄翻转,敌人不翻转,面对面
_stHeroConf()
{
spScale[0] = 1.5f; spScale[1] = 1.5f; spScale[2] = 1.5f;
spFlip[0] = true; spFlip[1] = true; spFlip[2] = true;
spPosStart[0] = PointS_1; spPosStart[1] = PointS_2; spPosStart[2] = PointS_3;
spPosEnd[0] = PointE_1; spPosEnd[1] = PointE_2; spPosEnd[2] = PointE_3;
}
}_stHeroConf;
struct _stEnemyConf
{
float spScale[3];//缩放
Point spPosStart[3];//起始位置
Point spPosEnd[3];//结束位置
bool spFlip[3];//是否翻转,英雄翻转,敌人不翻转,面对面
_stEnemyConf()
{
spScale[0] = 1.5f; spScale[1] = 1.5f; spScale[2] = 1.5f;
spFlip[0] = false; spFlip[1] = false; spFlip[2] = false;
spPosStart[0] = PointS_4; spPosStart[1] = PointS_5; spPosStart[2] = PointS_6;
spPosEnd[0] = PointE_4; spPosEnd[1] = PointE_5; spPosEnd[2] = PointE_6;
}
}_stEnemyConf;
//初始化英雄和敌人
for (unsigned int i = 0; i < 3; i++)
{
BaseSprite* hero = BaseSprite::create(m_bsConf[i]);
hero->setScale(_stHeroConf.spScale[i]);
hero->setPosition(_stHeroConf.spPosStart[i]);
hero->setFlippedX(_stHeroConf.spFlip[i]);
hero->startAction(SPRITESTATE_IDLE);
hero->move(MoveType_To, _stHeroConf.spPosEnd[i], 4.5f);//执行完有回调
addChild(hero,1);
//加入向量
m_vHeros.pushBack(hero);
BaseSprite* enemy = BaseSprite::create(m_bsConf[i+3]);
enemy->setScale(_stEnemyConf.spScale[i]);
enemy->setPosition(_stEnemyConf.spPosStart[i]);
enemy->setFlippedX(_stEnemyConf.spFlip[i]);
enemy->startAction(SPRITESTATE_IDLE);
enemy->move(MoveType_To, _stEnemyConf.spPosEnd[i], 4.5f);//执行完有回调
addChild(enemy,1);
//加入向量
m_vEnemys.pushBack(enemy);
Node* node = Node::create();
Sprite* lifebg = Sprite::create(s_ptBg);//背景
m_ptLifeTop[i] = ProgressTimer::create(Sprite::create(s_ptLife2));//进度条
m_ptLifeTop[i]->setType(ProgressTimer::Type::BAR);//条形
m_ptLifeTop[i]->setMidpoint(Point::ANCHOR_MIDDLE_LEFT);//(0,0.5)锚点为增长原点
m_ptLifeTop[i]->setBarChangeRate(Point::ANCHOR_MIDDLE_RIGHT);//向(1,0.5)增长
m_ptLifeTop[i]->setPercentage(100);
node->setPosition(enemy->getContentSize().width/2,enemy->getContentSize().height*0.8);
enemy->addChild(node);
node->addChild(lifebg, 0);
node->addChild(m_ptLifeTop[i], 1);
node->setScale(0.8);
//添加敌人生命值
}
setAttackTarget();//设置攻击目标
// //初始化技能、远程攻击 --》不能这样,因为多个英雄释放同一种技能时,会重复addChild
// for(int i = 0; i < 5; i++)
// {
// Magic* magic = Magic::create(m_magConf[i]);
// m_vMagics.pushBack(magic);//这里会retain一下
// }
scheduleUpdate();
}