2
\$\begingroup\$

I'm new to Cocos2d-x and working on a mac. I'm trying to play music in my demo project but I'm unable to include "SimpleAudioEngine.h" in the default HelloWorld Project. I tried adding CocosDenshion to my project but I got more errors. Anyone who knows how to fix this please help.

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

You need to add CocosDenshion, which is the audio library. Be sure the link is done correctly or copypaste it into your folder and use <> import just in case

#include <SimpleAudioEngine.h> 

Once you have it correctly linked the functions used are quite trivial:

CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("stuff.wav"); 

Be sure to be using the supported formats in each platform

\$\endgroup\$
4
  • \$\begingroup\$ In the default HelloWorld project CocosDenshion is not there so I'm unable to include SimpleAudioEngine.h I tried adding the folder to project in xcode but now I'm getting compiler errors. The best way i found till now is installing the template and then creating a new project. \$\endgroup\$ Commented Mar 14, 2012 at 4:43
  • \$\begingroup\$ Don't add the folder, just the SimpleAudioEngine.h library in your Class folder, and include it with <>. The rest of the libraries are compiled and linked together and they don't have to be inside the HelloWorld folder. \$\endgroup\$ Commented Mar 14, 2012 at 10:16
  • \$\begingroup\$ Maybe I'm doing something wrong can't get SimpleAudioEngine to work with HelloWorldpProject. Thanks for the help ! :) \$\endgroup\$ Commented Mar 14, 2012 at 14:36
  • \$\begingroup\$ Sadly I cannot send you my code, but the tutorial I used as reference is cocos2d-x.org/projects/cocos2d-x/wiki/… I solved the linking problem the way I showed you, but the include is probably the cause. \$\endgroup\$ Commented Mar 14, 2012 at 14:39

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.