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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:45:36+00:00 2026-06-13T11:45:36+00:00

I am creating a program with cocos2d where I have 2 ccMenuItems each linked

  • 0

I am creating a program with cocos2d where I have 2 ccMenuItems each linked to an image: In this case, one is a left arrow, the other is a right arrow. I also have an image in the center of my view that will rotate depending on the arrow pressed.

When I put my finger on one of the two menu items, either left or right, I want the center image to rotate as long as my finger is on the button. That is where I got lost. I tried using the following code:

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

    CGPoint p = [touch locationInView:[touch view]];

    if (CGRectContainsPoint(leftArrow, p) || CGRectContainsPoint(rightArrow, p)) {
        return YES;
    }
    return NO;
}

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

    CGPoint p = [touch locationInView:[touch view]];

    if (CGRectContainsPoint(leftArrow, p)) {
        [gun runAction:[CCRepeatForever actionWithAction:[CCRotateTo actionWithDuration:0.2 angle:180]]];
    }
    if (CGRectContainsPoint(rightArrow, p)) {
        [gun runAction:[CCRepeatForever actionWithAction:[CCRotateTo actionWithDuration:0.2 angle:0]]];

    }

}

Using this code, when I press on one of the two menu items, the ccTouchBegan method isn’t even called. The method is only called when I touch elsewhere.

How do I work with continuous actions when holding down a ccMenuItem.

Thank you for your help!

  • 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-13T11:45:37+00:00Added an answer on June 13, 2026 at 11:45 am

    As I understand, two methods you posted are in your CCLayer’s subclass.

    First of all, if you want to handle touches by yourself, you must remove menu items. CCMenu has much more touch priority and if it handles that the touch hit any menu item, it will swallow it. Thats why you receive touches only when touch is outside menu items.

    The second one, what is leftArrow and rightArrow? Rects of your arrows?

    And as for me, in such case I can propose you to run update method and change rotation property of your center image in it on every tick. I mean, that rotation value will be 0 if no one arraw was touched and will have positive or negative value due to the arrow you touched.

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

Sidebar

Related Questions

This should be an easy one: I am creating a program that spawns a
I creating a program which send newsletter with a background image. It works fine
I'm creating a program in VB.NET to output multiple images. Some images will have
I'm creating a program to open .txt files in a given directory, I have
I am currently creating a program that dynamically adds Image to a dockPanel every
I am creating a program in C where i have to accept an integer
Im creating a program that is supposed have the user enter a student name
I am creating a program to talk to a IP Camera, of this model:
I'm creating a program in SWT. I have a first Shell that has on
im creating a program that will compile java files, at the moment 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.