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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:38:26+00:00 2026-06-14T13:38:26+00:00

I have made a method player method (inherits from NSObject) that I initialize in

  • 0

I have made a method player method (inherits from NSObject) that I initialize in the HelloWorldLayer class. I want to declare other methods of the same class in such a way that I don’t need to alloc them. For Example:

Player.mm

-(id)spritePlayer:(CCLayer *)parentLayer 
                     inWorld:(b2World *)world
{
    creation of sprite body and other stuff
}

I want to use this method in the contact Listener class, but I’ve declared it the player class:

-(void) touchingFix:(b2Fixture *)touchedFix
{
    bodyTouched=TRUE;
    bodyFix=touchedFix;
}

In the Contact Listener class I can only access it through:

[[Player alloc] touchingFix:fixtureA];

Can’t I access it in a way without allocating it in another method? if yes, how can I do it.

  • 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-14T13:38:27+00:00Added an answer on June 14, 2026 at 1:38 pm

    Change it to a class method: remove the ‘-‘ in front of the method and change it to a ‘+’

    +(void) touchingFix:(b2Fixture *)touchedFix
    {
        bodyTouched=TRUE;
        bodyFix=touchedFix;
    }
    

    You can access a class method by using the class name instead of a pointer to an instance of the class:

    [Player touchingFix:fixtureA];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made simple encryption/decryption method in php that I'm trying to move to
So I have made a .dll containing some methods that I wish to use
I have made a code that read data from flash Nand (without filesystem). fd
I made an Interface having all common methods a player should have. I implemented
I have made a player that plays mp3 and does the job very well
I have a Adapter class in which I have made a method to delete
From what I have played around with JQuery Dialog, I made an observation that
I have made this method that creates a 2D array for co-ordinates and places
I have made a form validation using ajax post method. But i got the
I have made a custom NSView and have implemented the keyDown: method. However, when

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.