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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:39:32+00:00 2026-06-04T04:39:32+00:00

It might be that I am missing something fundamental. I have made a class

  • 0

It might be that I am missing something fundamental. I have made a class that inherits CCSprite, called Dude. In my layer I add the object dude, which works correctly: it shows on the screen. Everything goes well, until I touch the screen. Somehow the method “Jump” in my class Dude can’t be reached.

The error I get is:

-[CCSprite Jump::]: unrecognized selector sent to instance 0xf4611a0
2012-05-18 10:20:40.870 bitman[1732:10a03] * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[CCSprite Jump::]: unrecognized selector sent to instance 0xf4611a0’

Can anyone point me in the right direction? Why does the error say [CCSprite Jump::] instead of [Dude Jump::]? What is it that I am missing?

I have a Layer setup as followed (only relevant code):

#import "GameplayLayer.h"
#import "Dude.h"

@implementation GameplayLayer

+(CCScene *) scene
{
    // 'scene' is an autorelease object.
    CCScene *scene = [CCScene node];

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

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

    // return the scene
    return scene;
}

-(id)init{
    self=[super init];
    if(self!=nil){
        dude=[[Dude alloc]init] ;
        dude.position=ccp(screenSize.width/2,screenSize.height/2);
        [self addChild:dude];

        fJumpHight=screenSize.height/3;
        fJumpTime=.2f;
    }
    return self;
}

-(void) registerWithTouchDispatcher
{ 
    [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority: swallowsTouches:YES];
}

-(BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{
    [dude Jump:40:3];
    return YES;
}

@end

I setup the class Dude as followed:
Dude.h:

#import "CCSprite.h"
#import <Foundation/Foundation.h>
#import "cocos2d.h"

@interface Dude : CCSprite

    -(void) Jump:(float)fHight:(float)fTime;

@end

Dude.m:

#import "Dude.h"
#import <Foundation/Foundation.h>
#import "cocos2d.h"

@implementation Dude
-(id)init{
    self=[super init];
    if(self!=nil){

        CGSize screenSize =[CCDirector sharedDirector].winSize;
        self=[[CCSprite spriteWithFile:@"something.png"]retain];
        self.position=ccp(screenSize.width/2,screenSize.height*0.333f);

    }
    return self;
}

-(void) Jump:(float)fHight:(float)fTime{
    NSLog(@"JUMP!");
    //Jump actions    
}
@end
  • 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-04T04:39:33+00:00Added an answer on June 4, 2026 at 4:39 am

    Your main error is within the implementation of your Dude.

    self=[[CCSprite spriteWithFile:@"something.png"]retain];
    

    First, you correctly assign self = [super init] wich leaves self as a Dude but by overwriting self with [CCSprite spriteWithFile:...] you change that to a default CCSprite.

    You could instead use self = [super initWithFile:@"something.png"]. Like this:

    -(id)init {
      self = [super initWithFile:@"something.png"];
      if (self == nil) return nil;
    
      CGSize screenSize =[CCDirector sharedDirector].winSize;
      self.position = ccp(screenSize.width / 2.0, screenSize.height / 3.0);
    
      return self;
    }
    

    Another piece of advice: In objc methods are usually lowercase and tend to give you more information about the parameters.
    So you might consider renaming your Jump:: to

    -(void)jumpWithHeight:(float)height duration:(ccTime)duration {
      ...
    }
    

    This is due to the fact that you read code more often than you write it 😉

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

Sidebar

Related Questions

I have a theoretical grid of overlapping rectangles that might look something like this:
I have a text file that might contain thousands and thousands of numbers(0-9 -->
I have a json property that might be null, and I'd prefer to keep
I have a query that might be executed by several users consecutively. I'm scared
I have a function that might fail, so the value it returns needs to
I have a file that might contain a line like this. A B //Seperated
I have a few classes that perform background tasks that might raise exceptions. They
All, I am missing something fundamental about the underlying model for Django's ForeingKeys vs
It's been a long day, and I'm sure that I must be missing something
I might be missing something obvious but is there a reference somewhere about what

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.