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


C++ ComAudio类代码示例

本文整理汇总了C++中ComAudio的典型用法代码示例。如果您正苦于以下问题:C++ ComAudio类的具体用法?C++ ComAudio怎么用?C++ ComAudio使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ComAudio类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createComAudioWithFlatBuffers

 Component* ComAudioReader::createComAudioWithFlatBuffers(const flatbuffers::Table *comAudioOptions)
 {
     auto options = (ComAudioOptions*)comAudioOptions;
     
     Component* component = ComAudio::create();
     ComAudio* audio = static_cast<ComAudio*>(component);
     
     auto fileNameData = options->fileNameData();
     
     int resourceType = fileNameData->resourceType();
     switch (resourceType)
     {
         case 0:
         {
             std::string path = fileNameData->path()->c_str();
             audio->setFile(path.c_str());
             break;
         }
             
         default:
             break;
     }
     
     bool loop = options->loop() != 0;
     audio->setLoop(loop);
     
     audio->setName(options->name()->c_str());
     
     return component;
 }
开发者ID:114393824,项目名称:PolySprite-for-Cocos2d-x,代码行数:30,代码来源:ComAudioReader.cpp

示例2: 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

示例3: toExtensionsMainLayer

void SceneEditorTestLayer::toExtensionsMainLayer(cocos2d::Object *sender)
{
    ComAudio *pBackMusic = (ComAudio*)(_curNode->getComponent("CCBackgroundAudio"));
    pBackMusic->stopBackgroundMusic();
	ExtensionsTestScene *pScene = new ExtensionsTestScene();
	pScene->runThisTest();
	pScene->release();
}  
开发者ID:csouls,项目名称:nyangame-v3,代码行数:8,代码来源:SceneEditorTest.cpp

示例4: createGameScene

cocos2d::Node* BackgroundComponentTest::createGameScene()
{
    Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/BackgroundComponentTest/BackgroundComponentTest.json");
	if (node == nullptr)
	{
		return nullptr;
	}

	ComAudio *Audio = static_cast<ComAudio*>(node->getComponent("CCBackgroundAudio"));
	Audio->playBackgroundMusic();
    return node;
}
开发者ID:ntotani,项目名称:amiconveyor,代码行数:12,代码来源:SceneEditorTest.cpp

示例5: ComAudio

ComAudio* ComAudio::create(void)
{
    ComAudio * pRet = new ComAudio();
    if (pRet && pRet->init())
    {
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
	return pRet;
}
开发者ID:ElvisQin,项目名称:genius-x,代码行数:13,代码来源:CCComAudio.cpp

示例6: 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

示例7: new

ComAudio* ComAudio::create()
{
    ComAudio * pRet = new (std::nothrow) ComAudio();
    if (pRet && pRet->init())
    {
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
    return pRet;
}
开发者ID:253056965,项目名称:cocos2d-x-lite,代码行数:13,代码来源:CCComAudio.cpp

示例8: loadComAudio

Component* CSLoader::loadComAudio(const rapidjson::Value &json)
{
    ComAudio* audio = ComAudio::create();
    
    const char* name = DICTOOL->getStringValue_json(json, COMPONENT_NAME);
    bool enabled = DICTOOL->getBooleanValue_json(json, COMPONENT_ENABLED);
    
    audio->setName(name);
    audio->setEnabled(enabled);
    
    const char* filePath = DICTOOL->getStringValue_json(json, COMPONENT_AUDIO_FILE_PATH);
    bool loop = DICTOOL->getBooleanValue_json(json, COMPONENT_LOOP);
    
    audio->setFile(filePath);
    audio->setLoop(loop);
    
    
    return audio;
}
开发者ID:MinhHTML5,项目名称:FocusFire,代码行数:19,代码来源:CSLoader.cpp

示例9: CC_BREAK_IF

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

示例10: defaultPlay

void BackgroundComponentTest::defaultPlay()
{
	ComAudio *Audio = static_cast<ComAudio*>(_rootNode->getComponent("CCBackgroundAudio"));
	Audio->playBackgroundMusic();
}
开发者ID:AppleJDay,项目名称:cocos2d-x,代码行数:5,代码来源:SceneEditorTest.cpp

示例11: setPropertyFromJsonDict


//.........这里部分代码省略.........
						std::string plistpath;
						plistpath += file_path;
						plistpath.append(plist);
						cocos2d::Dictionary *root = Dictionary::createWithContentsOfFile(plistpath.c_str());
						Dictionary* metadata = DICTOOL->getSubDictionary(root, "metadata");
						const char* textureFileName = DICTOOL->getStringValue(metadata, "textureFileName");

						std::string textupath;
						textupath += file_path;
						textupath.append(textureFileName);

						cocos2d::extension::armature::ArmatureDataManager::getInstance()->addArmatureFileInfo(textupath.c_str(), plistpath.c_str(), pPath.c_str());

					}

					cocos2d::extension::armature::Armature *pAr = cocos2d::extension::armature::Armature::create(name);
					ComRender *pRender = ComRender::create(pAr, "CCArmature");
					if (pComName != NULL)
					{
						pRender->setName(pComName);
					}
					gb->addComponent(pRender);

					const char *actionName = subDict->getItemStringValue("selectedactionname");
					if (actionName != NULL && pAr->getAnimation() != NULL)
					{
						pAr->getAnimation()->play(actionName);
					}

					CC_SAFE_DELETE(jsonDict);
					CC_SAFE_DELETE(subData);
					CC_SAFE_DELETE_ARRAY(des);
                }
                else if(comName != NULL && strcmp(comName, "CCComAudio") == 0)
                {
					ComAudio *pAudio = NULL;
					if (nResType == 0)
					{
						pAudio = ComAudio::create();
					}
					else
					{
						continue;
					}
                    pAudio->preloadEffect(pPath.c_str());
                    gb->addComponent(pAudio);
                }
                else if(comName != NULL && strcmp(comName, "CCComAttribute") == 0)
                {
                    ComAttribute *pAttribute = NULL;
					if (nResType == 0)
					{
						pAttribute = ComAttribute::create();
						unsigned long size = 0;
						const char* pData = 0;
						pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(), "r", &size));
						if(pData != NULL && strcmp(pData, "") != 0)
						{
							pAttribute->getDict()->initWithDescription(pData);
						}
					}
					else
					{
						CCLOG("unknown resourcetype on CCComAttribute!");
						continue;
					}
开发者ID:mrayy,项目名称:ChampionRun,代码行数:67,代码来源:CCSSceneReader.cpp


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