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

The Archive Base Latest Questions

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

I am adding a layer (hudLayer) to my gamePlay scene, and then adding a

  • 0

I am adding a layer (hudLayer) to my gamePlay scene, and then adding a menu to that layer from which I want to run a function - (void) pauseGame {
method in here }

I’m trying to implement this like so:

- (void) addPauseButton: (CCScene *) parent {
pauseButton = [CCMenuItemImage itemWithNormalImage:@"pause.png" selectedImage:nil target:parent selector:@selector(pauseGame:)];
pause = [CCMenu menuWithItems:pauseButton, nil];
[hudLayer addChild: pause];
if (device == @"iPad") {
    pause.position = ccp(40,40);
}
else if (device == @"iPhoneFive") {
    pause.position = ccp(290,30);
}
else {
    pause.position = ccp(290,30);
}
}

- (id)init {

if( (self=[super init])) {
    paused = FALSE;
    CGSize screenSize = [CCDirector sharedDirector].winSize;

    hudLayer = [[[CCLayer alloc] init] autorelease];
    [self addChild:hudLayer z:2]; // adds hudLayer

    gameLayer = [[[CCLayer alloc] init] autorelease];
    [self addChild:gameLayer z:1];

    pauseMenu = [[[CCLayer alloc] init] autorelease];
    [self addChild:pauseMenu z:4];

    [self setupWorld];
    [self addPauseButton:self];   //calls method to add pause button to hudLayer sending it the scene as a variable

    CGPoint offScreenPoint = ccp(screenSize.width+(screenSize.width/2), 0);

    pauseMenu.position = offScreenPoint;

    self.motionManager = [[[CMMotionManager alloc] init] autorelease];
    motionManager.deviceMotionUpdateInterval = 1.0/60.0;
    if (motionManager.isDeviceMotionAvailable) {
        [motionManager startDeviceMotionUpdates];
    }
    self.iPadBool = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;

    if (iPadBool) {
        device = @"iPad";
    }
    else if (screenSize.height > 490) {
        device = @"iPhoneFive";
    }
    else {
        device = @"iPhone";
    }
    NSLog(@"the current device is a, %@", device);
    [self schedule:@selector(update:)];

}
return self;
}

However this throws the error: * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[gamePlay pauseGame:]: unrecognized selector sent to instance 0x11d310e0’ No idea why at all :/ any idea’s?

  • 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-13T07:20:05+00:00Added an answer on June 13, 2026 at 7:20 am

    The selector should be

    @selector(pauseGame)
    

    without the colon. It doesn’t take a parameter. Method should be:

    -(void) pauseGame
    {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a child layer that I'm adding to the scene which contains a
I am adding a layer to my scene and I want to check when
I'm tinkering with adding a model layer to an iPhone application so that I
I am adding a UITextField's layer as a sublayer to an existing layer that
Normally when adding sprites to a layer in cocos2d I'd just add a pointer
I'm in the process of adding a Data Access Layer for our ASP.Net 2.0
What is the equivalent of UIViewAnimationOptionBeginFromCurrentState flag when adding CABasicAnimation directly to the layer?
I am adding layer objects to the stage with a depth value. I have
I'm creating a custom (layer-hosting) document view, which is contained within a scroll view.
I'm adding a shadow to my view layer like so: self.view.layer.shadowOffset = CGSizeZero; self.view.layer.shadowOpacity

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.