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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:40:09+00:00 2026-05-31T19:40:09+00:00

please help me, i’m very new in objective-c i’ve got 2 simplest classes (bellow

  • 0

please help me, i’m very new in objective-c

i’ve got 2 simplest classes (bellow first, second)

i would like to set the offsetx properties of rolypoly object in second class like a self.rolypoly.offsetx=1 or run use [self.rolypoly setOffx]; to do somethings, but i always have the errors:

trying [self.rolypoly setOffx]; in second class

-[CCScene setOffx:]: unrecognized selector sent to instance 0x91d0b70′

or

trying self.rolypoly.offsetx=1; in second class

-[CCScene setOffsetx:]: unrecognized selector sent to instance 0x808bfc0′

first class

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

        @interface RolyPoly : CCLayer {

            CCAction *_walkAction; 
            CCSprite *_rolypoly;
            int offsetx;
            int offsety;
        }

        @property (nonatomic, retain) CCSprite *rolypoly;
        @property (nonatomic, retain) CCAction *walkAction;
        @property (nonatomic, assign) int offsetx;
        @property (nonatomic, assign) int offsety;

        +(id) scene;
        -(void) setOffx;
        @end
//************************************************************     
        #import "GameLayer.h"
        #import "RolyPoly.h"

        @implementation RolyPoly

        @synthesize rolypoly = _rolypoly;
        @synthesize walkAction = _walkAction;
        @synthesize  offsetx = _offsetx;
        @synthesize  offsety = _offsety;

        +(id) scene
        {
            CCScene *scene = [CCScene node];

            RolyPoly *layer = [RolyPoly node];

            [scene addChild: layer];

            return scene;
        }

        -(id) init
        {
            if ((self = [super init]))
            {

                [self scheduleUpdate];
            }
            return self;
        }
        -(void) setOffx
        {

            NSLog(@"setOffx");
        }

        -(void) update:(ccTime)delta
        {

        }
        - (void) dealloc
        {
            self.rolypoly = nil;
            self.walkAction = nil;
            [super dealloc];
        }
        @end

second class

//************************************************************ 
    #import <Foundation/Foundation.h>
    #import "cocos2d.h"
    #import "RolyPoly.h"


    @interface GameLayer : CCLayer {

        RolyPoly *_rolypoly;
    }

    // returns a CCScene that contains the HelloWorldLayer as the only child
    +(CCScene *) scene;
    @property (nonatomic, assign) RolyPoly * rolypoly;

    @end

//************************************************************   
    #import "GameLayer.h"
    #import "RolyPoly.h"

    // HelloWorldLayer implementation
    @implementation GameLayer

    @synthesize  rolypoly = _rolypoly;

    +(CCScene *) scene
    {
        CCScene *scene = [CCScene node];
        GameLayer *layer = [GameLayer node];
        [scene addChild: layer];
        return scene;
    }

    -(id) init
    {
        if( (self=[super init])) {

            CGSize screenSize = [[CCDirector sharedDirector] winSize];

            self.rolypoly = [RolyPoly scene];
            [self addChild:self.rolypoly z:1];
            [self.rolypoly setOffx];
            [self scheduleUpdate];

        }
        return self;
    }


    - (void)update:(ccTime)dt {

    }

    - (void) dealloc
    {
        [super dealloc];
    }
    @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-05-31T19:40:10+00:00Added an answer on May 31, 2026 at 7:40 pm

    Your problem lies in the fact that your passing a CCScene object into your rolyPoly variable, not the rolyPoly object.

        +(id) scene
        {
            CCScene *scene = [CCScene node];
    
            RolyPoly *layer = [RolyPoly node];
    
            [scene addChild: layer];
    
            return scene;
        }
    

    return scene;

    Delete your scene method in RolyPoly class and just use this in your scene

           self.rolypoly = [RolyPoly node];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please Help me to do this first i have this div <div class=loader alt=stat.php>
please help so here is the problem i got a rails app that sends
please help me, I got the Join Predicate not valid error for the below
Please help me I am New in PHP and since last 5 Hours i
Please help me fetching google like url descriptions in just one SQL query. see
please help on this issue: Within a loop, I first call a function, which
Please help me in separating the classes, headers and main() in the following program.
please help to rewrite Urls from http://www.site.com/index.php?cat=catname and http://www.site.com/index.php?id=productname to be like this http://www.site.com/catname
Please help me how to insert LIKE % in date between. Example is: SELECT
Please help! I'm really at my wits' end. My program is a little personal

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.