I am adding a layer to my scene and I want to check when it is fully loaded by setting a boolean after my initialization called doneInitializing to YES. But i need to access it somehow... How do I do that ?
LoadingScreen.h
@interface LoadingScreen : CCLayerColor{
CCLayer *hWL;
}
LoadingScreen.m
hWL = [HelloWorldLayer node];
[self addChild:hWL];
if(hWL.doneInitializing == YES){ // that is where I get stuck
//do something
}
I can't access the variable doneInitializing... WHY ?
HelloWorldLayer.h
@interface HelloWorldLayer : CCLayer
{
BOOL doneInitializing;
}
@property (nonatomic,readwrite) BOOL doneInitializing;
HelloWorldLayer.m
@synthesize doneInitializing;
Is there a better approach to achieve this ??
Just change this part:
To this:
OR use this line instead:
Compiler and the runtime needs to know you are getting a property of the
HelloWorldLayerinstead of theCCLayer. Although you are assigninghWL = [HelloWorldLayer node],hWLhas been declared to be a plainCCLayerand the line withhWL.doneInitializinggets into trouble because as far as the runtime knows, aCCLayerdoes not have a property nameddoneInitializing. You need to tell the runtime "dude, hWL is a HelloWorldLayer" by declaringhWLasHelloWorldLayeror casting it to that class.