本文整理汇总了C++中ComAudio::playEffect方法的典型用法代码示例。如果您正苦于以下问题:C++ ComAudio::playEffect方法的具体用法?C++ ComAudio::playEffect怎么用?C++ ComAudio::playEffect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComAudio
的用法示例。
在下文中一共展示了ComAudio::playEffect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onAdd
void BulletController::onAdd()
{
ComController::onAdd();
ComAudio* pSceneAudio = static_cast<ComAudio*>(_owner->getComponent("CCComAudio"));
if (pSceneAudio)
{
pSceneAudio->playEffect("res/sound/pew-pew-lei.wav");
}
LayerMainGame* pMainGameLyr = dynamic_cast<LayerMainGame*>(_owner->getParent());
if (pMainGameLyr == nullptr)
{
return;
}
Vec2 playerPosition = pMainGameLyr->getPlayerSprite()->getPosition();
Size winSize = Director::getInstance()->getWinSize();
Vec2 touchDir = m_ptTouch-playerPosition;
_owner->setPosition(playerPosition);
float targetDis = fabs(touchDir.length() * winSize.width / (m_ptTouch.x - playerPosition.x));
touchDir.normalize();
Vec2 ptTarget = playerPosition + targetDis*touchDir;
float velocity = 480/1; // 480pixels/1sec
float realMoveDuration = targetDis/velocity;
ActionInterval* pMoveAction = MoveTo::create(realMoveDuration, ptTarget);
_owner->runAction(Sequence::create(pMoveAction, RemoveSelf::create(), nullptr));
}
示例2: animationEvent
void EffectComponentTest::animationEvent(Armature *armature, MovementEventType movementType, const std::string& movementID)
{
std::string id = movementID;
if (movementType == LOOP_COMPLETE)
{
if (id.compare("Fire") == 0)
{
ComAudio *pAudio = static_cast<ComAudio*>(_node->getChildByTag(10015)->getComponent("CCComAudio"));
pAudio->playEffect();
}
}
}
示例3: done
void PlayMusic::done()
{
do
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
CC_BREAK_IF(node == nullptr);
ComAudio *audio = (ComAudio*)(node->getComponent(_comName.c_str()));
CC_BREAK_IF(audio == nullptr);
if (_type == 0)
{
audio->playBackgroundMusic();
}
else if (_type == 1)
{
audio->playEffect();
}
} while (0);
}