Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"SimpleAudioEngine has not been declared" error when trying to enable music pausing in Cocos2D-X

So using Cocos2D-X, in the AppDelegate.cpp file, I uncomment the line:

SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();

so that my audio will be paused when the app is exited. However, when I do this, I get the error stated in the title. How can I fix this?

like image 700
David Small Avatar asked Jun 14 '26 05:06

David Small


2 Answers

It seems to me that you forgot to add declaration of SimpleAudioEngine. Add this lines to AppDelegate.cpp:

#include "SimpleAudioEngine.h"

using namespace CocosDenshion;
like image 50
dfomin Avatar answered Jun 16 '26 19:06

dfomin


the answer from Dmitry Fomin is correct, or after you put

#include "SimpleAudioEngine.h"

you can use

CocosDenshion::SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
like image 36
m.ding Avatar answered Jun 16 '26 20:06

m.ding



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!