title: How to perform drag and drop operation on sprite fetched from array and present on screen ?
body: <p>I want to perform drag and drop operation on these image. </p>
  
  <p>How can i make it possible with the following code.</p>
  
  <pre><code>void storeLocation::changescene()
  {
  
  this-&gt;removeAllChildren();
  //CCDirector::sharedDirector()-&gt;replaceScene(storeLocation::scene());
  
  CCSize visibleSize = CCDirector::sharedDirector()-&gt;getVisibleSize();
  CCPoint origin = CCDirector::sharedDirector()-&gt;getVisibleOrigin();
  
  //CCScene* scene=CCScene::create();
      storeLocation *layer = storeLocation::create();
      CCSprite *k=CCSprite::create("background.png");
      this-&gt;addChild(k,0);
      k-&gt;setPosition(ccp(visibleSize.width/2+ origin.x, visibleSize.height/2 + origin.y));
      CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                      "CloseNormal.png",
                                      "CloseSelected.png",
                                      this,
                                      menu_selector(storeLocation::menuCloseCallback));
  
  pCloseItem-&gt;setPosition(ccp(origin.x + visibleSize.width - pCloseItem-&gt;getContentSize().width ,
                              origin.y + pCloseItem-&gt;getContentSize().height/2));
  pCloseItem-&gt;setScale(1.5);
  // create menu, it's an autorelease object
  CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
  pMenu-&gt;setPosition(CCPointZero);
  this-&gt;addChild(pMenu, 1);
  
          this-&gt;addChild(pMenu, 1);
          this-&gt;setTouchEnabled(true);
  
  
  
  
  
  
  
  
  
  
  
  int l=5;
  int posx=0,posy=0;
  
  
  int count=0,r,j=-1,i=0,flag=0;
  int x=20;
  int b[30],a[30];
  while(count&lt;=5)
  {
      srand(time(0));
  
      r=rand()%x+1;
      flag=checktag(b,r,j);
      if(flag==1)
      {
  
  
      b[i]=r;
      i++;
      count++;
      j++;
  
      }
  
  }
  
              int t;
  
  
  CCObject* jt=NULL;
  
  CCARRAY_FOREACH(images, jt)
      {
             // CCSize winSize = CCDirector::sharedDirector()-&gt;getWinSize();
              //float i=winSize.width;
  
          CCSprite *image = dynamic_cast&lt;CCSprite*&gt;(jt);
          t=image-&gt;getTag();
          for(i=0;i&lt;l;i++)
          {
              if(t==b[i])
              {
                  this-&gt;addChild(image);
          image-&gt;setPosition(ccp(100+posx,100));
          posx=posx+120;
  
  
              }}}
  </code></pre>