Note that there are some explanatory texts on larger screens.

plurals
  1. POCCLayer is null
    text
    copied!<p>I am trying to change the color of a CCLayerColor called bgColorLayer, however when I check to see if it is initialized it returns null. I have a color picker that calls the <code>setBGColor:</code> method. I know the colorpicker is calling the method and it is spitting out the correct colors. I am just at a loss as to why the bgColorLayer is null.</p> <p>This is Cocos2D for Mac.</p> <p>Any thoughts on why?</p> <p>In my AppDelegeate method I have an IBOUTLET that is is tied to the NSColorWell</p> <pre><code>- (IBAction)colorwellBackground:(id)sender { NSLog(@"Color Well: %@", [sender color]); // Yes I know the sender color isn’t passing the correct value AnimationViewerLayer * bkg = [AnimationViewerLayer alloc]; [bkg setBGColor:[sender color]]; } </code></pre> <p><strong>AnimationViewerLayer.h</strong></p> <pre><code>@interface AnimationViewerLayer : CCLayer { CCLayerColor * bgColorLayer; } + (CCScene *) scene; @end </code></pre> <p><strong>AnimationViewLayer.m</strong></p> <pre><code> #import "AnimationViewerLayer.h" @implementation AnimationViewerLayer +(CCScene *) scene { CCScene *scene = [CCScene node]; AnimationViewerLayer *layer = [AnimationViewerLayer node]; [scene addChild: layer]; return scene; } -(id) init { if( (self=[super init])) { float red = 25.0 * 255; bgColorLayer = [CCLayerColor layerWithColor:ccc4(57, 109, 58, 255)]; [self addChild:bgColorLayer z:1]; } return self; } - (void) setBGColor: (ccColor3B) color{ NSLog(@"SET BG COLOR"); [bgColorLayer setColor:ccRED]; } - (void) dealloc { [super dealloc]; } @end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload