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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:09:01+00:00 2026-06-18T10:09:01+00:00

In my Cocos2d 2.0 iOS game, I use a CCMenuAdvanced to create a scrolling

  • 0

In my Cocos2d 2.0 iOS game, I use a CCMenuAdvanced to create a scrolling menu. The problem is that the invisible portion of the menu also seems to be handling touches.

Here is the code (needed to get boundaryRect to display and crop properly):

// background is full screen, with all pixels transparent 
// except the part where menu shows
CCSprite *menuBackground = [CCSprite spriteWithFile:@"scrollingmenubackground.png"];
//...
[self addChild:menuBackground];
//...    
//create menu items
CCMenuAdvanced *settingsMenu = [CCMenuAdvanced menuWithItems:item1, item2, item3, nil];
//...
[menuBackground addChild:settingsMenu];

// foreground is full screen, with an image    
// with a transparent hole where the menu shows
CCSprite *foreground = [CCSprite spriteWithFile:@"scrollingmenuforeground.png"];    
[menuBackground addChild:foreground];
//...

Now this works fine, and the menu displays, is cropped correctly and handles touches. However, the problem is that when I click below the visible menu, it still handles the touches on the menu, even though there is a sprite with non-transparent pixels ahead of it (foreground).

I have tried fiddling with the zorder by setting the foreground with a higher zorder than the menu but that doesn’t seem to change anything.

    menuBackground.zOrder = 1;
    settingsMenu.zOrder = 2;
    foreground.zOrder = 3;

I also tried setting the menu priority to INT_MIN as well as kCCMenuHandlerPriority - 1, but no effect.

How do I get the menu to only respond in the portion that is visible to the user?

Thanks
Anand

  • 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-18T10:09:02+00:00Added an answer on June 18, 2026 at 10:09 am

    To have an effective ‘mask’, you should use a layer with touch enabled as foreground. In that layer, you can accept touches outside the menu, and do nothing with them, and pass those inside the mask. However, this will cause issues : if the touchBegan inside the mask, and the user drags its finger outside, the menu will still continue scrolling. You can either subclass CCAdvancedMenu to implement your own touch processing requirements, or create your own version of it. I ended up doing the latter because my game designer wanted many other features from it and subclassing became a hindrance rather than a help. BTW, dont rely on zOrder for the touch processing, they are not related.

    Also, the ‘touch mask’ approach will probably come back and haunt you later on (for example if you add other objects alongside your scrolling menu that also need touch, the touches will be masked out), it would be best if all your objects that are concerned with implementing touch related requirements encapsulate their own implementation.

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

Sidebar

Related Questions

my problem is: I'm making a game for iOS using cocos2d and this game
I have a cocos2d powered game that uses UIKit menues, so I only use
What should I use to create a 2D game for iOS? There are a
I'm creating a cocos2d game on iOS that uses the accelerometer. I just started
My cocos2d iOS game code compiles and runs without error in Xcode 4.2.1 but
I have been learning and using Objective-C and cocos2d (iOS game-engine) for a couple
I am building a cocos2d continuous running ios game, where a character is animated
I got this problem since few months. When I test my game on cocos2D
I am looking to create a similar tunnel effect in COCOS2D (iOS). Could anyone
I am developing a cocos2d game in ios. This is the code for app

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.