Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8146899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:09:43+00:00 2026-06-06T14:09:43+00:00

i’ve got a Scene class that adds several layers. I would like to add

  • 0

i’ve got a “Scene” class that adds several layers. I would like to add a last layer at the end of the game (to show the different scores) from one of the layer (so this layer would call the Scene class with a delegate, and the Scene class should add this new layer: “LevelCompleteLayer”).

But the method in the Scene class does not receive the call. Would you know why? The other delegates (between the layers) work fine, but this one (from the layer to the Scene) does not.

Here’s the code :

//in Level1Scene.h :
@interface Level1Scene : CCScene <CompleteLayerDelegate>{

//in Level1Scene.mh :
@implementation Level1Scene
@synthesize levelComplete;

-(void)showLevelCompleteLayer {
    CCLOG(@"delegateCompleteLayer showLevelCompleteLayer!!!");//does not show up
    [self addChild:levelComplete z:5000];//is not added
}

-(id)init {
    if ((self = [super init])) {
        ScoreLayer *scoreLayer = [ScoreLayer node];
        layer = [[Level1Layer alloc] initWithBackgroundImage:background.backgroundImage];
        levelComplete = [[LevelComplete alloc] init];

        layer.delegate = scoreLayer;//works fine
        layer.delegateCompleteLayer = self; //does not respond
        scoreLayer.delegate = layer;//works fine
        //...
    }
    return self;
}



//in Level1Layer.m :
[delegateCompleteLayer showLevelCompleteLayer];

//in GameProtocols.h :
@protocol CompleteLayerDelegate
-(void)showLevelCompleteLayer;
@end

Thanks for your help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:09:44+00:00Added an answer on June 6, 2026 at 2:09 pm

    As a way to discover why it is not working, I would suggest:

    1. add a breakpoint (or a trace) in the method (let’s call it method A) where you execute
      [delegateCompleteLayer showLevelCompleteLayer];?

    2. if it is called, inspect delegateCompleteLayer value;

    3. if it is not, set a breakpoint in the method that should call method A;

    4. (repeat, similarly to 2/3).

    EDIT:

    If I understand correctly, when you execute [delegateCompleteLayer showLevelCompleteLayer];, instead of jumping into that method, you jump to a random (more or less) memory address.

    It seems to me that this is a hint to a memory management issue. It seems like your delegateCompleteLayer has become garbage at the moment when you call showLevelCompleteLayer from Level1Layer.

    You could inspect your code and make sure that the delegateCompleteLayer is properly retained and that its dealloc method is not called early (put a breakpoint or a trace in there).

    Another thing you could try is enabling zombies detection. Please, read this to know how to do it.

    EDIT 2:

    About your second attempt with the delegate, I think that when you do:

         //in the init :
         [delegate startGame];
    

    your delegate might have been not set yet (in the init method), so that explain why the call is void.

    More generally, I suggest that you put NSLog traces in all of your dealloc methods:

    NSLog(@"DEALLOCATING OBJECT %@", [self description]);
    

    so that you can detect any unforeseen deallocation; and also before each call to a delegate that does not work:

    NSLog(@"CALLING INTO DELEGATE %@", [YOUR_DELEGATE_HERE description]);
    

    to check that your are calling the right object.

    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.