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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:01:56+00:00 2026-06-05T19:01:56+00:00

I am using the ccTouchBegan and ccTouchEnded, and for some reason there is a

  • 0

I am using the ccTouchBegan and ccTouchEnded, and for some reason there is a block of code that runs perfectly on iPhone simulator and doesn’t run at all on iPhone 4. This is what my methods look like:

-(BOOL)ccTouchBegan:(UITouch*)touch withEvent:(UIEvent *)event {

firstTouch = [self convertTouchToNodeSpace:touch];

if (!self.currentFootball.footballHasEmbarked) {

    //arrow.position = ccp(fPos.x, fPos.y);
    float newAnc = (120 + (self.currentFootball.contentSize.width * .5f) + (arrow.contentSize.width * .5f)) / arrow.contentSize.width;
    arrow.anchorPoint = ccp(-newAnc, .5);//self.currentFootball.position;
    arrow.position = self.currentFootball.position;//ccp(fPos.x-120, fPos.y);
arrow.rotation = 180;
arrow.visible = YES;
arrow.scale = 0.5f;

    //powerLevel.position = fPos;
    powerLevel.position = self.currentFootball.position;
    powerLevel.rotation = 180;
powerLevel.percentage = 0;
powerLevel.visible = YES;

    outLine.position = self.currentFootball.position;
    outLine.rotation = 180;
    outLine.visible = YES;

    CCProgressFromTo *powerBarGoUp = [CCProgressFromTo actionWithDuration:1.0f from:0.0f to:100.0f];

    CCProgressFromTo *powerBarGoDown = [CCProgressFromTo actionWithDuration:1.0f from:100.0f to:0.0f];

    id action = [CCRepeatForever actionWithAction:[CCSequence actions:powerBarGoUp, powerBarGoDown,  nil]];
    [powerLevel runAction:action];

    return YES;
}
else {
    return NO;
}

}

-(void) ccTouchEnded:(UITouch*)touch withEvent:(UIEvent *)event {

const float max = 100;

CGPoint endTouch = [self convertTouchToNodeSpace:touch];

if (endTouch.x > firstTouch.x) {
endTouch = ccp(firstTouch.x, endTouch.y);
    //CCLOG(@"I ran");
}

arrow.visible = NO;
powerLevel.visible = NO;
    outLine.visible = NO;
self.currentFootball.footballHasEmbarked = YES;
self.currentFootball.spiraling = YES;

if (self.currentFootball) {

    [smgr addBody:self.currentFootball.body];

}

 if (CGPointEqualToPoint(endTouch, firstTouch)) {
    CCLOG(@" I have run");
    float   anchorPointDist = ccpLength(endTouch);

    float   distFactor = distFromFb + anchorPointDist;

    projectionAnchorPoint = ccp(firstTouch.x + distFactor,firstTouch.y);

}

    CGPoint diff = ccpSub(endTouch, projectionAnchorPoint);

    float len = powerLevel.percentage;

CGPoint norm = ccpNormalize(diff);

if (len > max){
    len = max;
}

[self.currentFootball applyImpulse:ccpMult(norm, (len * 300))];

pos = self.currentFootball.position.y;

[self schedule:@selector(newFootball)]; 

}

This is the block of code that will not run on my iPhone.

if (CGPointEqualToPoint(endTouch, firstTouch)) {
    CCLOG(@" I have run");
    float   anchorPointDist = ccpLength(endTouch);

    float   distFactor = distFromFb + anchorPointDist;

    projectionAnchorPoint = ccp(firstTouch.x + distFactor,firstTouch.y);

}

Am I not doing something right?

  • 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-05T19:01:57+00:00Added an answer on June 5, 2026 at 7:01 pm

    Print out the values for endTouch and firstTouch. They may vary by a very small amount on device, as it’s harder to keep your finger in the same location as opposed to a mouse pointer. If that’s the case, you may want to accept end touches within a range of the first touch.

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

Sidebar

Related Questions

My question is that, I was using this method before it was working perfectly,
Using ASP.NET MVC there are situations (such as form submission) that may require a
(I'm using cocos2d for iphone) First I'll explain you my code: (the important parts)
I'm trying to make my sprites stay in screen borders using the following code:
Using android 2.3.3, I have a background Service which has a socket connection. There's
Using mercurial, I've run into an odd problem where a line from one committer
Using Yii, I want to delete all the rows that are not from today.
Using a JEditorPane, is there any way to tell if the caret is currently
Using this example . Pretend there are date fields in both forms. How would
Using the ndk I have compiled a code written in C. The program is

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.