PuzzleSDK
AudioProfileTest类 参考

#include <NewAudioEngineTest.h>

+ 类 AudioProfileTest 继承关系图:
+ AudioProfileTest 的协作图:

Public 成员函数

 CREATE_FUNC (AudioProfileTest)
 
virtual ~AudioProfileTest ()
 
virtual bool init () override
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
virtual void update (float dt) override
 
- Public 成员函数 继承自 AudioEngineTestDemo
 AudioEngineTestDemo ()
 
virtual void onExit () override
 
virtual void onBackCallback (cocos2d::Ref *sender) override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 
virtual void onEnter () override
 

Private 属性

std::string _files [FILE_COUNT]
 
cocos2d::AudioProfile _audioProfile
 
int _audioCount
 
cocos2d::Label * _showLabel
 
float _time
 
float _minDelay
 
void * _timeSlider
 

静态 Private 属性

static const int FILE_COUNT = 2
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 AudioEngineTestDemo
std::shared_ptr< bool > _isDestroyed
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 NewAudioEngineTest.h97 行定义.

构造及析构函数说明

◆ ~AudioProfileTest()

AudioProfileTest::~AudioProfileTest ( )
virtual

在文件 NewAudioEngineTest.cpp583 行定义.

584{
585}

成员函数说明

◆ CREATE_FUNC()

AudioProfileTest::CREATE_FUNC ( AudioProfileTest  )

◆ init()

bool AudioProfileTest::init ( )
overridevirtual

在文件 NewAudioEngineTest.cpp499 行定义.

500{
501 auto ret = AudioEngineTestDemo::init();
502
503 char text[30];
504 _files[0] = "background.mp3";
505#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
506 _files[1] = "background.caf";
507#else
508 _files[1] = "background.ogg";
509#endif
510
511 std::string fontFilePath = "fonts/arial.ttf";
512 _minDelay = 1.0f;
513 _time = 0.0f;
514
515 _audioProfile.name = "AudioProfileTest";
516 _audioProfile.maxInstances = 3;
517 _audioProfile.minDelay = 1.0;
518
519 Vec2 pos(0.5f,0.7f);
520 for(int index = 0; index < FILE_COUNT; ++index){
521 sprintf(text,"play %s",_files[index].c_str());
522
523 auto playItem = TextButton::create(text, [&](TextButton* button){
524 int index = button->getTag();
525 auto id = AudioEngine::play2d(_files[index], false, 1.0f, &_audioProfile);
526 if(id != AudioEngine::INVALID_AUDIO_ID){
528 _audioCount += 1;
529 char show[30];
530 sprintf(show,"audio count:%d",_audioCount);
531 _showLabel->setString(show);
532
533 AudioEngine::setFinishCallback(id, [&](int id, const std::string& filePath){
534 _audioCount -= 1;
535 char show[30];
536 sprintf(show,"audio count:%d",_audioCount);
537 _showLabel->setString(show);
538 });
539 }
540
541 });
542 playItem->setTag(index);
543 playItem->setPositionNormalized(pos);
544 this->addChild(playItem);
545 pos.y -= 0.15f;
546
547 }
548
549 Vec2 origin = Director::getInstance()->getVisibleOrigin();
550 Size size = Director::getInstance()->getVisibleSize();
551
552 auto profileInfoLabel = Label::createWithTTF("AudioProfile Info:\n max instance:3 \n minimum delay:1.0", fontFilePath, 12);
553 profileInfoLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
554 profileInfoLabel->setPosition(Vec2(origin.x, origin.y + size.height * 0.65f));
555 addChild(profileInfoLabel);
556
557 _audioCount = 0;
558 _showLabel = Label::createWithTTF("audio count:0", fontFilePath, 12);
559 _showLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
560 _showLabel->setPosition(Vec2(origin.x, origin.y + size.height * 0.5f));
561 addChild(_showLabel);
562
563 auto timeSlider = SliderEx::create();
564 timeSlider->setEnabled(false);
565 timeSlider->setPositionNormalized(pos);
566 addChild(timeSlider);
567 _timeSlider = timeSlider;
568
569 this->schedule(CC_CALLBACK_1(AudioProfileTest::update, this), 0.05f, "update_key");
570
571 return ret;
572}
std::string _files[FILE_COUNT]
cocos2d::AudioProfile _audioProfile
cocos2d::Label * _showLabel
virtual void update(float dt) override
static const int FILE_COUNT

引用了 _audioCount, _audioProfile, _files, _minDelay, _showLabel, _time, _timeSlider, FILE_COUNT , 以及 update().

+ 函数调用图:

◆ subtitle()

std::string AudioProfileTest::subtitle ( ) const
overridevirtual

重载 TestCase .

在文件 NewAudioEngineTest.cpp592 行定义.

593{
594 return "See the console.";
595}

◆ title()

std::string AudioProfileTest::title ( ) const
overridevirtual

重载 AudioEngineTestDemo .

在文件 NewAudioEngineTest.cpp587 行定义.

588{
589 return "AudioProfileTest";
590}

◆ update()

void AudioProfileTest::update ( float  dt)
overridevirtual

在文件 NewAudioEngineTest.cpp574 行定义.

575{
576 if(_time > 0.0f)
577 {
578 _time -= dt;
579 ((SliderEx*)_timeSlider)->setRatio(_time / _minDelay);
580 }
581}

引用了 _minDelay, _time , 以及 _timeSlider.

被这些函数引用 init().

+ 这是这个函数的调用关系图:

类成员变量说明

◆ _audioCount

int AudioProfileTest::_audioCount
private

在文件 NewAudioEngineTest.h116 行定义.

被这些函数引用 init().

◆ _audioProfile

cocos2d::AudioProfile AudioProfileTest::_audioProfile
private

在文件 NewAudioEngineTest.h114 行定义.

被这些函数引用 init().

◆ _files

std::string AudioProfileTest::_files[FILE_COUNT]
private

在文件 NewAudioEngineTest.h113 行定义.

被这些函数引用 init().

◆ _minDelay

float AudioProfileTest::_minDelay
private

在文件 NewAudioEngineTest.h119 行定义.

被这些函数引用 init() , 以及 update().

◆ _showLabel

cocos2d::Label* AudioProfileTest::_showLabel
private

在文件 NewAudioEngineTest.h117 行定义.

被这些函数引用 init().

◆ _time

float AudioProfileTest::_time
private

在文件 NewAudioEngineTest.h118 行定义.

被这些函数引用 init() , 以及 update().

◆ _timeSlider

void* AudioProfileTest::_timeSlider
private

在文件 NewAudioEngineTest.h120 行定义.

被这些函数引用 init() , 以及 update().

◆ FILE_COUNT

const int AudioProfileTest::FILE_COUNT = 2
staticprivate

在文件 NewAudioEngineTest.h112 行定义.

被这些函数引用 init().


该类的文档由以下文件生成: