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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:24:01+00:00 2026-06-09T22:24:01+00:00

In cocos2d-x, the following piece of code is supposed to run the callback function

  • 0

In cocos2d-x, the following piece of code is supposed to run the callback function after a delay. What do I need to do to fix the error?

bool LoadingLevelScreen::initialise() {

        // set up the time delay
    CCDelayTime *delayAction = CCDelayTime::actionWithDuration(0.5f);

    // perform the selector call
    CCCallFunc *callSelectorAction = CCCallFunc::actionWithTarget( 
        this, callfunc_selector( LoadingLevelScreen::menuCallbackStart ) );

    // run the action
    this->runAction( CCSequence::actions(
        delayAction, callSelectorAction, NULL ) );
}

void LoadingLevelScreen::menuCallbackStart(CCObject * pSender)
{
}

Compiler Error:

error C2440: 'type cast' : 
cannot convert from 'void (__thiscall LoadingLevelScreen::* )(cocos2d::CCObject *)' 
to 'cocos2d::SEL_CallFunc'
Pointers to members have different representations; cannot cast between them
  • 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-09T22:24:03+00:00Added an answer on June 9, 2026 at 10:24 pm

    Either remove the CCObject* parameter in menuCallbackStart() method (because CCCallFunc::actionWithTarget() expects a method with no arguments), or change CCCallFunc to CCCallFuncO which expects a method with a CCObject* as argument, like so:

    CCCallFuncO * callSelectorAction =
        CCCallFuncO::create(this, &LoadingLevelScreen::menuCallbackStart, myObject);
    

    where myObject is a CCObject * that will be passed to your method as the argument.

    Note that callfunc_selector() is just a macro that typecasts your method to SEL_CallFunc:

    #define callfunc_selector(MYSELECTOR) (SEL_CallFunc)(& (MYSELECTOR))
    

    BTW ::actionWithTarget() is being deprecated, so use ::create() instead.

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

Sidebar

Related Questions

I have written my code in following way in cocos2d. id actionTo = [CCFadeOut
My cocos2d iOS game code compiles and runs without error in Xcode 4.2.1 but
I use the following code to add cocos2d scene to a viewcontroller - (void)viewDidLoad
I am using cocos2d and have the following code which moves my layer based
When am using build and analyse method the following error occurs:- /Users/ghost/demo/libs/cocos2d/CCSprite.m:476:2 Assigned value
I am using following code for sprite animation in cocos2d [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile: @AnimBear.plist];
In my cocos2D(cocos2d 0.99.5 version) project i integrated a uiview as the following code
I have a very strange error using NSMutableArray in cocos2d/xcode In my code, I
fresh to objC and cocos2d :) i'm following learn cocos2d game development with iOS5,
i am following a tutorial on a simple cocos2d game . however on that

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.