How can I create object and use it in Objective-C?
Try the following code to initialise it.
AudioEngine *audio = [[AudioEngine alloc] init];
you can use following code to call its method.
if you have some code like audio.abc.pausAll then you can call it by simply adding .
[[audio abc] pauseAll];
AudioEngine is a C++ class. You will be calling C++ from Obj-C. In particular, the
AudioEngine's methods are static functions, so there is no "object" to create.
You should pause and resume as opposed to mute and unmute, since mute would continue playback and simply set the volume to 0. Additionally, pausing is easier based the functions avail in the
AudioEngine header you listed. Volume control requires knowing the
audioID which would require some tracking to ensure that all playing audio is muted/unmuted.
When you want to pause, just call:
To resume, just call:
As an FYI, it is possible you may need to use the
cocos2d namespace as well. Which means
experimental would change to
Another caveat is that your Obj-C code must be compiled as Objective-C++ source.
There are two ways to do this.
- The source file uses the
- The type of the file set in the File Inspector in Xcode is
explicitly set to
.mfiles will be listed as
Objective-C Source. To do this, select the file in the Project Navigator and then choose View:Inspectors:Show File Inspector in the menu. The File Inspector, if not already present, will show up on the far right.