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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:30:22+00:00 2026-05-14T05:30:22+00:00

I am using cocos2d to build an iPhone game. It’s mostly done, but along

  • 0

I am using cocos2d to build an iPhone game. It’s mostly done, but along the way I came across some things that I would like to handle better. I am fairly new to Objective C, and honestly I do more Perl scripting in my day-to-day job than anything, so my C skills are a little rusty.

One of them is the fact that I have modified cocos2d files for some specific cases in my game. However, when I update to a new version, I have to manually pull my changes forward.

So, the question is, what is the best way to deal with this?

Some options I have thought of:

  1. Overload/redefine the cocos2d classes. I was under the impression that I cannot overload existing class functions, so I don’t think this will work.
  2. Create patches that I re-apply after library updates. I don’t think this will work as the new files won’t necessarily be the same as the old ones, and if they were, I could just copy the whole file forward.
  3. Turn in my changes to Cocos2d. Not an option as my changes are very specific to my application.

Am I missing something obvious?

UPDATE:

I will explain what I am doing to be more clear.

Cocos2d has a CCNode object, which can contain children, etc. I added a shadow, which is very similar to a child, but handled a little differently. The shadow has an offset from the parent, and translates with it’s parent, rotates around it’s own center when the parent rotates, etc. The shadow is not included as a true child, however, so given the correct z-index, the shadows can render under ALL other objects, but still move with the parent.

To do this I added addShadow functions to CCNode, and modified the setPosition and setRotate functions to move the shadowSprite:

CCNode.m:

-(id) init 
{ 
        if ((self=[super init]) ) { 
            ...
            shadowSprite_ = nil;
            ...
        }
}

...

-(BOOL) addShadow: (CCNode*) child offset: (CGPoint) offset
{ 
        shadowSprite_ = child;
        shadowSprite_.position = CGPointMake(position_.x+offset.x, position_.y+offset.y);
        return YES;
} 

...

-(void) setRotation: (float)newRotation
{ 
        rotation_ = newRotation; 
        isTransformDirty_ = isInverseDirty_ = YES;

        if(shadowSprite_) { 
                [shadowSprite_ setRotation: newRotation];
        } 
}

There is more, of course, including the prototypes in the .h file, but that is the basics. I don’t think I need shadowSprite to be a property, because I don’t need to access it after it has been added.

  • 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-14T05:30:23+00:00Added an answer on May 14, 2026 at 5:30 am

    I can think of a few ways to do this:

    • subclass and override certain methods. This is preferable if it is possible.

    slightly hackier methods:

    • Class Posing provides a way to switch out classes
    • Method Swizzling will let you switch out specific methods
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build a game for the iphone using cocos2d engine. I
I am using cocos2d-iphone to place Sprites onto a Layer to setup a game
I just finish my iPhone game using cocos2d, and I want to submit it
I'm making a iPhone App written in Objective-C using the Cocos2d game engine. I'm
Using cocos2d for iPhone game development, I am confused between Layer and Scene. For
I am building a game using cocos2d-iphone 0.99.4 and Xcode 3.2.4. When I try
Background: I'm developing a game for the iPhone/iPad using cocos2d-iphone. Our engine provides the
I'm making a game using cocos2d-iphone, I want's to rotate a Texture2D of maybe
I am trying to develop a iphone app by using cocos2d. I create a
I'm using cocos2d for the iPhone to create an infinitely scrolling horizontal tile map.

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.