Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-22-2010, 05:24 AM   #1 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 18
Default White Box - Cocos2D

Hi, I've been attempting to create a Loading Bar that loads and then displays the loaded scene in Cocos2D. My code first loads a special loadingScreen scene which creates a thread to initialize the coming scene. The coming scene updates the loadingScreen every x amount of %, and when it's done, calls the finished method to display itself on the scene and remove the old scene.

However, while the loading bar does load up, the resulting scene that it loads to has a white box in the center of it (where it's supposed to have a normal sprite icon). The shape is correct as well as the position, but the color is all white.

Here is the code that starts the thread:

Quote:
-(void) loadLayerid)layer
{
CCScene *scene = [CCScene node];
[scene addChild:self];

//LoadingScreen deterimines if the Layer on the scene responds to the Load protocol
//LoadingScreen calls

if ([layer conformsToProtocol:@protocol(Load)]) {
[[CCDirector sharedDirector] replaceScene: scene];

[self updateToPercent:0];
[NSThread detachNewThreadSelector:@selector(initFromLoadingS creen toTarget:layer withObject:self];

} else {

[[CCDirector sharedDirector] replaceScene:scene];
}
}
The threaded selector is this:

Quote:
-(void) initFromLoadingScreenLoadingScreen *)ld
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

for (int i = 0; i < 4; i++) {
[ld updateToPercent:i];
[NSThread sleepForTimeInterval:0.5];
}

spritetest = [CCSprite spriteWithFile:@"Icon.png"];
[spritetest setPosition:ccp(512, 384)];
[self addChild:spritetest];

[ld finished:self];

[self scheduleUpdate];

[pool drain];
}
And the finished method that should replace the current scene and display the new layer.

Quote:
-(void) finishedid)layer
{
@synchronized(self) {
CCScene *scene = [CCScene node];

[scene addChild:layer];

[[CCDirector sharedDirector] replaceScene:scene];
}
}
ImpGuard is offline   Reply With Quote
Old 06-22-2010, 10:47 AM   #2 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 18
Default

This is a really strange problem, and I think it may have to do wit the way I use NSThread. Can anyone shed some light on it?
ImpGuard is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 345
20 members and 325 guests
ADY, Alsahir, Dani77, e2applets, JasonR, keeshux, linkmx, mer10, Monstertaco, piesia, prchn4christ, Promo Dispenser, Robiwan, sebasx, sly24, Touchmint, twerner, zulfishah
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,760
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:28 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0