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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:10:21+00:00 2026-06-17T16:10:21+00:00

I am super frustrated and I know it is just because I don’t know

  • 0

I am super frustrated and I know it is just because I don’t know what i am doing with cocos2d. I am following Ray Wenderlich tutorials on cocos2d and I am trying to put it all together. When the screen is tapped,one bullet is fired in the direction of the tap. I am using

- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint touchLocation = [self convertTouchToNodeSpace:touch];
    [self.officer shootToward:touchLocation];
    [self.officer shootNow];
}

- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint touchLocation = [self convertTouchToNodeSpace:touch];
    [self.officer shootToward:touchLocation];
    [self.officer shootNow];
}

which calls these methods in my Officer class

- (void)shootNow {
    // 1
    CGFloat angle = ccpToAngle(_shootVector);
    _gun.rotation = (-1 * CC_RADIANS_TO_DEGREES(angle)) + 90;

    // 2
    CGSize winSize = [[CCDirector sharedDirector] winSize];
    float mapMax = MAX(winSize.width, winSize.height);
    CGPoint actualVector = ccpMult(_shootVector, mapMax);

    // 3
    float POINTS_PER_SECOND = 300;
    float duration = mapMax / POINTS_PER_SECOND;

    // 5
    for(id item in self.children) {
    NSString *bulletName = [NSString stringWithFormat:@"bullet.png"];
    CCSprite * bullet = [CCSprite spriteWithSpriteFrameName:bulletName];
    //bullet.tag = _type;
    bullet.position = ccpAdd(self.position, ccpMult(_shootVector, _gun.contentSize.height));
    CCMoveBy * move = [CCMoveBy actionWithDuration:duration position:actualVector];
    CCCallBlockN * call = [CCCallBlockN actionWithBlock:^(CCNode *node) {
        [node removeFromParentAndCleanup:YES];
    }];
    [bullet runAction:[CCSequence actions:move, call, nil]];
    [self.batchNode addChild:bullet];

        //[self addChild:bullet];
        [_shotsFired addObject:bullet];
    }
}

So I figured it would be a simple for loop go through the 5th step x amount of times then call a reload method. Well that didn’t work. So I tried to count the touches on the screen, I figured if I got x amount of taps then call the reload method(which is not written yet)? The problem with that was every time you pressed a different area of the screen the count started over from one. Some please help me through this week long process of pulling my hair out? How do I count the amount of times I have fired the gun?

  • 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-17T16:10:22+00:00Added an answer on June 17, 2026 at 4:10 pm

    Couldn’t you just make a property on your view controller and then every time the shoot now method is called just add 1 to your property, then reset it to 0 when you call the reload method?

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

Sidebar

Related Questions

I was originally super frustrated when trying to set up Stylus, because I would
I'm super frustrated by this one, because I've got to be doing something obviously
OK, I am most likely just missing something basic but I am super frustrated
I'm still super new with Rails, and just trying to get my first has_many
Getting super frustrated trying to get this working. Basically this is for a site
I'm trying to write a super sort Javascript library for myself just to make
Im sure this is super simple, all I am trying to do is center
Super nub question time! I am trying to use simplejson on the google appengine.
Super newbie question here. I'm trying to teach myself Web Forms, so I'm experimenting
I am super frustrated with a php soap error and this keeps me occupied

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.