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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:25:57+00:00 2026-05-23T05:25:57+00:00

How to implement an ‘menu’ that seems like stuck to it’s position? Here with

  • 0

How to implement an ‘menu’ that seems like stuck to it’s position? Here with stuck I meant to say either scene is moving or still it remain on it’s on position. Which gives feel like it’s on it’s place. I am implementing it by moving it with scrolling scene, it works but behave absurdly, ‘sometimes’.

Here is the code how am I creating menu:

resetPosition =[CCMenuItemImage itemFromNormalImage:@"position.png"
                                      selectedImage:@"position_over.png" 
                                      disabledImage:@"disabled.png"
                                             target:self
                                           selector:@selector(reset)]; 
resetPosition.position =ccp(400, 300);
myresetMenu = [CCMenu menuWithItems:resetPosition, nil];
myresetMenu.position = ccp(0,0);
[[self parent] addChild:myresetMenu z:10];  
[resetPosition setIsEnabled:NO];

And now code for moving the scene(when user trying to scroll the scene). Also I have moved the menu with scene, so it gives the effect that the menu is still with the scene:

if([touchArray count]==1)//scroll
        {

            UITouch *myTouch = [touches anyObject];
            CGPoint location = [myTouch locationInView:[myTouch view]];
            moveLocation1 = [[CCDirector sharedDirector] convertToGL:location];
            float diffX = beginLocation1.x - moveLocation1.x;
            float diffY = beginLocation1.y - moveLocation1.y;   

            //NAVIGATION TOWARDS X AND Y WhenEver and how ever you want         
            if (abs(diffX) > abs(diffY))
            {
                CCLOG(@"yScrlFlag=%d",yScrlFlag);
                if(diffX > 0)
                {
                    xScrlFlag=1;
                    [self.parent runAction:[CCMoveTo actionWithDuration:round(-(-3112-self.parent.position.x)/650)
                                                               position:ccp((-3112-self.position.x),self.parent.position.y)]];
                    [resetPosition setIsEnabled:YES];
                    [resetPosition runAction:[CCMoveTo actionWithDuration:round(-(-3112-self.parent.position.x)/650) 
                                                                 position:ccp((3112+self.position.x+400),resetPosition.position.y)]];
                }
                else
                {
                    xScrlFlag=0;                        
                    [self.parent runAction:[CCMoveTo actionWithDuration:(-self.parent.position.x/650) 
                                                               position:ccp(0,self.parent.position.y)]];
                    //[resetPosition setIsEnabled:YES];
                    [resetPosition runAction:[CCMoveTo actionWithDuration:(-self.parent.position.x/650) 
                                                                 position:ccp(400,resetPosition.position.y)]];
                }
            }
            else
            {                       
                if(diffY < 0)
                {
                    yScrlFlag=1;
                    CCLOG(@"\n nodePosition.x=%f \n nodePosition.y=%f",nodePosition.x,nodePosition.y);
                    [self.parent runAction:[CCMoveTo actionWithDuration:(-(-300-self.parent.position.y)/650) 
                                                               position:ccp(self.parent.position.x,(-self.position.y))]];
                    //[self.parent runAction:[CCMoveBy actionWithDuration:(-(-300-self.parent.position.y)/650)
                    //                                         position:ccp(self.parent.position.x, -diffY)]];
                    [resetPosition setIsEnabled:YES];
                    //[resetPosition runAction:[CCMoveBy actionWithDuration:round(-(-300-self.parent.position.x)/650) 
                    //                                           position:ccp(resetPosition.position.x, (self.parent.position.y))]];
                }
                else
                {   
                    yScrlFlag=0;
                    [self.parent runAction:[CCMoveTo actionWithDuration:(-(-300-self.parent.position.y)/650) 
                                                               position:ccp(self.parent.position.x,0)]];
                    //[resetPosition runAction:[CCMoveTo actionWithDuration:round(-(-300-self.parent.position.x)/650) 
                    //                                           position:ccp(resetPosition.position.x,300)]];
                }   
            }
        }
  • 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-05-23T05:25:57+00:00Added an answer on May 23, 2026 at 5:25 am

    I had a bit of trouble with this a while back. I had been trying to have UI elements that did not get lost when the camera moved. What I ended up doing was adding a CCParallaxNode as a child and setting the parallax ratio to ccp(0.0, 0.0) on everything I put on it. That way the scene can move around but my UI layer stays in place. I’m not sure if that’s the best way to do it, but I’m a dirty hack kind of programmer 🙂

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

Sidebar

Related Questions

I implement a function that acts like getline( .. ). So my initial approach
I'm about to implement a feature in our application that allows the user to
How do I implement a Copy menu item in a Windows application written in
I'm trying to implement something like this: <div> <table> <thead> <tr> <td>Port name</td> <td>Current
Implement Biginteger Multiply use integer array to store a biginteger like 297897654 will be
To implement a status bar like below: [========== ] 45% [================ ] 60% [==========================]
I implement search engine with solr that import minimal 2 million doc per day.
I was trying to implement a simple function that can concatenate any number of
Implement multi-level hierarchies so that super user have also all rights that sub user
To implement depth-first search in a grid, I wrote a function like this (define

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.