Play sound created in cocostudio

The audio component is not of ComAudio type below. So unable to play the sound effect. SoundEffects.csb file is loaded correctly.

I am using :
cocos2dx-3.7.1
cocostudio 2.3.2

Cocostudio

  • Create new file of type Node. Let’s call it SoundEffects.csd
  • Add Audio component. Let’s call it efxButtonClicked

C++

On some button click:

  auto node = CSLoader::createNode( "SoundEffects.csb" );
  auto comp = node->getComponent( "efxButtonClicked" );
  ComAudio* aud = dynamic_cast<ComAudio*>( comp );
  aud->playEffect();