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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:36:16+00:00 2026-05-31T22:36:16+00:00

I’m pretty close to having this figured out and just need the last bit

  • 0

I’m pretty close to having this figured out and just need the last bit (logic). In the following code, the background does scroll vertically (with touches) AND is going in the right direction (i.e. down).

The problem is it doesn’t stop scrolling when it gets beyond the content size of the background image…

(CGPoint)boundLayerPos:(CGPoint)newPos {
CGSize winSize = [CCDirector sharedDirector].winSize;
CGPoint retval = newPos;
retval.y = -MAX(retval.y, -background.contentSize.height+winSize.height);
retval.y = -MIN(retval.y, 0);
retval.x = self.position.x;
return retval;
}

I am also wondering how to make the scrolling seem more natural…i.e. a way to continue for a while but slow down to a stop when TouchesEnded occurs…

  • 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-31T22:36:17+00:00Added an answer on May 31, 2026 at 10:36 pm

    This question is confusing because intuitively your brain thinks the foreground is moving but really it’s the background that you need to move so that it appears as if the foreground is moving…hence it’s easy to get lost in x/y, -x/y, x/-y, -x/-y combinations. It’s also a little confusing to communicate with others (i.e. Did you mean “up” or did you mean “down”)…

    For me, I needed the foreground to appear to be going downwards as it was being scrolled until it came to the bottom. I realized that this meant the background (self) had to move upwards until it reached the highest point (1539.0) which meant it was now displaying the bottom of the background image. I ended up using the following in my tick/update method and it works (i.e. prevents any further scrolling):

    if (self.position.y > 1539.0f) {
    
        //CCLOG(@"My position is greater than 1539");
    
        self.position = ccp(self.position.x, 1539.0f);
    
    }
    

    Not sure how to make the scrolling seem more natural, however…

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.