alxPlay() work around for iOS 7 for T2D MIT and iTorque 2D
by Michael Cozzolino · 10/07/2013 (12:35 pm) · 8 comments
A work around to get audio in your iTorque2D 1.5 projects and Torque 2D MIT projects for iOS. Compliments of Chris Jorgenson of Cascadia Games He's got Cavorite 3 coming out in a few days so I think it would be nice if you use his fix that you buy some of his iOS works.
In the project navigator, select your project
Select your target
Select the 'Build Phases' tab
Open 'Link Binaries With Libraries' expander
Click the '+' button
Select your framework (You want AVFoundation framework)
***Notes*** If you are using iTorque 2D then you need to use the TGBAppDelegate.h and TGBAppDelegate.mm. If you are using T2D MIT you need to use T2DAppDelegate.h and T2DAppDelegate.mm
The scripting goes like this:
For Torque 2D MIT
%boom = new SceneObject()
{
filename = "modules/TNT/1/assets/audio/boom.wav"; //Be sure you use the correct path!!!!
description = "audioNonLooping"; //To Loop description = "audioLooping";
};
For iTorque 2D
%boom = new ScriptObject()
{
filename = "modules/TNT/1/assets/audio/boom.wav"; //Be sure you use the correct path!!!!
description = "audioNonLooping"; //To Loop description = "audioLooping";
};
You call it in script like so
%play= iPlaySound(%boom.filename,(%boom.description $= "audioNonLooping";));
With All the quotations marks and such the formatting bug on the site trashed the files so here is a link
www.bigmonkgames.com/downloads/ It's under AudioWorkAround.zip.
In the project navigator, select your project
Select your target
Select the 'Build Phases' tab
Open 'Link Binaries With Libraries' expander
Click the '+' button
Select your framework (You want AVFoundation framework)
***Notes*** If you are using iTorque 2D then you need to use the TGBAppDelegate.h and TGBAppDelegate.mm. If you are using T2D MIT you need to use T2DAppDelegate.h and T2DAppDelegate.mm
The scripting goes like this:
For Torque 2D MIT
%boom = new SceneObject()
{
filename = "modules/TNT/1/assets/audio/boom.wav"; //Be sure you use the correct path!!!!
description = "audioNonLooping"; //To Loop description = "audioLooping";
};
For iTorque 2D
%boom = new ScriptObject()
{
filename = "modules/TNT/1/assets/audio/boom.wav"; //Be sure you use the correct path!!!!
description = "audioNonLooping"; //To Loop description = "audioLooping";
};
You call it in script like so
%play= iPlaySound(%boom.filename,(%boom.description $= "audioNonLooping";));
With All the quotations marks and such the formatting bug on the site trashed the files so here is a link
www.bigmonkgames.com/downloads/ It's under AudioWorkAround.zip.
About the author
Indie Developer in the Albany NY area. iOS, PC, Mac OSX development. http://itunes.apple.com/us/artist/michael-cozzolino/id367780489
#2
10/25/2013 (1:04 pm)
Updated the Resource to add the iTorque 2D 1.5 supported files and to include the steps to include the AVFoundation FrameWork.
#3
I test the same code for 1.5 on my iTorque2D 1.6 but I have an error :
assigning to 'id<AVAudioPlayerDelegate>' from incompatible type 'TGBAppDelegate *const'
Bye
12/05/2013 (1:03 pm)
Good resource but ... for iTorque2D 1.6 ?? Have news ??I test the same code for 1.5 on my iTorque2D 1.6 but I have an error :
assigning to 'id<AVAudioPlayerDelegate>' from incompatible type 'TGBAppDelegate *const'
Bye
#4
I added in AppDelegate.h
in the definition of interface TGBAppDelegate :
Into NSObject < ....... , AVAudioPlayerDelegate>
;-)
12/07/2013 (2:23 am)
Ok I resolved it !!!I added in AppDelegate.h
in the definition of interface TGBAppDelegate :
Into NSObject < ....... , AVAudioPlayerDelegate>
;-)
#5
I can start music ..... by :
$loopmenuplaying = iPlaySound(%loopmenu.filename,"true");
but I can't stop music :
iStopSound($loopmenuplaying);
and other function as :
iStopAllSound();
don't work ....
Why ??
Any suggestions ????
Thanks to everyone
^_^
12/11/2013 (11:02 am)
I have a problem now ...I can start music ..... by :
$loopmenuplaying = iPlaySound(%loopmenu.filename,"true");
but I can't stop music :
iStopSound($loopmenuplaying);
and other function as :
iStopAllSound();
don't work ....
Why ??
Any suggestions ????
Thanks to everyone
^_^
#6
12/13/2013 (12:11 am)
I don't know if its my lack of understanding, or if the guide is just not clear enough, but I have no idea what I am supposed to do with the TGBAppDelegate.mm and TGBAppDelegate.h files. I didn't even know they were needed for this fix till I clicked on the link thinking it would have a better tutorial. Also will the iPlaySound function replace alxPlay?
#7
02/24/2014 (6:59 am)
If I need to copy and paste this some where just please tell me where.
#8
"Use of undeclared identifier" for "OBJC_ASSOCIATION_RETAIN" and "objc_getAssociatedObject" and "DEAD_SOUND"
Anyone know why this is?
Thanks,
Warthog
03/17/2014 (5:31 pm)
Okay, I've been gone a long time, but I'm back and trying to implement this in 1.6, but I keep getting:"Use of undeclared identifier" for "OBJC_ASSOCIATION_RETAIN" and "objc_getAssociatedObject" and "DEAD_SOUND"
Anyone know why this is?
Thanks,
Warthog

Joao Brandao
Tricephalus
I'm using iTorque2D 1.5, and when I try to compile on Xcode, it always stops with an error.
Is there any way you could tell me what change I have to do to the files you provided in the AudioWorkAround.zip?
I changed their name to TGBAppDelegate.h and TGBAppDelegate.mm and placed them in the folder iTorque2D_1_5/engine/source/platformiPhone in the Mac version of iTorque2D.
Thank you in advance!