title: How to duplicate sprite of sprites in cocos2d-x 2.1.4
body: <p>Well, my question is simple, I'm starting with cocos2d-x programming and I'm trying to make a tiled infinite background, lets say I have a png of an image I want to repeat infinitely as a background, What I did was that I created a Sprite as a container, then I added sprites with the same image, one aside the next, covering about 110% the screen, then, following the Space game tutorial I created the same sprite of sprites once again as a second background and I use it as two large identical images to scroll infinite... it works perfect... but I'm wondering if it is possible to create the second sprite by just copying the frist. Some code maybe will clear my situation:</p>
  
  <p>this goes in the init():</p>
  
  <pre><code>acum = 0.0;
  city1 = CCSprite::create();
  for(int i = 0; i &lt; 12; ++i) {
      CCSprite *city = CCSprite::createWithSpriteFrameName("env_buildings_background2.png");
      city-&gt;setPosition(ccp(acum, 0));
      city1-&gt;addChild(city);
      acum+= city-&gt;getContentSize().width*0.99;
  }
  city1-&gt;setContentSize(ccp(acum, 0));
  city2 = CCSprite::create();
  acum = 0.0;
  for(int i = 0; i &lt; 12; ++i) {
      CCSprite *city = CCSprite::createWithSpriteFrameName("env_buildings_background2.png");
      city-&gt;setPosition(ccp(acum, 0));
      city2-&gt;addChild(city);
      acum+= city-&gt;getContentSize().width*0.99;
  }
  city2-&gt;setContentSize(ccp(acum, 0));
  _backgroundNode-&gt;addChild(city1, -1 , buildingspeed, ccp(0, winSize.height * 0.6));
  
  _backgroundNode-&gt;addChild(city2, -1 , buildingspeed, ccp(city1-&gt;getContentSize().width, winSize.height * 0.6));
  printf("%f - %f\n", city1-&gt;getContentSize().width, city2-&gt;getContentSize().width);
  </code></pre>
  
  <p>The main problem is here, where I need to create city2 from city1 and not just repeat code... is there a way to do this? I don't see a constructor in CCSprite that allows me to do so...</p>
  
  <p>this goes in the update():</p>
  
  <pre><code>CCArray *cities = CCArray::createWithCapacity(2);
  cities-&gt;addObject(city1);
  cities-&gt;addObject(city2);
  for ( int ii = 0; ii &lt;cities-&gt;count(); ii++ ) {
      CCSprite * city = (CCSprite *)(cities-&gt;objectAtIndex(ii));
      float xPosition = _backgroundNode-&gt;convertToWorldSpace(city-&gt;getPosition()).x;
      float size = city-&gt;getContentSize().width;
      if ( xPosition &lt; -size ) {
          _backgroundNode-&gt;incrementOffset(ccp(city-&gt;getContentSize().width*2,0),city);
      }
  }
  </code></pre>
  
  <p>I will appreciate any help, thanks in advance.</p>