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

  • Home
  • SEARCH
  • 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 8802827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:10:59+00:00 2026-06-14T01:10:59+00:00

I’m developing my first app for iOS with Cocos2d in Objective C. I’m new

  • 0

I’m developing my first app for iOS with Cocos2d in Objective C. I’m new to objective c but I tried to google around but I cannot find solution for this general problem.

-(void)accelerate{
     moveSpeed = 720.0 / 3.0;

     [self stopAllActions];
     _moving = FALSE;
     CCAnimation *walkAnim = [CCAnimation animationWithFrames:_walkAnimFrames delay:0.066f];
     self.walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
     CGPoint loc = ccp(500, 200);
     [self playerMoveTo:loc];
 }

-(void)playerMoveTo:(CGPoint)moveLocation{
     CGPoint moveDifference = ccpSub(moveLocation, self.position); //here is EXC_BAD_ACCESS
     float distanceToMove = ccpLength(moveDifference);
 }

and this is the way i call Player1 accelerate from my Game Scene:

-(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event {
    CGPoint touchLocation = [touch locationInView: [touch view]];
    touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation];
    touchLocation = [self convertToNodeSpace:touchLocation];
    [self.Player1 accelerate];
}

Player1 is in my gameScene :

//implementation
@synthesize Player1 = _Player1;

//header
@property (nonatomic,retain) TPlayer *Player1;

Thank you for your patience and help. I wasn’t sure what part of code i should put here so please tell me what and I will add it.

Simon

EDIT 1:
Player1 is allocated in init function of game scene. TPlayer is subclass of CCSprite :

_Player1 = [[TPlayer alloc] initWithSpriteFrameName:@"walk2"];

And EXC_BAD_ACCESS happens on this line:

CGPoint moveDifference = ccpSub(moveLocation, self.position);
  • 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-14T01:11:03+00:00Added an answer on June 14, 2026 at 1:11 am

    self.position might be crashing as was mentioned because of memory issues. Self might be getting deallocated on you. What version of Xcode are you running? In the latest version the @synthesize is unnecessary as properties are automatically synthesized for you. You might also consider converting your project to ARC. I have done it with my Cocos2D project and I’m happy I did.

    You could try:

    _Player1 = [[[TPlayer alloc] initWithSpriteFrameName:@"walk2"] autorelease];
    

    or manually bump up the reference count after initializing it:

    [self.Player1 retain];
    

    To see if that helps. This is why I like ARC 🙂

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

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.