I'm trying to implement a loading screen for my game. The app starts at SimpleGameAppDelegate, which calls MainMenu, the first scene. I started by putting the lines in Main Menu, but the user can enter the game while still loading.
Now, I have everything in SimpleGameAppDelegate and it works fine, however all the pre-loaded textures have become white squares!
@implementation SimpleGameAppDelegate
- (id)init {
NSLog(@"begin loading");
if(self = [super init]) {
// preload game textures
[[TextureMgr sharedTextureMgr] addImage:@"game_bg.png"];
[[TextureMgr sharedTextureMgr] addImage:@"tuffy_bold_italic-charmap.png"];
[[TextureMgr sharedTextureMgr] addImage:@"obstacles.png"];
[[TextureMgr sharedTextureMgr] addImage:@"char.png"];
[[TextureMgr sharedTextureMgr] addImage:@"tutorial.png"];
// preload sounds
[PASoundMgr sharedSoundManager];
[[PASoundMgr sharedSoundManager] addSound:@"smack" withPosition:CGPointZero looped:NO];
[[PASoundMgr sharedSoundManager] addSound:@"clank" withPosition:CGPointZero looped:NO];
[[PASoundMgr sharedSoundManager] addSound:@"fall" withPosition:CGPointZero looped:NO];
[[PASoundMgr sharedSoundManager] addSound:@"squish1" withPosition:CGPointZero looped:NO];
[[PASoundMgr sharedSoundManager] addSound:@"squish2" withPosition:CGPointZero looped:NO];
[[PASoundMgr sharedSoundManager] addSound:@"squish3" withPosition:CGPointZero looped:NO];
[[PASoundMgr sharedSoundManager] addSound:@"squish4" withPosition:CGPointZero looped:NO];
[[PASoundMgr sharedSoundManager] addSound:@"squawk" withPosition:CGPointZero looped:NO];
}
return self;
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSLog(@"finished loading");
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window setUserInteractionEnabled:YES];
[window setMultipleTouchEnabled:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
[[Director sharedDirector] setLandscape: YES];
[[Director sharedDirector] attachInWindow:window];
[window makeKeyAndVisible];
MenuScene * ms = [MenuScene node];
[[Director sharedDirector] runWithScene:ms];
}
- (void) dealloc {
[window release];
[super dealloc];
}
@end