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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:42:18+00:00 2026-06-07T05:42:18+00:00

I subclassed CCSprite to detect a touch to itself. touchBegan fires upon touch, but

  • 0

I subclassed CCSprite to detect a touch to itself.

touchBegan fires upon touch, but log shows that the same sprite is handling touches all the time even though I am touching different sprites every time.
(It’s pointer address is same for all touch.)

Further log shows that it’s the last sprite I added to the world layer.

Why is the last sprite I added react to touch events all by itself?

I used CCSpriteBatchNode, would this be related to the problem?

Or is it because cocos2d just doesn’t perform hit-test to find the correct object to deliver the touch event to?

  • 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-07T05:42:19+00:00Added an answer on June 7, 2026 at 5:42 am

    You need to check if the location of the touch is inside the bounds of your sprite.

    Some weird pseudocode

    function touchBegan(UITouch touch, etc)
        CGPoint pos = get location of touch;
        if (CGRectContainsPoint(sprite.boundingBox, pos)) //I think that is the method you need. It's something like that.
            NSLog(@"Sprite was touched!");
            return YES;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to make many duplicates, or clones, of my CCSprite that's been subclassed.
This problem started happening when I subclassed CCSprite (Entity) to recieve touch input. When
So I have a subclassed UITableView that lists data. I need to make only
I have a subclassed NSTextView that I am manipulating in a separate thread (using
I subclassed uiscrollview and overrode the touch began method to pass touch events to
so I have subclassed a UIViewController that I create. The question is, is there
I've recently decided to subclass my sprite, but I am a bit clueless on
I have subclassed CStatic. I have overrided the ON_WM_VSCROLL event function. But when I
I have a subclassed UIView (currentMapView) that draws a map of several states using
I have a subclassed NSManagedObject that conforms to the MKAnnotation protocol and it has

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.