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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:47:14+00:00 2026-05-27T00:47:14+00:00

In my game in objective c, I have two classes, The main ArcherClass and

  • 0

In my game in objective c, I have two classes, The main ArcherClass and the person class.
Here is part of the .m of the person class.

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

    if (self) {
        _bow = [CCSprite spriteWithFile:@"bpw.png"];

    }
    return self;
}

Here is part of main ArcherClass.m

  Player *object = nil;
        CCSprite *bow;

        bow = [object bow];

        //bow = [CCSprite spriteWithFile:@"bow.png"];
        [self addChild:bow z:1];

        bow.position = ccp(150,150);

The following code gets a sigbart error, because of the part I commented out. If I delete the comment, the code works fine.

Why can I not use the image file declared in the Person class? I already declared that sprite as to having that image value or whatever, but for some reason I have to re-declare the image in my main class? Why is that.

  • 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-27T00:47:14+00:00Added an answer on May 27, 2026 at 12:47 am

    Assuming that your “person” class and “Player” classes referred to are the same thing, this code:

    Player *object = nil;         
    CCSprite *bow;          
    bow = [object bow];
    

    Is going to set bow to nil. You haven’t initialised object so any methods called on it will return nil.

    Somewhere in your code you need the following:

    Player *object = [[Player alloc] init];
    

    It’s difficult to say where without more context, but if you are sending messages to object, you need to have a valid instance of it. You don’t say how the archer class and player classes are related.

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

Sidebar

Related Questions

Currently I have this code in my UIViewController: //Cocos2D methods -(id) init { if((self=[super
I'm making a game and I have a class called Man and a class
I have a game entity class as follows : @interface CPlanet : NSObject {
I have a game built on xcode using objective c. this game needs to
I'm writing an iPhone game in objective-C using XCode. I'd like to profile the
I'd like to give Objective-C a try in game programming. The problem is I'd
I've been trying to implement a simple component-based game object architecture using Objective-C, much
I have a little game written in C#. It uses a database as back-end.
I have a set of Objective-C files in my app labeled Crop.h/Crop.m. Inside is
Is there a nice way to do this in Objective-C, or do I have

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.