本文整理汇总了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;
}
示例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));
}
示例3: toExtensionsMainLayer
void SceneEditorTestLayer::toExtensionsMainLayer(cocos2d::Object *sender)
{
ComAudio *pBackMusic = (ComAudio*)(_curNode->getComponent("CCBackgroundAudio"));
pBackMusic->stopBackgroundMusic();
ExtensionsTestScene *pScene = new ExtensionsTestScene();
pScene->runThisTest();
pScene->release();
}
示例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;
}
示例5: ComAudio
ComAudio* ComAudio::create(void)
{
ComAudio * pRet = new ComAudio();
if (pRet && pRet->init())
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
示例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();
}
}
}
示例7: new
ComAudio* ComAudio::create()
{
ComAudio * pRet = new (std::nothrow) ComAudio();
if (pRet && pRet->init())
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
示例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;
}
示例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);
}
示例10: defaultPlay
void BackgroundComponentTest::defaultPlay()
{
ComAudio *Audio = static_cast<ComAudio*>(_rootNode->getComponent("CCBackgroundAudio"));
Audio->playBackgroundMusic();
}
示例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;
}