Hi all!
I'm implementing a singleton class that controls access to a SPTextureAtlas, but when i run the game on a real Device (and only on real device) I get the following error:
NOTE: when I just call "atlasGeneral" instead of "atlasGeneral2" works correctly on simulator and device (I've imported the necessary files).
Seems that the application can not find the file when running on the device
[Session started at 2011-02-16 13:57:04 +0100.] GNU gdb 6.3.50-20050815 (Apple version gdb-1510) (Fri Oct 22 04:12:10 UTC 2010) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin". tty /dev/ttys001 Loading program into debugger… Program loaded. target remote-mobile /tmp/.XcodeGDBRemote-159-54 Switching to remote-macosx protocol mem 0x1000 0x3fffffff cache mem 0x40000000 0xffffffff none mem 0x00000000 0x0fff none run Running… [Switching to thread 11523] [Switching to thread 11523] sharedlibrary apply-load-rules all continue warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/info/dns.so (file not found). 2011-02-16 13:56:31.374 MyGame[4655:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter' *** Call stack at first throw: ( 0 CoreFoundation 0x33ac0987 __exceptionPreprocess + 114 1 libobjc.A.dylib 0x3347b49d objc_exception_throw + 24 2 CoreFoundation 0x33ac07c9 +[NSException raise:format:arguments:] + 68 3 CoreFoundation 0x33ac0803 +[NSException raise:format:] + 34 4 Foundation 0x3362b54f -[NSURL(NSURL) initFileURLWithPath:] + 70 5 Foundation 0x33650157 +[NSURL(NSURL) fileURLWithPath:] + 30 6 MyGame 0x0000f20c -[SPTextureAtlas parseAtlasXml:] + 300 7 MyGame 0x0000efc0 -[SPTextureAtlas initWithContentsOfFile:texture:] + 304 8 MyGame 0x0000f030 -[SPTextureAtlas initWithContentsOfFile:] + 60 9 MyGame 0x0000ff94 +[SPTextureAtlas atlasWithContentsOfFile:] + 100 10 MyGame 0x0000ed64 +[Atlas atlasGeneral2] + 180 11 MyGame 0x00002fdc -[Game creaEstructura] + 572 12 MyGame 0x00002cdc -[Game initWithWidth:height:] + 244 13 MyGame 0x000025e0 -[VikingTenderAppDelegate applicationDidFinishLaunching:] + 216 14 UIKit 0x3209ec01 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 832 15 UIKit 0x3209a259 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 272 16 UIKit 0x3206648b -[UIApplication handleEvent:withNewEvent:] + 1114 17 UIKit 0x32065ec9 -[UIApplication sendEvent:] + 44 18 UIKit 0x32065907 _UIApplicationHandleEvent + 5090 19 GraphicsServices 0x33b0ef03 PurpleEventCallback + 666 20 CoreFoundation 0x33a556ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26 21 CoreFoundation 0x33a556c3 __CFRunLoopDoSource1 + 166 22 CoreFoundation 0x33a47f7d __CFRunLoopRun + 520 23 CoreFoundation 0x33a47c87 CFRunLoopRunSpecific + 230 24 CoreFoundation 0x33a47b8f CFRunLoopRunInMode + 58 25 UIKit 0x32099309 -[UIApplication _run] + 380 26 UIKit 0x32096e93 UIApplicationMain + 670 27 MyGame 0x000024c4 main + 120 28 MyGame 0x00002448 start + 40 ) terminate called after throwing an instance of 'NSException' Program received signal: “SIGABRT”. warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found). kill quit
Here's my code:
Atlas.h
#import <Foundation/Foundation.h> @interface Atlas : NSObject { } + (SPTextureAtlas *)atlasGeneral; + (SPTextureAtlas *)atlasGeneral2; @end
on Atlas.m
#import "Atlas.h" /* Singleton */ @implementation Atlas + (SPTextureAtlas *)atlasGeneral { static SPTextureAtlas *atlasCompartido; @synchronized(self){ if (!atlasCompartido) { atlasCompartido = [SPTextureAtlas atlasWithContentsOfFile:@"atlas_general.xml"]; //Lazy initialization [atlasCompartido retain]; } } return atlasCompartido; } + (SPTextureAtlas *)atlasGeneral2 { static SPTextureAtlas *atlasCompartido_2; @synchronized(self){ if (!atlasCompartido_2) { atlasCompartido_2 = [SPTextureAtlas atlasWithContentsOfFile:@"atlas_general-2.xml"]; //Lazy initialization [atlasCompartido_2 retain]; } } return atlasCompartido_2; } - (void)dealloc { [super dealloc]; } @end
On my Game.m I instantiate it:
SPImage *img = [[Atlas atlasGeneral2] textureByName:@"texture_0"]; [container addChild:img];
Any Idea?
Thanks guys!
Great Framework, but i'm still learning