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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:41:00+00:00 2026-05-28T04:41:00+00:00

I am trying to convert some Cocos2d-iphone code to Cocos2d-x code and could use

  • 0

I am trying to convert some Cocos2d-iphone code to Cocos2d-x code and could use a little assistance. In the Cocos2d-iphone code, it contains the following definition:

@interface CCPanZoomControllerScale : CCScaleTo {
    CCPanZoomController *_controller;
    CGPoint _point;
}+(id) actionWithDuration:(ccTime)duration scale:(float)s controller:(CCPanZoomController*)controller point:(CGPoint)pt;

@end

@implementation CCPanZoomControllerScale

+(id) actionWithDuration:(ccTime)duration 
                   scale:(float)s 
              controller:(CCPanZoomController*)controller
                   point:(CGPoint)pt
{

return [[[self alloc] initWithDuration:duration scale:s controller:controller point:pt] autorelease];
}

In trying to convert this (statement in bold) to C++, I believe it should be a static method. Also, the Cocos2d-x documentation recommends returning bool, because id doesn’t exist in C++. However in the method implementation I’m not sure what to return. Do I just return true?

static bool actionWithDuration(ccTime duration, float scale, PanZoomController* controller, CCPoint point){
return true;
}

  • 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-05-28T04:41:00+00:00Added an answer on May 28, 2026 at 4:41 am

    In objective-C, you can return the self object in static methods also(means in class methods).But in c++, If you want to return the current object, you need to create the object for current class and need to return that object only. we con’t able to use the “this” directly. So, make this method as non-static and return the current class object “this”.

    You can specify the method declaration as shown below.

    CCAction* className::actionWithDuration(ccTime duration, float scale, PanZoomController *controller, CCPoint point)
    {
        return (your class object);
    }
    

    Whenever you want to call this method, Create the object for that particular class and call this method on the object for example,

    PanZoomController *controller = new PanZoomController();
    CCPanZoomControllerScale *scaleController = new CCPanZoomControllerScale();
    sprite -> runAction(scaleController -> actionWithDuration(duration, scale, controller, pt));
    

    I think this can be helpful for you.

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

Sidebar

Related Questions

I trying to convert some loops in my code to use the for_each functionality
I'm trying to convert some C# code to VB.NET. I have the following in
I'm trying to convert some code that worked great in VB, but I can't
I'm trying to convert some code from C# to C so that it can
There is some code that I'm trying to convert from IList to IEnumerable :
Im trying to convert some Delphi code to c# and I've come across a
I'm trying to convert some c code to assmebly, and I need some help.
I'm trying to convert some code from Javascript to c. The function creates an
I was trying to use TextInfo.ToTitleCase to convert some names to proper case. it
I'm trying to convert some Haskell code to F# but I'm having some trouble

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.