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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:09:45+00:00 2026-06-05T08:09:45+00:00

I want to draw a infinitely repeating parallax using Cocos2D on Android. Now, there

  • 0

I want to draw a infinitely repeating parallax using Cocos2D on Android.
Now, there are some solutions given to this problem in Objective C, but I’m stuck with my implementation in Android. I have tried using

CCSprite background = CCSprite.sprite("background_island.png");
CCTexParams params = new CCTexParams(GL10.GL_LINEAR,GL10.GL_LINEAR,GL10.GL_REPEAT,GL10.GL_REPEAT);
            background.getTexture().setTexParameters(params);

But it only extends the background in 1 direction.
I guess I have to use 2 sprites, such that as soon as 1st finishes, the other starts and vice versa, but I’m stuck with the implementation.

  • 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-05T08:09:46+00:00Added an answer on June 5, 2026 at 8:09 am

    I had the same problem and figured it out.

    Try this. Declare the background and offset as a member:

    CCSprite _bg;
    float _bgOffset;
    

    In your scene constructor:

    CGSize winSize = CCDirector.sharedDirector().displaySize();
    _bg = CCSprite.sprite("yourbg.png"); // needs to be square, i.e. 256x256
    _bg.setTextureRect(0, 0, winSize.width, winSize.height, false);
    _bg.getTexture().setTexParameters(GL10.GL_LINEAR, GL10.GL_LINEAR, GL10.GL_REPEAT,
            GL10.GL_REPEAT);
    _bg.setAnchorPoint(CGPoint.zero());
    this.addChild(_bg);
    

    And in your update(float dt) method:

    if (_bgOffset > 2000000000)
        _bgOffset = 0; // don't want problems, do we?
    _bgOffset += dt * PIXELS_PER_SECOND; // this can be dynamic if you want
    _bg.setTextureRect(0, _bgOffset, _bg.getTextureRect().size.width,
                _bg.getTextureRect().size.height, false);
    

    See “Repeating Backgrounds” in http://www.raywenderlich.com/3857/how-to-create-dynamic-textures-with-ccrendertexture for the Objective C code

    If you need to go both ways, you could perhaps start with a non-zero _bgOffset and see if that works.

    Hope this helps someone!

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

Sidebar

Related Questions

I want to draw a simple graph like this in android. Can it be
I want to draw an area from given points on a map using the
I want to draw random shapes in random colors in an image using python.
I want to draw some text on the wallpaper and make it move, but
I want to draw the Silverlight-PhoneApplicationPage and its controls on top of some squares
I want to draw a stock chart using Google Chart Tools. My self-written webservice
I want to draw some hlines and vlines snapped to occupy whole pixels on
I want to draw some items on screen, each item is in one of
I want to Draw a hyper Link in C# using stringbuilder when i create
I want to draw lat log in every 1 Km interval using service. I

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.