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 8829871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:56:04+00:00 2026-06-14T07:56:04+00:00

[self classmethod] in super class and then use it child class I’m making some

  • 0

[self classmethod] in super class and then use it child class
I’m making some iPhone game based on cocos2d.
In many games I’ve seen before, the scene restart when user’s character die or gone.
It can be done simply but needs some handling if implement in each child class.

[[CCDirector sharedDirector] replacescene:[childclass scene]];

But if I could implement in parent class, it can be done by once. I guess.
So I tried [self scene] in parent class, but it doesn’t work.

How can I do this in parent class?

added in

@interface Parent : CCLayer  {}

+(CCScene*)scene;

-(void)dead;

@end

@implementation Parent

…

+(CCScene*)scene {

CCScene *scene = [CCScene node];

// 'layer' is an autorelease object.
Parent *layer = [Parent node];

// add layer as a child to scene
[scene addChild: layer];

// return the scene
return scene;

}

…

-(void)dead {

// called after character death

[[CCDirector sharedDirector] replacescene:[self scene]]; //This makes a error “Parent may not respond to ‘scene'”

}


@interface Child1 : Parent {}

+(CCScene*)scene;

@end

@implementation Parent

…

+(CCScene*)scene {

CCScene *scene = [CCScene node];

// 'layer' is an autorelease object.
Child *layer = [Child node];

// add layer as a child to scene
[scene addChild: layer];

// return the scene
return scene;

}

…

@end

I think Child1 doesn’t need dead method implementation because it’s child class of Parent
but it doesn’t work. And Child2, Child3…too.

It works when I move the dead method to Child1 and modify its self -> Child1

Please let me know, if u can’t understand my question.
thank u for reply.

  • 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-14T07:56:06+00:00Added an answer on June 14, 2026 at 7:56 am

    Have found the solution I wanted.

    -(void) dead { // if your character died, call this method

    [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:2.0 scene:[self.class scene]]];

    }

    In dead method, self can be child class inherited from super class.

    ex) super class is Stage : CCLayer, and child class is Stage1 : Stage dead method is invoked when your character die in Stage1,Stage2,Stage3 … You don’t need to implement each dead method in those class(Stage1,Stage2..) like [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:2.0 scene:[StageX scene]]];

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

Sidebar

Related Questions

I have a method which calls for a classmethod of another class def get_interface_params_by_mac(self,
As what I just learned, I can use super() this way: super(class, obj_of_class-or-_subclass_of_class) Code
I have a class that contains this class method: def self.get_event_record(row, participant) event =
Suppose I have the following object: class Foo(object): def __init__(self, name=None): self.name = name
I currently have a project and tests similar to these. class mylib: @classmethod def
Hi I'm trying to use the CIKernel class I don't understand why is it
How can one accomplish class-based default value in following scheme? I mean, I would
When redefining a class method I want to be able to call super, just
I have the following class hierarchy: class A(object): def __init__(self, filename, x): self.x =
I'm having some problems with the super function in Python. Suppose I have these

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.