当前位置: 首页>>代码示例>>C++>>正文


C++ ComAudio::playEffect方法代码示例

本文整理汇总了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));
}
开发者ID:CanFengHome,项目名称:Cocos2dXPractice,代码行数:30,代码来源:BulletController.cpp

示例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();
		}
	}
}
开发者ID:ntotani,项目名称:amiconveyor,代码行数:13,代码来源:SceneEditorTest.cpp

示例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);
}
开发者ID:eoeuou,项目名称:HelloGame,代码行数:19,代码来源:acts.cpp


注:本文中的ComAudio::playEffect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。