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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:56:06+00:00 2026-06-08T12:56:06+00:00

I am developing game in Cocos2d. In it background of scene moving constantly with

  • 0

I am developing game in Cocos2d. In it background of scene moving constantly with x – axis.
I want to understand how can i do it because i am new in cocos2d.

thanks in advance

  • 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-08T12:56:08+00:00Added an answer on June 8, 2026 at 12:56 pm

    Take a look to my code – here are the sources. Find the “moving” technique in HelloWorldLayer.m. I have taken a 360 panorama picture and put it to move continuously from right to left, in fullscreen.

    In your YourClass.h file:

    #import "cocos2d.h"
    @interface YourClass : CCLayer
    
    +(CCScene *) scene;
    
    @end
    

    In your YourClass.m file:

    #import "YourClass.h"
    
    @implementation YourClass
    
    CCSprite *panorama;
    CCSprite *appendix;
    //_____________________________________________________________________________________
    +(CCScene *) scene
    {
        // 'scene' is an autorelease object.
        CCScene *scene = [CCScene node];
    
        // 'layer' is an autorelease object.
        YourClass *layer = [YourClass node];
    
        // add layer as a child to scene
        [scene addChild: layer];
    
        // return the scene
        return scene;
    }
    //_____________________________________________________________________________________
    // on "init" you need to initialize your instance
    -(id) init
    {
        // always call "super" init
        // Apple recommends to re-assign "self" with the "super" return value
        if( (self=[super init])) {
    
            panorama = [CCSprite spriteWithFile: @"panorama.png"];
            panorama.position = ccp( 1709/2 , 320/2 );
            [self addChild:panorama];
    
            appendix = [CCSprite spriteWithFile: @"appendix.png"];
            appendix.position = ccp( 1709+480/2-1, 320/2 );
            [self addChild:appendix];
    
            // schedule a repeating callback on every frame
            [self schedule:@selector(nextFrame:)];
    
        }
        return self;
    }
    //_____________________________________________________________________________________
    - (void) nextFrame:(ccTime)dt {
    
        panorama.position = ccp(panorama.position.x - 100 * dt, panorama.position.y);
        appendix.position = ccp(appendix.position.x - 100 * dt, appendix.position.y);
        if (panorama.position.x < -1709/2) {
            panorama.position = ccp( 1709/2 , panorama.position.y );
            appendix.position = ccp( 1709+480/2-1, appendix.position.y );
        }
    
    }
    // on "dealloc" you need to release all your retained objects
    - (void) dealloc
    {
        // in case you have something to dealloc, do it in this method
        // in this particular example nothing needs to be released.
        // cocos2d will automatically release all the children (Label)
    
        // don't forget to call "super dealloc"
        [super dealloc];
    }
    //_____________________________________________________________________________________
    @end
    

    Play a little with this code and you will get what you need.

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

Sidebar

Related Questions

I am new to cocos2d and im developing my first iphone game. The requirement
So I am developing a game and I want it to have background sound
Background: I'm developing a game for the iPhone/iPad using cocos2d-iphone. Our engine provides the
hi I am developing a cocos2d Game. I want to move CCSprite with accelerometer
I am developing an iPhone game with Cocos2d-iphone. I want my game to only
I'm developing a game using cocos2d v2.0 beta2. Since i worked with iOS5.0 all
I'm currently developing a doodle-jump style game in Cocos2d for iPhone and have a
I am currently developing a card game for the iphone using cocos2d. I am
I had choosen Cocos2d v1.01rc instead of 2.x when starting developing my first game
I am developing a game in android,I want use the services to play and

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.