Hi!
What's the easiest way to add sound to my game e.g. background music and sounds on actions?
Thanks
-Alex
A fast, easy to use, free, and community supported 2D game engine
Hi!
What's the easiest way to add sound to my game e.g. background music and sounds on actions?
Thanks
-Alex
That would be library CocosDenshion and the SimpleAudioEngine interface.
is there an easy tutorial on how to do so... the file seems complicated and daunting
OK I've added the CocosDenshion folder conrtaining SimpleAudioEngine.* to my project and I've added the following frameworks:
AudioToolbox, AVFoundation and OpenAL...
but how do I set up the class files to play a background sound????
Did you even read the link I posted? Here is the code to play a sound file called "mysound.wav" that is in the root of your project.
[[SimpleAudioEngine sharedEngine] playEffect:@"mysound.wav"];
yes, I've added that code :-) in my GameScene.m
-should it be somewhere else?
-is ogg format OK?
I get one build error:
*Building target "Game" of project "Game " with configuration "Debug" - (1 error)
*Linking /Users/alex/......
*".obj_clas_name_SimpleAudioEngine",referenced from:
literal-pointer@_OBJC@_cls_refs@SimpleAudioEngine in GameScene.o
symbol(s) not found
collect2: Id returned 1 exit status
*Build failed (1 error)
Where is my mistake?
OK all works well when starting with the MyFirstGame template in the 0.8 version... otherwise its a matter of fixing linking and dependencies with is causes more errors than I thought.
A good guide on this would help newbies like me :-)
"A good guide on this would help newbies like me :-) "
agreed. However - cocos comes with plenty of code examples that explain how things work - and some of us feel thats the best way to learn anyway. If after going through the code and learning how it works you feel like writing a guide to cocos that would be very appreciated.
"A good guide on this would help newbies like me :-)"
Yes, please write one. I've already spent lots of time trying to make SimpleAudioEngine easy to understand but obviously I haven't made it simple enough.
Yes, please write one. I've already spent lots of time trying to make SimpleAudioEngine easy to understand but obviously I haven't made it simple enough.
lol
"... otherwise its a matter of fixing linking and dependencies with is causes more errors than I thought."
I checked this out and it is wrong. You just need to add the files in the CocosDenshion folder to your project and make sure the 3 frameworks that are detailed in the FAQ have also been added. From memory someone had a similar linking error to yours because they had included multiple copies of the CocosDenshion files in their project.
There is an introductory screencast at http://bobueland.com/cocos2d/?p=195 .
You must log in to post.